diff --git a/edge/services/nginx-operator/CreateService.md b/edge/services/nginx-operator/CreateService.md index 3146049e..95ada0e2 100644 --- a/edge/services/nginx-operator/CreateService.md +++ b/edge/services/nginx-operator/CreateService.md @@ -75,22 +75,16 @@ The above command will give you an empty ansible operator. At the very least you ```bash wget https://raw.githubusercontent.com/open-horizon/examples/master/edge/services/nginx-operator/ansible-role-files/deployment.j2 && mv deployment.j2 roles/myoperator/templates/ wget https://raw.githubusercontent.com/open-horizon/examples/master/edge/services/nginx-operator/ansible-role-files/service.j2 && mv service.j2 roles/myoperator/templates/ - wget https://raw.githubusercontent.com/open-horizon/examples/master/edge/services/nginx-operator/ansible-role-files/route.j2 && mv route.j2 roles/myoperator/templates/ wget https://raw.githubusercontent.com/open-horizon/examples/master/edge/services/nginx-operator/ansible-role-files/main.yml && mv main.yml roles/myoperator/tasks/ ``` -3. Build the operator image (use ppc64le for power arch): +3. **FOR OCP EDGE CLUSTERS ONLY:** Obtain the `route`, and modified task file and move them into the `my-operator` roles directory: ```bash - operator-sdk build docker.io/$DOCKER_HUB_ID/my.operator_amd64:1.0.0 - docker push docker.io/$DOCKER_HUB_ID/my.operator_amd64:1.0.0 - ``` - -4. In the `deploy/operator.yaml` file replace `"REPLACE_IMAGE"` with the operator image name you build and pushed in the previous step (use ppc64le for power arch): - ```bash - image: "/my.operator_amd64:1.0.0" + wget https://raw.githubusercontent.com/open-horizon/examples/master/edge/services/nginx-operator/ansible-role-files/route.j2 && mv route.j2 roles/myoperator/templates/ + wget https://raw.githubusercontent.com/open-horizon/examples/master/edge/services/nginx-operator/ansible-role-files/main-route.yml && mv main.yml roles/myoperator/tasks/main.yml ``` -5. By default the operator does not have the permission to create routes, however, with the following command you can add the lines needed to the `deploy/role.yaml` file so the operator can expose the `nginx` service with a route: +4. **FOR OCP EDGE CLUSTERS ONLY:** By default the operator does not have the permission to create routes, however, with the following command you can add the lines needed to the `deploy/role.yaml` file so the operator can expose the `nginx` service with a route: ```bash echo "- apiGroups: - route.openshift.io @@ -107,7 +101,18 @@ The above command will give you an empty ansible operator. At the very least you - delete" >> deploy/role.yaml ``` -6. Apply the required resources to run the operator +5. Build the operator image (use ppc64le for power arch): + ```bash + operator-sdk build docker.io/$DOCKER_HUB_ID/my.operator_amd64:1.0.0 + docker push docker.io/$DOCKER_HUB_ID/my.operator_amd64:1.0.0 + ``` + +6. In the `deploy/operator.yaml` file replace `"REPLACE_IMAGE"` with the operator image name you build and pushed in the previous step (use ppc64le for power arch): + ```bash + image: "/my.operator_amd64:1.0.0" + ``` + +7. Apply the required resources to run the operator ```bash kubectl apply -f deploy/crds/my.operator.com_myoperators_crd.yaml kubectl apply -f deploy/service_account.yaml @@ -117,7 +122,7 @@ The above command will give you an empty ansible operator. At the very least you kubectl apply -f deploy/crds/my.operator.com_v1alpha1_myoperator_cr.yaml ``` -7. Ensure the operator pod and the deployed service pod are running: +8. Ensure the operator pod and the deployed service pod are running: ```bash kubectl get pods ``` @@ -129,7 +134,7 @@ If everything deployed correctly you should see an output similar to the followi my-operator-55c6f56c47-b6p7c 1/1 Running 0 48s ``` -8. Check that the service is up: +9. Check that the service is up: ```bash kubectl get service ``` @@ -142,7 +147,7 @@ If everything deployed correctly you should see an output similar to the followi If you are using an **OCP edge cluster** you will need to `curl` the service using the exposed `route`. -9. Get the exposed route name: +10. Get the exposed route name: ```bash kubectl get route -n openhorizon-agent ``` @@ -153,7 +158,7 @@ If the route was exposed correctly you should see an output similar to the follo nginx-route nginx-route-openhorizon-agent.apps.apollo5.cp.fyre.ibm.com nginx 8080 None ``` -10. `curl` the service to test if it is functioning correctly: +11. `curl` the service to test if it is functioning correctly: **OCP edge cluster** substitute the above `HOST/PORT` value: ```bash curl nginx-route-openhorizon-agent.apps.apollo5.cp.fyre.ibm.com @@ -193,15 +198,13 @@ If the service is running you should see following `Welcome to nginx!` output: ``` -11. Delete the resources to stop your operator pod and service +12. Delete the resources to stop your operator pod and service ```bash kubectl delete crd myoperators.my.operator.com kubectl delete deployment my-operator - kubectl delete service my-operator-metrics kubectl delete serviceaccount my-operator kubectl delete rolebinding my-operator kubectl delete role my-operator - kubectl delete route nginx-route ``` **Note:** if any pods are stuck in the `Terminating` state after running the previous commands you can force delete them with the following command: @@ -209,7 +212,7 @@ If the service is running you should see following `Welcome to nginx!` output: kubectl -n delete pods --grace-period=0 --force ``` -12. Create a tar archive that contains the files inside the operators `deploy/` directory: +13. Create a tar archive that contains the files inside the operators `deploy/` directory: ``` tar -zcvf operator.tar.gz deploy/* ``` diff --git a/edge/services/nginx-operator/PatternRegister.md b/edge/services/nginx-operator/PatternRegister.md index ecda57da..b091f3cc 100644 --- a/edge/services/nginx-operator/PatternRegister.md +++ b/edge/services/nginx-operator/PatternRegister.md @@ -10,7 +10,7 @@ 1. Register your edge node with Horizon to use the `nginx-operator` pattern: ```bash - hzn register -p IBM/pattern-nginx.operator-amd64 -u $HZN_EXCHANGE_USER_AUTH + hzn register -p IBM/pattern-ibm.nginx-operator-amd64 -u $HZN_EXCHANGE_USER_AUTH ``` - **Note**: using the `-s` flag with the `hzn register` command will cause Horizon to wait until agreements are formed and the service is running on your edge node to exit, or alert you of any errors encountered during the registration process. diff --git a/edge/services/nginx-operator/README.md b/edge/services/nginx-operator/README.md index 633b6f27..b0ab1a99 100644 --- a/edge/services/nginx-operator/README.md +++ b/edge/services/nginx-operator/README.md @@ -64,7 +64,7 @@ In the following steps you will deploy the `nginx-operator` to your edge cluster ```json { "properties": [ - { "name": "openhorizon.example", "value": "nginx-operator" } + { "name": "openhorizon.example", "value": "operator" } ], "constraints": [ ] @@ -104,17 +104,17 @@ In the following steps you will deploy the `nginx-operator` to your edge cluster ```json { - "mycluster/policy-hello-operator": { + "mycluster/policy-ibm.nginx-operator_1.0.1": { "owner": "root/root", - "label": "nginx-operator Deployment Policy", + "label": "ibm.nginx-operator Deployment Policy", "description": "A super-simple sample Horizon Deployment Policy", "service": { - "name": "nginx-operator", + "name": "ibm.nginx-operator", "org": "IBM", "arch": "*", "serviceVersions": [ { - "version": "1.0.0", + "version": "1.0.1", "priority": {}, "upgradePolicy": {} } @@ -122,10 +122,10 @@ In the following steps you will deploy the `nginx-operator` to your edge cluster "nodeHealth": {} }, "constraints": [ - "openhorizon.example == nginx-operator" + "openhorizon.example == operator" ], - "created": "2020-11-05T19:18:17.722Z[UTC]", - "lastUpdated": "2020-11-05T19:18:17.722Z[UTC]" + "created": "2022-05-12T23:17:04.919499Z[UTC]", + "lastUpdated": "2022-05-12T23:17:04.919489Z[UTC]" } } ``` diff --git a/edge/services/nginx-operator/ansible-role-files/main-route.yml b/edge/services/nginx-operator/ansible-role-files/main-route.yml new file mode 100644 index 00000000..3c75fef2 --- /dev/null +++ b/edge/services/nginx-operator/ansible-role-files/main-route.yml @@ -0,0 +1,17 @@ +--- +# tasks file for nginx operator + +- name: Create the Operator Deployment + k8s: + state: present + definition: "{{lookup('template', 'deployment.j2') | from_yaml}}" + +- name: Create the Operator Service + k8s: + state: present + definition: "{{lookup('template', 'service.j2') | from_yaml}}" + +- name: Create the Operator Route + k8s: + state: present + definition: "{{lookup('template', 'route.j2') | from_yaml}}" \ No newline at end of file diff --git a/edge/services/nginx-operator/ansible-role-files/main.yml b/edge/services/nginx-operator/ansible-role-files/main.yml index 3c75fef2..b4877d1e 100644 --- a/edge/services/nginx-operator/ansible-role-files/main.yml +++ b/edge/services/nginx-operator/ansible-role-files/main.yml @@ -10,8 +10,3 @@ k8s: state: present definition: "{{lookup('template', 'service.j2') | from_yaml}}" - -- name: Create the Operator Route - k8s: - state: present - definition: "{{lookup('template', 'route.j2') | from_yaml}}" \ No newline at end of file diff --git a/edge/services/nginx-operator/ansible-role-files/route.j2 b/edge/services/nginx-operator/ansible-role-files/route.j2 index bb7fb817..230b5793 100644 --- a/edge/services/nginx-operator/ansible-role-files/route.j2 +++ b/edge/services/nginx-operator/ansible-role-files/route.j2 @@ -1,4 +1,4 @@ -apiVersion: v1 +apiVersion: route.openshift.io/v1 kind: Route metadata: name: nginx-route diff --git a/edge/services/nginx-operator/horizon/deployment.policy.json b/edge/services/nginx-operator/horizon/deployment.policy.json index 9309597f..d2f6fd48 100644 --- a/edge/services/nginx-operator/horizon/deployment.policy.json +++ b/edge/services/nginx-operator/horizon/deployment.policy.json @@ -15,7 +15,7 @@ "properties": [ ], "constraints": [ - "openhorizon.example == nginx-operator" + "openhorizon.example == operator" ], "userInput": [ ] diff --git a/edge/services/nginx-operator/horizon/hzn.json b/edge/services/nginx-operator/horizon/hzn.json index c12cc74e..8a018ecd 100644 --- a/edge/services/nginx-operator/horizon/hzn.json +++ b/edge/services/nginx-operator/horizon/hzn.json @@ -1,8 +1,8 @@ { "HZN_ORG_ID": "IBM", "MetadataVars": { - "DOCKER_IMAGE_BASE": "", - "SERVICE_NAME": "nginx-operator", - "SERVICE_VERSION": "1.0.0" + "DOCKER_IMAGE_BASE": "openhorizon/ibm.nginx-operator", + "SERVICE_NAME": "ibm.nginx-operator", + "SERVICE_VERSION": "1.0.1" } } \ No newline at end of file diff --git a/edge/services/nginx-operator/horizon/node.policy.json b/edge/services/nginx-operator/horizon/node.policy.json index f0b077e8..2492baf7 100644 --- a/edge/services/nginx-operator/horizon/node.policy.json +++ b/edge/services/nginx-operator/horizon/node.policy.json @@ -1,6 +1,6 @@ { "properties": [ - { "name": "openhorizon.example", "value": "nginx-operator" } + { "name": "openhorizon.example", "value": "operator" } ], "constraints": [ ] diff --git a/edge/services/nginx-operator/operator.tar.gz b/edge/services/nginx-operator/operator.tar.gz index 7fad2aba..ec27f366 100644 Binary files a/edge/services/nginx-operator/operator.tar.gz and b/edge/services/nginx-operator/operator.tar.gz differ