Skip to content

Commit 0154ff4

Browse files
authored
update mw client doc and build cli (#487)
Signed-off-by: Wei Liu <liuweixa@redhat.com>
1 parent 36077c4 commit 0154ff4

File tree

6 files changed

+267
-135
lines changed

6 files changed

+267
-135
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
# Ignore built binaries
3333
/maestro
3434
/maestroperf
35+
/maestro-cli
3536

3637
# Ignore generated templates
3738
/templates/*-template.json

Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,10 @@ binary: check-gopath
189189
${GO} build $(BUILD_OPTS) ./cmd/maestro
190190
.PHONY: binary
191191

192+
maestro-cli:
193+
${GO} build $(BUILD_OPTS) -o maestro-cli ./examples/manifestwork/client.go
194+
.PHONY: maestro-cli
195+
192196
# Install
193197
install: check-gopath
194198
CGO_ENABLED=$(CGO_ENABLED) GOEXPERIMENT=boringcrypto ${GO} install -ldflags="$(ldflags)" ./cmd/maestro

README.md

Lines changed: 121 additions & 116 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,127 @@ ensuring that resource status is continuously updated and monitored.
4040
**Improve Security Architecture**: Maestro enhances security by eliminating the need for kubeconfigs,
4141
reducing the need for direct access to clusters.
4242

43-
## Run in Local Environment
43+
## Run in KinD Cluster
44+
45+
You can also run the maestro in a KinD cluster locally.
46+
47+
```shell
48+
$ make test-env
49+
```
50+
51+
This creates a KinD cluster with name `maestro`, and deploys the maestro server and agent in the cluster. The Kubeconfig of the KinD cluster is in `./test/_output/.kubeconfig`.
52+
53+
```shell
54+
$ export KUBECONFIG=$(pwd)/test/_output/.kubeconfig
55+
$ kubectl -n maestro get svc
56+
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
57+
maestro NodePort 10.96.143.3 <none> 8000:30080/TCP 7m42s
58+
maestro-db ClusterIP 10.96.53.61 <none> 5432/TCP 7m59s
59+
maestro-grpc NodePort 10.96.114.161 <none> 8090:30090/TCP 7m42s
60+
maestro-healthcheck ClusterIP 10.96.67.145 <none> 8083/TCP 7m42s
61+
maestro-metrics ClusterIP 10.96.201.253 <none> 8080/TCP 7m42s
62+
maestro-mqtt ClusterIP 10.96.241.85 <none> 1883/TCP 7m59s
63+
64+
$ kubectl get pods -n maestro
65+
NAME READY STATUS RESTARTS AGE
66+
maestro-85c847764-4xdt6 1/1 Running 0 5m
67+
maestro-db-65f57d978c-c68 1/1 Running 0 5m
68+
maestro-mqtt-6cb7bdf46c-kcczm 1/1 Running 0 5m
69+
$ kubectl get pods -n maestro-agent
70+
NAME READY STATUS RESTARTS AGE
71+
maestro-agent-5dc9f5b4bf-8jcvq 1/1 Running 0 3m
72+
```
73+
74+
Now you can create a resource bundle with the `MaestroGRPCSourceWorkClient`, check the [document](./examples/manifestwork/README.md) for more details.
75+
76+
## Run in OpenShift
77+
78+
If you are using an OpenShift cluster in the cloud, you need to export Kubeconfig to point to your cluster and skip the CRC login step. If you are using CodeReady Containers (CRC) locally, you need to login to the CRC cluster first.
79+
80+
### Log into CRC
81+
82+
Use OpenShift Local to deploy to a local openshift cluster. Be sure to have CRC running locally:
83+
84+
```shell
85+
$ crc status
86+
CRC VM: Running
87+
OpenShift: Running (v4.13.12)
88+
RAM Usage: 7.709GB of 30.79GB
89+
Disk Usage: 23.75GB of 32.68GB (Inside the CRC VM)
90+
Cache Usage: 37.62GB
91+
```
92+
93+
```shell
94+
$ make crc/login
95+
Logging into CRC
96+
Logged into "https://api.crc.testing:6443" as "kubeadmin" using existing credentials.
97+
98+
You have access to 66 projects, the list has been suppressed. You can list all projects with 'oc projects'
99+
100+
Using project "default".
101+
Login Succeeded!
102+
```
103+
104+
### Set external_apps_domain
105+
106+
You need to set the `external_apps_domain` environment variable to point your cluster.
107+
```shell
108+
$ export external_apps_domain=`oc -n openshift-ingress-operator get ingresscontroller default -o jsonpath='{.status.domain}'`
109+
```
110+
111+
### Deploy Maestro
112+
113+
If you want to push the image to your OpenShift cluster default registry and then deploy it to the cluster. You need to follow [this document](https://docs.openshift.com/container-platform/4.13/registry/securing-exposing-registry.html) to expose a default registry manually and login into the registry with podman. Then run `make push` to push the image to the registry.
114+
115+
If you want to use the default image, you can skip the `make push` step.
116+
117+
```shell
118+
$ make deploy
119+
120+
$ oc get pod -n maestro
121+
NAME READY STATUS RESTARTS AGE
122+
maestro-85c847764-4xdt6 1/1 Running 0 62s
123+
maestro-db-5d4c4679f5-r92vg 1/1 Running 0 61s
124+
maestro-mqtt-6cb7bdf46c-kcczm 1/1 Running 0 63s
125+
```
126+
127+
### Create a Consumer
128+
129+
```shell
130+
$ curl -k -X POST -H "Authorization: Bearer $TOKEN" \
131+
-H "Content-Type: application/json" \
132+
https://maestro-maestro.${external_apps_domain}/api/maestro/v1/consumers \
133+
-d '{
134+
"name": "cluster1"
135+
}'
136+
```
137+
You should get a response like this:
138+
139+
```shell
140+
{
141+
"created_at":"2023-12-08T11:35:08.557450505Z",
142+
"href":"/api/maestro/v1/consumers/3f28c601-5028-47f4-9264-5cc43f2f27fb",
143+
"id":"3f28c601-5028-47f4-9264-5cc43f2f27fb",
144+
"kind":"Consumer",
145+
"name":"cluster1",
146+
"updated_at":"2023-12-08T11:35:08.557450505Z"
147+
}
148+
```
149+
150+
### Deploy Maestro Agent
151+
152+
```shell
153+
$ export consumer_name=cluster1
154+
$ export install_work_crds=false
155+
$ make deploy-agent
156+
$ oc get pod -n maestro-agent
157+
NAME READY STATUS RESTARTS AGE
158+
maestro-agent-5dc9f5b4bf-8jcvq 1/1 Running 0 13s
159+
```
160+
161+
Now you can create a resource bundle with the `MaestroGRPCSourceWorkClient`, check the [document](./examples/manifestwork/README.md) for more details.
162+
163+
## Run Maestro server with binary
44164

45165
### Make a build, run postgres and message broker (MQTT or Pub/Sub)
46166

@@ -261,118 +381,3 @@ curl http://localhost:8000/api/maestro/v1/resource-bundles
261381
"total": 1
262382
}
263383
```
264-
265-
## Run in OpenShift
266-
267-
If you are using an OpenShift cluster in the cloud, you need to export Kubeconfig to point to your cluster and skip the CRC login step. If you are using CodeReady Containers (CRC) locally, you need to login to the CRC cluster first.
268-
269-
### Log into CRC
270-
271-
Use OpenShift Local to deploy to a local openshift cluster. Be sure to have CRC running locally:
272-
273-
```shell
274-
$ crc status
275-
CRC VM: Running
276-
OpenShift: Running (v4.13.12)
277-
RAM Usage: 7.709GB of 30.79GB
278-
Disk Usage: 23.75GB of 32.68GB (Inside the CRC VM)
279-
Cache Usage: 37.62GB
280-
```
281-
282-
```shell
283-
$ make crc/login
284-
Logging into CRC
285-
Logged into "https://api.crc.testing:6443" as "kubeadmin" using existing credentials.
286-
287-
You have access to 66 projects, the list has been suppressed. You can list all projects with 'oc projects'
288-
289-
Using project "default".
290-
Login Succeeded!
291-
```
292-
293-
### Set external_apps_domain
294-
295-
You need to set the `external_apps_domain` environment variable to point your cluster.
296-
```shell
297-
$ export external_apps_domain=`oc -n openshift-ingress-operator get ingresscontroller default -o jsonpath='{.status.domain}'`
298-
```
299-
300-
### Deploy Maestro
301-
302-
If you want to push the image to your OpenShift cluster default registry and then deploy it to the cluster. You need to follow [this document](https://docs.openshift.com/container-platform/4.13/registry/securing-exposing-registry.html) to expose a default registry manually and login into the registry with podman. Then run `make push` to push the image to the registry.
303-
304-
If you want to use the default image, you can skip the `make push` step.
305-
306-
```shell
307-
$ make deploy
308-
309-
$ oc get pod -n maestro
310-
NAME READY STATUS RESTARTS AGE
311-
maestro-85c847764-4xdt6 1/1 Running 0 62s
312-
maestro-db-5d4c4679f5-r92vg 1/1 Running 0 61s
313-
maestro-mqtt-6cb7bdf46c-kcczm 1/1 Running 0 63s
314-
```
315-
316-
### Create a Consumer
317-
318-
```shell
319-
$ curl -k -X POST -H "Authorization: Bearer $TOKEN" \
320-
-H "Content-Type: application/json" \
321-
https://maestro-maestro.${external_apps_domain}/api/maestro/v1/consumers \
322-
-d '{
323-
"name": "cluster1"
324-
}'
325-
```
326-
You should get a response like this:
327-
328-
```shell
329-
{
330-
"created_at":"2023-12-08T11:35:08.557450505Z",
331-
"href":"/api/maestro/v1/consumers/3f28c601-5028-47f4-9264-5cc43f2f27fb",
332-
"id":"3f28c601-5028-47f4-9264-5cc43f2f27fb",
333-
"kind":"Consumer",
334-
"name":"cluster1",
335-
"updated_at":"2023-12-08T11:35:08.557450505Z"
336-
}
337-
```
338-
339-
### Deploy Maestro Agent
340-
341-
```shell
342-
$ export consumer_name=cluster1
343-
$ export install_work_crds=false
344-
$ make deploy-agent
345-
$ oc get pod -n maestro-agent
346-
NAME READY STATUS RESTARTS AGE
347-
maestro-agent-5dc9f5b4bf-8jcvq 1/1 Running 0 13s
348-
```
349-
350-
Now you can create a resource bundle with the `MaestroGRPCSourceWorkClient`, check the [document](./examples/manifestwork/README.md) for more details.
351-
352-
## Run in KinD Cluster
353-
354-
You can also run the maestro in a KinD cluster locally. The simplest way is to use the provided script to create a KinD cluster and deploy the maestro in the cluster. It creates a KinD cluster with name `maestro`, and deploys the maestro server and agent in the cluster.
355-
356-
```shell
357-
$ make test-env
358-
```
359-
The Kubeconfig of the KinD cluster is in `./test/_output/.kubeconfig`.
360-
```shell
361-
$ export KUBECONFIG=$(pwd)/test/_output/.kubeconfig
362-
$ kubectl -n maestro get svc
363-
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
364-
maestro NodePort 10.96.143.3 <none> 8000:30080/TCP 7m42s
365-
maestro-db ClusterIP 10.96.53.61 <none> 5432/TCP 7m59s
366-
maestro-grpc NodePort 10.96.114.161 <none> 8090:30090/TCP 7m42s
367-
maestro-healthcheck ClusterIP 10.96.67.145 <none> 8083/TCP 7m42s
368-
maestro-metrics ClusterIP 10.96.201.253 <none> 8080/TCP 7m42s
369-
maestro-mqtt ClusterIP 10.96.241.85 <none> 1883/TCP 7m59s
370-
$ kubectl get pods -n maestro
371-
NAME READY STATUS RESTARTS AGE
372-
maestro-85c847764-4xdt6 1/1 Running 0 5m
373-
maestro-db-65f57d978c-c68 1/1 Running 0 5m
374-
maestro-mqtt-6cb7bdf46c-kcczm 1/1 Running 0 5m
375-
$ kubectl get pods -n maestro-agent
376-
NAME READY STATUS RESTARTS AGE
377-
maestro-agent-5dc9f5b4bf-8jcvq 1/1 Running 0 3m
378-
```

0 commit comments

Comments
 (0)