-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: morvencao <lcao@redhat.com>
- Loading branch information
Showing
64 changed files
with
1,815 additions
and
8,110 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,75 @@ | ||
# CURD Resource/Bundle with gRPC Client | ||
# Resource Bundle CURD with gRPC Client | ||
|
||
## Preparation | ||
|
||
1. Enable gRPC server by passing `--enable-grpc-server=true` to the maestro server start command, for example: | ||
1. Enable gRPC server by passing `--enable-grpc-server=true` to the maestro server start command: | ||
|
||
```shell | ||
$ oc -n maestro patch deploy/maestro --type=json -p='[{"op": "add", "path": "/spec/template/spec/containers/0/command/-", "value": "--enable-grpc-server=true"}]' | ||
$ kubectl -n maestro patch deploy/maestro --type=json -p='[{"op":"add","path":"/spec/template/spec/containers/0/command/-","value":"--enable-grpc-server=true"}]' | ||
``` | ||
|
||
2. Port-forward the gRPC service to your local machine, for example: | ||
2. Do the port-forward the maestro-grpc service: | ||
|
||
```shell | ||
$ oc -n maestro port-forward svc/maestro-grpc 8090 & | ||
$ kubectl -n maestro port-forward svc/maestro-grpc 8090 & | ||
``` | ||
|
||
## Operate Resource Bundle with gRPC client | ||
## How | ||
|
||
1. Set the source ID for the manifestwork client and consumer name: | ||
|
||
```shell | ||
$ export SOURCE_ID=grpc | ||
$ export CONSUMER_NAME=cluster1 | ||
``` | ||
|
||
2. Create a resource bundle: | ||
|
||
```shell | ||
# create | ||
go run ./grpcclient.go -grpc_server localhost:8090 -cloudevents_json_file ./cloudevent-bundle.json | ||
$ go run ./grpcclient.go -source=$SOURCE_ID -consumer-name=$CONSUMER_NAME -cloudevent-file ./cloudevent.json | ||
``` | ||
|
||
# update | ||
go run ./grpcclient.go -grpc_server localhost:8090 -cloudevents_json_file ./cloudevent-bundle-update.json | ||
Note: If your gRPC server enable authentication and authorization, you'll need to provide the CA file for the server and the client's token. For example, after setting up Maestro with `make e2e-test/setup`, you can retrieve the gRPC server's CA, client certificate, key, and token using the following command: | ||
|
||
# delete | ||
go run ./grpcclient.go -grpc_server localhost:8090 -cloudevents_json_file ./cloudevent-bundle-delete.json | ||
```shell | ||
kubectl -n maestro get secret maestro-grpc-cert -o jsonpath="{.data.ca\.crt}" | base64 -d > /tmp/grpc-server-ca.crt | ||
kubectl -n maestro get secret maestro-grpc-cert -o jsonpath="{.data.client\.crt}" | base64 -d > /tmp/grpc-client-cert.crt | ||
kubectl -n maestro get secret maestro-grpc-cert -o jsonpath="{.data.client\.key}" | base64 -d > /tmp/grpc-client-cert.key | ||
kubectl -n maestro get secret grpc-client-token -o jsonpath="{.data.token}" | base64 -d > /tmp/grpc-client-token | ||
``` | ||
|
||
You also need to create a cluster role to grant publish & subscribe permissions to the client by running this command: | ||
|
||
```shell | ||
$ cat << EOF | kubectl apply -f - | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: ClusterRole | ||
metadata: | ||
name: grpc-pub-sub | ||
rules: | ||
- nonResourceURLs: | ||
- /sources/${SOURCE_ID} | ||
verbs: | ||
- pub | ||
- sub | ||
EOF | ||
``` | ||
|
||
then you can create a resource bundle with the following command: | ||
|
||
```shell | ||
$ go run ./grpcclient.go -source=$SOURCE_ID -consumer-name=$CONSUMER_NAME -cloudevent-file ./cloudevent.json -grpc-server-tls=true -grpc-server=127.0.0.1:30090 -grpc-server-ca-file=/tmp/grpc-server-ca.crt -grpc-client-token-file=/tmp/grpc-client-token | ||
``` | ||
|
||
2. Update the resource bundle: | ||
|
||
```shell | ||
$ go run ./grpcclient.go -source=$SOURCE_ID -consumer-name=$CONSUMER_NAME -cloudevent-file ./cloudevent-update.json -grpc-server-tls=true -grpc-server=127.0.0.1:30090 -grpc-server-ca-file=/tmp/grpc-server-ca.crt -grpc-client-token-file=/tmp/grpc-client-token | ||
``` | ||
|
||
3. Delete the resource bundle: | ||
|
||
```shell | ||
$ go run ./grpcclient.go -source=$SOURCE_ID -consumer-name=$CONSUMER_NAME -cloudevent-file ./cloudevent-delete.json -grpc-server-tls=true -grpc-server=127.0.0.1:30090 -grpc-server-ca-file=/tmp/grpc-server-ca.crt -grpc-client-token-file=/tmp/grpc-client-token | ||
``` |
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.