|
| 1 | +:_mod-docs-content-type: ASSEMBLY |
| 2 | +[id="cloud-experts-deploying-application-lab-overview"] |
| 3 | += Tutorial: Deploying an application |
| 4 | +include::_attributes/attributes-openshift-dedicated.adoc[] |
| 5 | +:context: cloud-experts-deploying-application-intro |
| 6 | + |
| 7 | +toc::[] |
| 8 | + |
| 9 | +//rosaworkshop.io content metadata |
| 10 | +//Brought into ROSA product docs 22-JAN-2024 |
| 11 | + |
| 12 | +== Lab overview |
| 13 | + |
| 14 | +=== Lab resources |
| 15 | + |
| 16 | +* link:https://github.com/openshift-cs/ostoy[Source code for the OSToy application] |
| 17 | +* link:https://quay.io/ostoylab/ostoy-frontend[OSToy front-end container image] |
| 18 | +* link:https://quay.io/ostoylab/ostoy-microservice[OSToy microservice container image] |
| 19 | +* Deployment Definition YAML files: |
| 20 | ++ |
| 21 | +.`ostoy-frontend-deployment.yaml` |
| 22 | ++ |
| 23 | +[source,yaml] |
| 24 | +---- |
| 25 | +apiVersion: v1 |
| 26 | +kind: PersistentVolumeClaim |
| 27 | +metadata: |
| 28 | + name: ostoy-pvc |
| 29 | +spec: |
| 30 | + accessModes: |
| 31 | + - ReadWriteOnce |
| 32 | + resources: |
| 33 | + requests: |
| 34 | + storage: 1Gi |
| 35 | +--- |
| 36 | +apiVersion: apps/v1 |
| 37 | +kind: Deployment |
| 38 | +metadata: |
| 39 | + name: ostoy-frontend |
| 40 | + labels: |
| 41 | + app: ostoy |
| 42 | +spec: |
| 43 | + selector: |
| 44 | + matchLabels: |
| 45 | + app: ostoy-frontend |
| 46 | + strategy: |
| 47 | + type: Recreate |
| 48 | + replicas: 1 |
| 49 | + template: |
| 50 | + metadata: |
| 51 | + labels: |
| 52 | + app: ostoy-frontend |
| 53 | + spec: |
| 54 | + # Uncomment to use with ACK portion of the workshop |
| 55 | + # If you chose a different service account name please replace it. |
| 56 | + # serviceAccount: ostoy-sa |
| 57 | + containers: |
| 58 | + - name: ostoy-frontend |
| 59 | + securityContext: |
| 60 | + allowPrivilegeEscalation: false |
| 61 | + runAsNonRoot: true |
| 62 | + seccompProfile: |
| 63 | + type: RuntimeDefault |
| 64 | + capabilities: |
| 65 | + drop: |
| 66 | + - ALL |
| 67 | + image: quay.io/ostoylab/ostoy-frontend:1.6.0 |
| 68 | + imagePullPolicy: IfNotPresent |
| 69 | + ports: |
| 70 | + - name: ostoy-port |
| 71 | + containerPort: 8080 |
| 72 | + resources: |
| 73 | + requests: |
| 74 | + memory: "256Mi" |
| 75 | + cpu: "100m" |
| 76 | + limits: |
| 77 | + memory: "512Mi" |
| 78 | + cpu: "200m" |
| 79 | + volumeMounts: |
| 80 | + - name: configvol |
| 81 | + mountPath: /var/config |
| 82 | + - name: secretvol |
| 83 | + mountPath: /var/secret |
| 84 | + - name: datavol |
| 85 | + mountPath: /var/demo_files |
| 86 | + livenessProbe: |
| 87 | + httpGet: |
| 88 | + path: /health |
| 89 | + port: 8080 |
| 90 | + initialDelaySeconds: 10 |
| 91 | + periodSeconds: 5 |
| 92 | + env: |
| 93 | + - name: ENV_TOY_SECRET |
| 94 | + valueFrom: |
| 95 | + secretKeyRef: |
| 96 | + name: ostoy-secret-env |
| 97 | + key: ENV_TOY_SECRET |
| 98 | + - name: MICROSERVICE_NAME |
| 99 | + value: OSTOY_MICROSERVICE_SVC |
| 100 | + - name: NAMESPACE |
| 101 | + valueFrom: |
| 102 | + fieldRef: |
| 103 | + fieldPath: metadata.namespace |
| 104 | + volumes: |
| 105 | + - name: configvol |
| 106 | + configMap: |
| 107 | + name: ostoy-configmap-files |
| 108 | + - name: secretvol |
| 109 | + secret: |
| 110 | + defaultMode: 420 |
| 111 | + secretName: ostoy-secret |
| 112 | + - name: datavol |
| 113 | + persistentVolumeClaim: |
| 114 | + claimName: ostoy-pvc |
| 115 | +--- |
| 116 | +apiVersion: v1 |
| 117 | +kind: Service |
| 118 | +metadata: |
| 119 | + name: ostoy-frontend-svc |
| 120 | + labels: |
| 121 | + app: ostoy-frontend |
| 122 | +spec: |
| 123 | + type: ClusterIP |
| 124 | + ports: |
| 125 | + - port: 8080 |
| 126 | + targetPort: ostoy-port |
| 127 | + protocol: TCP |
| 128 | + name: ostoy |
| 129 | + selector: |
| 130 | + app: ostoy-frontend |
| 131 | +--- |
| 132 | +apiVersion: route.openshift.io/v1 |
| 133 | +kind: Route |
| 134 | +metadata: |
| 135 | + name: ostoy-route |
| 136 | +spec: |
| 137 | + to: |
| 138 | + kind: Service |
| 139 | + name: ostoy-frontend-svc |
| 140 | +--- |
| 141 | +apiVersion: v1 |
| 142 | +kind: Secret |
| 143 | +metadata: |
| 144 | + name: ostoy-secret-env |
| 145 | +type: Opaque |
| 146 | +data: |
| 147 | + ENV_TOY_SECRET: VGhpcyBpcyBhIHRlc3Q= |
| 148 | +--- |
| 149 | +kind: ConfigMap |
| 150 | +apiVersion: v1 |
| 151 | +metadata: |
| 152 | + name: ostoy-configmap-files |
| 153 | +data: |
| 154 | + config.json: '{ "default": "123" }' |
| 155 | +--- |
| 156 | +apiVersion: v1 |
| 157 | +kind: Secret |
| 158 | +metadata: |
| 159 | + name: ostoy-secret |
| 160 | +data: |
| 161 | + secret.txt: VVNFUk5BTUU9bXlfdXNlcgpQQVNTV09SRD1AT3RCbCVYQXAhIzYzMlk1RndDQE1UUWsKU01UUD1sb2NhbGhvc3QKU01UUF9QT1JUPTI1 |
| 162 | +type: Opaque |
| 163 | +---- |
| 164 | ++ |
| 165 | +.`ostoy-microservice-deployment.yaml` |
| 166 | ++ |
| 167 | +[source,yaml] |
| 168 | +---- |
| 169 | +apiVersion: apps/v1 |
| 170 | +kind: Deployment |
| 171 | +metadata: |
| 172 | + name: ostoy-microservice |
| 173 | + labels: |
| 174 | + app: ostoy |
| 175 | +spec: |
| 176 | + selector: |
| 177 | + matchLabels: |
| 178 | + app: ostoy-microservice |
| 179 | + replicas: 1 |
| 180 | + template: |
| 181 | + metadata: |
| 182 | + labels: |
| 183 | + app: ostoy-microservice |
| 184 | + spec: |
| 185 | + containers: |
| 186 | + - name: ostoy-microservice |
| 187 | + securityContext: |
| 188 | + allowPrivilegeEscalation: false |
| 189 | + runAsNonRoot: true |
| 190 | + seccompProfile: |
| 191 | + type: RuntimeDefault |
| 192 | + capabilities: |
| 193 | + drop: |
| 194 | + - ALL |
| 195 | + image: quay.io/ostoylab/ostoy-microservice:1.5.0 |
| 196 | + imagePullPolicy: IfNotPresent |
| 197 | + ports: |
| 198 | + - containerPort: 8080 |
| 199 | + protocol: TCP |
| 200 | + resources: |
| 201 | + requests: |
| 202 | + memory: "128Mi" |
| 203 | + cpu: "50m" |
| 204 | + limits: |
| 205 | + memory: "256Mi" |
| 206 | + cpu: "100m" |
| 207 | +--- |
| 208 | +apiVersion: v1 |
| 209 | +kind: Service |
| 210 | +metadata: |
| 211 | + name: ostoy-microservice-svc |
| 212 | + labels: |
| 213 | + app: ostoy-microservice |
| 214 | +spec: |
| 215 | + type: ClusterIP |
| 216 | + ports: |
| 217 | + - port: 8080 |
| 218 | + targetPort: 8080 |
| 219 | + protocol: TCP |
| 220 | + selector: |
| 221 | + app: ostoy-microservice |
| 222 | +---- |
| 223 | +* S3 bucket manifest for ACK S3 |
| 224 | ++ |
| 225 | +.`s3-bucket.yaml` |
| 226 | ++ |
| 227 | +[source,yaml] |
| 228 | +---- |
| 229 | +apiVersion: s3.services.k8s.aws/v1alpha1 |
| 230 | +kind: Bucket |
| 231 | +metadata: |
| 232 | + name: ostoy-bucket |
| 233 | + namespace: ostoy |
| 234 | +spec: |
| 235 | + name: ostoy-bucket |
| 236 | +---- |
| 237 | + |
| 238 | +[NOTE] |
| 239 | +==== |
| 240 | +To simplify deployment of the OSToy application, all of the objects required in the above deployment manifests are grouped together. For a typical enterprise deployment, a separate manifest file for each Kubernetes object is recommended. |
| 241 | +==== |
| 242 | + |
| 243 | +=== About the OSToy application |
| 244 | + |
| 245 | +OSToy is a simple Node.js application that you will deploy to a ROSA cluster to help explore the functionality of Kubernetes. This application has a user interface where you can: |
| 246 | + |
| 247 | +* Write messages to the log (stdout / stderr). |
| 248 | +* Intentionally crash the application to view self-healing. |
| 249 | +* Toggle a liveness probe and monitor OpenShift behavior. |
| 250 | +* Read config maps, secrets, and env variables. |
| 251 | +* If connected to shared storage, read and write files. |
| 252 | +* Check network connectivity, intra-cluster DNS, and intra-communication with the included microservice. |
| 253 | +* Increase the load to view automatic scaling of the pods to handle the load using the Horizontal Pod Autoscaler. |
| 254 | +* Optional: Connect to an AWS S3 bucket to read and write objects. |
| 255 | + |
| 256 | +=== OSToy Application Diagram |
| 257 | + |
| 258 | +image::ostoy-arch.png[OSToy architecture diagram] |
| 259 | + |
| 260 | +=== Understanding the OSToy UI |
| 261 | + |
| 262 | +image::ostoy-homepage.png[Preview of the OSToy homepage] |
| 263 | + |
| 264 | +1. Shows the pod name that served your browser the page. |
| 265 | +2. *Home:* The main page of the application where you can perform some of the functions listed which we will explore. |
| 266 | +3. *Persistent Storage:* Allows you to write data to the persistent volume bound to this application. |
| 267 | +4. *Config Maps:* Shows the contents of configmaps available to the application and the key:value pairs. |
| 268 | +5. *Secrets:* Shows the contents of secrets available to the application and the key:value pairs. |
| 269 | +6. *ENV Variables:* Shows the environment variables available to the application. |
| 270 | +7. *Networking:* Tools to illustrate networking within the application. |
| 271 | +8. *Pod Auto Scaling:* Tool to increase the load of the pods and test the HPA. |
| 272 | +9. *ACK S3:* Optional: Integrate with AWS S3 to read and write objects to a bucket. |
| 273 | ++ |
| 274 | +[NOTE] |
| 275 | +==== |
| 276 | +In order see the "ACK S3" section of OSToy, you must complete the ACK section of this workshop. If you decide not to complete that section, the OSToy application will still function. |
| 277 | +==== |
| 278 | ++ |
| 279 | +10. *About:* Displays more information about the application. |
0 commit comments