|
| 1 | +# Install Serverless and Cloud Events on an existing cluster using GitOps |
| 2 | + |
| 3 | +<!--- cSpell:ignore gitid kubeseal cntk --> |
| 4 | + |
| 5 | +!!!Note |
| 6 | + This is a work in progress, come back for updates. |
| 7 | + |
| 8 | +## Overview |
| 9 | +This guide will illustrate the steps to install Serverless and Cloud Events in an existing cluster using ArgoCD provided by Red Hat OpenShift GitOps operator. |
| 10 | + |
| 11 | +Additionally it shows the steps to configure Red Hat Openshift Pipelines operator based on Tekton to send cloud events and steps to configure a "slack-notification" app to receive those events. |
| 12 | + |
| 13 | +## Install Serverless and Cloud Eventing |
| 14 | + |
| 15 | +### Pre-requisites |
| 16 | + |
| 17 | +The following is required before proceeding to the next section. |
| 18 | + |
| 19 | +- Provision an OpenShift cluster. |
| 20 | +- Login to the cluster via the oc cli. |
| 21 | + |
| 22 | +### Installation Steps |
| 23 | + |
| 24 | +1. Fork the [multi-tenancy-gitops](https://github.com/cloud-native-toolkit/multi-tenancy-gitops) repository and clone your fork. |
| 25 | + |
| 26 | + ```shell |
| 27 | + git clone git@github.com:{gitid}/multi-tenancy-gitops.git |
| 28 | + ``` |
| 29 | + |
| 30 | +1. Change to the `kustomize` branch of your fork. |
| 31 | + |
| 32 | + ```shell |
| 33 | + cd multi-tenancy-gitops |
| 34 | + git checkout kustomize |
| 35 | + ``` |
| 36 | + |
| 37 | +1. Install the Red Hat OpenShift GitOps operator. |
| 38 | + - For Openshift 4.6 |
| 39 | + ```shell |
| 40 | + oc apply -f setup/ocp46/ |
| 41 | + ``` |
| 42 | + - For Openshift 4.7 |
| 43 | + ```shell |
| 44 | + oc apply -f setup/ocp47/ |
| 45 | + ``` |
| 46 | + |
| 47 | +1. Update the files to reference your forked repository. Run the `set-git-source.sh` script that will replace `cloud-native-toolkit` Github Org references with your {gitid}. |
| 48 | + |
| 49 | + ```shell |
| 50 | + export GIT_USER={gitid} |
| 51 | + ./scripts/set-git-source.sh |
| 52 | + ``` |
| 53 | +  |
| 54 | + |
| 55 | +1. Push the changes to your forked repository. |
| 56 | + |
| 57 | + ```shell |
| 58 | + git add . |
| 59 | + git commit -m "push repo gitid changes" |
| 60 | + git push |
| 61 | + ``` |
| 62 | +  |
| 63 | + |
| 64 | +1. Their are different deployment options provided in folders in the repository. In this guide we will use the default `single-server` deployment. The other options are located in the `others` folder. |
| 65 | + |
| 66 | + ```text |
| 67 | + ./0-bootstrap |
| 68 | + └── argocd |
| 69 | + ├── bootstrap.yaml |
| 70 | + ├── others |
| 71 | + │ ├── 1-shared-cluster |
| 72 | + │ ├── 2-isolated-cluster |
| 73 | + │ └── 3-multi-cluster |
| 74 | + └── single-cluster |
| 75 | + ``` |
| 76 | + |
| 77 | +1. If you choose to use a different deployment option edit the `0-bootstrap/argocd/bootstrap.yaml` and modify the `spec.source.path` and update the `metadata.name` accordingly. For example to use the `1-shared-cluster` change the path to `0-bootstrap/argocd/others/1-shared-cluster`. |
| 78 | + |
| 79 | + ```text |
| 80 | + apiVersion: argoproj.io/v1alpha1 |
| 81 | + kind: Application |
| 82 | + metadata: |
| 83 | + name: bootstrap-1-shared-cluster |
| 84 | + namespace: openshift-gitops |
| 85 | + spec: |
| 86 | + destination: |
| 87 | + namespace: openshift-gitops |
| 88 | + server: https://kubernetes.default.svc |
| 89 | + project: default |
| 90 | + source: |
| 91 | + path: 0-bootstrap/argocd/others/1-shared-cluster |
| 92 | + repoURL: https://github.com/lsteck/multi-tenancy-gitops.git |
| 93 | + targetRevision: kustomize |
| 94 | + syncPolicy: |
| 95 | + automated: |
| 96 | + prune: true |
| 97 | + selfHeal: true |
| 98 | + ``` |
| 99 | + |
| 100 | +1. In this guide we will use the unchanged `0-bootstrap/argocd/bootstrap.yaml` which uses the `single-cluster` deployment. |
| 101 | + |
| 102 | + |
| 103 | + ```text |
| 104 | + apiVersion: argoproj.io/v1alpha1 |
| 105 | + kind: Application |
| 106 | + metadata: |
| 107 | + name: bootstrap-single-cluster |
| 108 | + namespace: openshift-gitops |
| 109 | + spec: |
| 110 | + destination: |
| 111 | + namespace: openshift-gitops |
| 112 | + server: https://kubernetes.default.svc |
| 113 | + project: default |
| 114 | + source: |
| 115 | + path: 0-bootstrap/argocd/single-cluster |
| 116 | + repoURL: https://github.com/lsteck/multi-tenancy-gitops.git |
| 117 | + targetRevision: kustomize |
| 118 | + syncPolicy: |
| 119 | + automated: |
| 120 | + prune: true |
| 121 | + selfHeal: true |
| 122 | + ``` |
| 123 | + |
| 124 | +1. Under the cluster's folder there are `1-infra`, `2-services` and `3-apps` folders which define what infrastructure, services and app resources are to be deployed respectively. |
| 125 | +
|
| 126 | + ```text |
| 127 | + ./0-bootstrap |
| 128 | + └── argocd |
| 129 | + ├── bootstrap.yaml |
| 130 | + ├── others |
| 131 | + └── single-cluster |
| 132 | + ├── 1-infra |
| 133 | + ├── 2-services |
| 134 | + ├── 3-apps |
| 135 | + ├── bootstrap.yaml |
| 136 | + └── kustomization.yaml |
| 137 | + ``` |
| 138 | +
|
| 139 | +1. Open the `kustomization.yaml` file under the `1-infra` folder |
| 140 | +
|
| 141 | + ```text |
| 142 | + ./0-bootstrap |
| 143 | + └── argocd |
| 144 | + ├── bootstrap.yaml |
| 145 | + ├── others |
| 146 | + └── single-cluster |
| 147 | + └── 1-infra |
| 148 | + ├── 1-infra.yaml |
| 149 | + ├── argocd |
| 150 | + └── kustomization.yaml |
| 151 | + ``` |
| 152 | +
|
| 153 | +1. Uncomment the lines under the `# Openshift Serverless/Eventing` section to deploy those resources. |
| 154 | +
|
| 155 | + ```text |
| 156 | + # Openshift Serverless/Eventing |
| 157 | + - argocd/namespace-openshift-serverless.yaml |
| 158 | + - argocd/namespace-knative-serving.yaml |
| 159 | + - argocd/namespace-knative-eventing.yaml |
| 160 | + ``` |
| 161 | + |
| 162 | +1. Open the `kustomization.yaml` file under the `2-services` folder |
| 163 | +
|
| 164 | + ```text |
| 165 | + ./0-bootstrap |
| 166 | + └── argocd |
| 167 | + ├── bootstrap.yaml |
| 168 | + ├── others |
| 169 | + └── single-cluster |
| 170 | + ├── 1-infra |
| 171 | + └── 2-services |
| 172 | + ├── 1-infra.yaml |
| 173 | + ├── argocd |
| 174 | + └── kustomization.yaml |
| 175 | + ``` |
| 176 | +
|
| 177 | +1. Uncomment the lines under the `# Openshift Serverless/Eventing` section to deploy those resources. |
| 178 | +
|
| 179 | + ```text |
| 180 | + # Openshift Serverless/Eventing |
| 181 | + - argocd/operators/openshift-serverless.yaml |
| 182 | + - argocd/instances/knative-eventing-instance.yaml |
| 183 | + ``` |
| 184 | +
|
| 185 | +1. Installing the **Serverless and Eventing** doesn't require any resources under the `3-apps` folder so the `kustomization.yaml` in that folder doesn't need to be changed. |
| 186 | +
|
| 187 | +1. Push the changes to your forked repository. |
| 188 | +
|
| 189 | + ```shell |
| 190 | + git add . |
| 191 | + git commit -m "push serverless and eventing" |
| 192 | + git push |
| 193 | + ``` |
| 194 | +
|
| 195 | +1. Create the bootstrap ArgoCD application. |
| 196 | +
|
| 197 | + ```shell |
| 198 | + oc apply -f 0-bootstrap/argocd/bootstrap.yaml -n openshift-gitops |
| 199 | + ``` |
| 200 | +
|
| 201 | +1. From the OpenShift console launch ArgoCD by clicking the `ArgoCD` link from the Applications (9 squares) menu |
| 202 | +
|
| 203 | +  |
| 204 | +
|
| 205 | +1. The ArcoCD user id is `admin` and the password can be found in the `argocd-cluster-cluster` secret in the `openshift-gitops` project namespace. You can extract the secret with the command |
| 206 | + ```shell |
| 207 | + oc extract secret/argocd-cluster-cluster --to=- -n openshift-gitopsoc extract secret/argocd-cluster-cluster --to=- -n openshift-gitops |
| 208 | + ``` |
| 209 | +
|
| 210 | +1. On the ArgoCD UI you can see the newly created bootstrap application. |
| 211 | +
|
| 212 | +  |
| 213 | +
|
| 214 | +1. After several minutes you will see all the other ArgoCD applications with a status `Healthy` and `Synced`. The status will progress from `Missing`, `OutOfSync`, `Syncing`. If you see a status of `Sync failed` there were errors. |
| 215 | +
|
| 216 | +  |
| 217 | +
|
| 218 | +1. You can check that the Red Hat OpenShift Serverless operator that provides serverless and eventing capabilities has been installed from the **Installed Operators** page on the console. |
| 219 | +
|
| 220 | +  |
| 221 | +
|
| 222 | +## Install Slack Notification app and configure Tekton to emit Cloud Events |
| 223 | +
|
| 224 | +!!!Note |
| 225 | + Both installation steps could be performed at the same time. They were broken out in this guide to illustrate how you could install **Serverless and Eventing** without installing the **Slack Notification** app. |
| 226 | +
|
| 227 | +### Pre-requisites |
| 228 | +
|
| 229 | +The following are required before proceeding. |
| 230 | +
|
| 231 | +- Compete the previous section [Install Serverless and Cloud Eventing](#install-serverless-and-cloud-eventing) |
| 232 | +- Create a [Slack Incoming Webhook](https://api.slack.com/messaging/webhooks). |
| 233 | +
|
| 234 | +### Installation Steps |
| 235 | +
|
| 236 | +1. Open the `kustomization.yaml` file under the `1-infra` folder |
| 237 | +
|
| 238 | + ```text |
| 239 | + ./0-bootstrap |
| 240 | + └── argocd |
| 241 | + ├── bootstrap.yaml |
| 242 | + ├── others |
| 243 | + └── single-cluster |
| 244 | + └── 1-infra |
| 245 | + ├── 1-infra.yaml |
| 246 | + ├── argocd |
| 247 | + └── kustomization.yaml |
| 248 | + ``` |
| 249 | +
|
| 250 | +1. Uncomment the lines under the `# Slack Notifications` section to deploy those resources. |
| 251 | +
|
| 252 | + ```text |
| 253 | + # Slack Notifications |
| 254 | + - argocd/namespace-slack-notifications.yaml |
| 255 | + ``` |
| 256 | +
|
| 257 | +1. Push the changes to your forked repository. |
| 258 | +
|
| 259 | + ```shell |
| 260 | + git add . |
| 261 | + git commit -m "push slack notifications namespace" |
| 262 | + git push |
| 263 | + ``` |
| 264 | +
|
| 265 | +1. After a few minutes you should see see an ArgoCD `namespace-slack-notifications` app. This app creates the `slack-notifications` project namespace where we will deploy the slack notification app. |
| 266 | +  |
| 267 | +
|
| 268 | +1. Before we deploy the app we need to create a secret to store the slack incoming webhook you created as a pre-requisite. This secret needs to be in the `slack-notifications` project namespace. You can generate an encrypted secret containing the slack notification webhook using the Sealed Secret Operator or you can manually create the secret as follows **NOTE:** replace `<webhook-url>` with your slack webhook url . |
| 269 | +
|
| 270 | + ```shell |
| 271 | + WEBHOOK=<webhook-url> |
| 272 | +
|
| 273 | + oc project slack-notifications |
| 274 | +
|
| 275 | + oc create secret generic slack-secret \ |
| 276 | + --from-literal=SLACK_URL=${WEBHOOK} |
| 277 | +
|
| 278 | + ``` |
| 279 | +
|
| 280 | +1. Installing the **Slack Notification app** doesn't require any resources under the `2-services` folder so the `kustomization.yaml` in that folder doesn't need to be changed. |
| 281 | +
|
| 282 | +1. Open the `kustomization.yaml` file under the `3-apps` folder |
| 283 | +
|
| 284 | + ```text |
| 285 | + ./0-bootstrap |
| 286 | + └── argocd |
| 287 | + ├── bootstrap.yaml |
| 288 | + ├── others |
| 289 | + └── single-cluster |
| 290 | + ├── 1-infra |
| 291 | + ├── 2-services |
| 292 | + └── 3-apps |
| 293 | + ├── 3-apps.yaml |
| 294 | + ├── argocd |
| 295 | + └── kustomization.yaml |
| 296 | + ``` |
| 297 | +
|
| 298 | +1. Uncomment the lines under the `# Slack Notifications` section to deploy those resources. |
| 299 | +
|
| 300 | + ```text |
| 301 | + # Slack Notifications |
| 302 | + - argocd/slack-notifications/slack-notifications.yaml |
| 303 | + - argocd/shared/config/openshift-pipelines/configmap/openshift-pipelines-config.yaml |
| 304 | + ``` |
| 305 | +
|
| 306 | +1. If you changed the slack-secret name or key you need to update the secret name and key value in the `slack-notification.yaml` |
| 307 | +
|
| 308 | + 1. Open `slack-notifications.yaml` |
| 309 | + ```text |
| 310 | + ./0-bootstrap |
| 311 | + └── argocd |
| 312 | + └── single-cluster |
| 313 | + └── 3-apps |
| 314 | + └── argocd |
| 315 | + └── slack-notifications |
| 316 | + └── slack-notifications.yaml |
| 317 | + ``` |
| 318 | +
|
| 319 | + 1. Modify the name and key to match your secret name and the key name. |
| 320 | + ```text |
| 321 | + secret: |
| 322 | + # provide name of the secret that contains slack url |
| 323 | + name: slack-secret |
| 324 | + # provide key of the secret that contains slack url |
| 325 | + key: SLACK_URL |
| 326 | + ``` |
| 327 | +
|
| 328 | +1. Push the changes to your forked repository. |
| 329 | +
|
| 330 | + ```shell |
| 331 | + git add . |
| 332 | + git commit -m "push slack notifications app" |
| 333 | + git push |
| 334 | + ``` |
| 335 | +
|
| 336 | +
|
| 337 | +1. After a few minutes you will see an `apps-slack-notifications` ArgoCD app and a `openshift-pipelines-config` ArgoCD app. |
| 338 | +  |
| 339 | +
|
| 340 | +
|
| 341 | +1. On the OpenShift Console you can see the slack notifications app deployment in the `slack-notifications` project namespace. |
| 342 | +  |
| 343 | +
|
| 344 | +
|
| 345 | +Now when you run Pipelines you will receive Slack Notifications. |
0 commit comments