You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -14,7 +14,7 @@ Follow the steps on this page to create your first ansible operator that deploys
14
14
- Open the Docker **Preferences** dialog
15
15
- Uncheck **Securely store Docker logins in macOS keychain**
16
16
17
-
3. Install [operator-sdk](https://github.com/operator-framework/operator-sdk/tree/v0.19.x#prerequisites) and all its prerequisites. This example was created using version `0.19`, and has not been tested on any other versions.
17
+
3. Install [operator-sdk](https://v1-27-x.sdk.operatorframework.io/docs/installation/) and all its prerequisites.
18
18
19
19
4. Install the Kubenetes CLI [kubectl](https://kubernetes.io/docs/tasks/tools/install-kubectl/)
20
20
@@ -57,111 +57,87 @@ Follow the steps on this page to create your first ansible operator that deploys
57
57
brew install git jq
58
58
```
59
59
60
-
## <a id=build-publish-your-op></a> Building and Publishing Your Own Operator Example Edge Service
60
+
## <a id=build-publish-your-op></a> Building and Publishing Your Own Nginx Ansible Operator Example Edge Service
61
61
62
-
In order to deploy a containerized edge service to an edge cluster, a software developer first has to build a Kubernetes Operator that deploys the containerized edge service in a Kubernetes cluster. There are several options when writing a Kubernetes operator. This example will guide through creating an ansible operator. The following steps were originally performed on the cluster host machine.
63
-
64
-
1. Create a new operator application and generate a default directory layout based on the input name, and move into the created default operator directory:
62
+
In order to deploy a containerized edge service to an edge cluster, a software developer first has to build a Kubernetes Operator that deploys the containerized edge service in a Kubernetes cluster. There are several options when writing a Kubernetes operator. This example will guide through creating an ansible operator. These steps are based on the [Ansible Operator Tutorial](https://v1-27-x.sdk.operatorframework.io/docs/building-operators/ansible/tutorial/) on the official `operator-sdk` website. If you have never created an operator before, I highly suggest skimming over the information there as well. The following steps were originally performed on the cluster host machine.
65
63
64
+
1. Creating yourself a base working directory, and grab the Makefile int his repo:
66
65
```bash
67
-
operator-sdk new my-operator --type=ansible --api-version=my.operator.com/v1alpha1 --kind=MyOperator
**Note:** If you are following these steps to create an operator that will deploy your own service, you should modify the names used above, **not** modify things manually in the generated files.
72
-
73
-
The above command will give you an empty ansible operator. At the very least you will need to define a `deployment`, `service`, and a set of tasks to deploy your service. If you look in the [ansible-role-files](https://github.com/open-horizon/examples/tree/master/edge/services/hello-operator/ansible-role-files) directory you can see these three files and how they are used to deploy the `nginxinc/nginx-unprivileged` image, and how they expose the port `8080`. There are several methods forconfiguring cluster network traffic, which you can read aboutin the [OCP traffic overview documentation](https://docs.openshift.com/container-platform/4.6/networking/configuring_ingress_cluster_traffic/overview-traffic.html). For this service we've going to create a service of type `NodePort` and `expose` our service with a route.
74
-
75
-
2. Obtain the `deployment`, `service`, and task file and move them into the `my-operator` roles directory with the following commands:
76
-
71
+
2. Export the following environment variables to customize the `operator-sdk` init:
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:
86
+
The above Makefile command will:
87
+
- Create a new `my-nginx-ansible-operator` project and generate the entire operator structure and empty `roles/mynginxansibleoperator`
88
+
- Create a `MyNginxAnsibleOperator` API
89
+
- Added `services` to the operator RBAC
90
+
- Changed the default namespace to the value set with `OPERATOR_NAMESPACE`
91
+
- Added `size: 1` to the operators custom resource
91
92
93
+
4. Gather the necessary nginx deployment, service, and task files for the operator to deploy the nginx service:
92
94
```bash
93
-
echo "- apiGroups:
94
-
- route.openshift.io
95
-
resources:
96
-
- routes
97
-
- routes/custom-host
98
-
verbs:
99
-
- get
100
-
- list
101
-
- watch
102
-
- patch
103
-
- update
104
-
- create
105
-
- delete" >> deploy/role.yaml
95
+
make nginx-files
106
96
```
107
97
108
-
5. Build the operator image (use ppc64le for power arch):
6. In the `deploy/operator.yaml` file, replace `"REPLACE_IMAGE"` with the operator image name you built and pushed in the previous step (use ppc64le for power arch):
116
-
117
-
```text
118
-
image: "<docker-hub-id>/my.operator_amd64:1.0.0"
103
+
6. Deploy the operator locally:
119
104
```
120
-
121
-
7. Apply the required resources to run the operator
0 commit comments