Deploy a Helm chart
Deploy an application with Kustomize
Expose a service using MetalLB
Outcomes
Deploy an application from a chart.
Deploy an application from a Kustomize layer.
Configure an application to connect to the MySQL database.
If you did not previously reset your workstation and server machines, then save any work that you want to keep from earlier exercises on those machines, and reset them now.
Use the lab command to prepare your system for this exercise.
This command ensures that the cluster API is reachable and prepares the environment for the exercise.
[student@workstation ~]$ lab start compreview-package
Specifications
Deploy an application that uses a database by using a Helm chart and Kustomization files. Access the application by using a route.
Use the developer user with the developer password for this exercise.
Use a compreview-package project for all the resources.
Deploy a MySQL database by using the mysql-persistent Helm chart in the http://helm.ocp4.example.com/charts repository.
Use the latest version in the repository, and the default resource names that the chart generates.
Use Kustomize in the /home/student/DO280/labs/compreview-package/roster/ path to deploy the application.
Add a new Kustomize production overlay that adds probes to the application.
The /home/student/DO280/solutions/compreview-package/roster/overlays/production/ directory contains the solution kustomization.yaml file and the patch-roster-prod.yaml file.
Deploy the overlay.
Verify that the application creates a route, and that the application is available through the route by using the TLS/SSL protocol (HTTPS).
Add the classroom Helm repository at http://helm.ocp4.example.com/charts and examine its contents.
Use the helm repo list command to list the repositories that are configured for the student user.
[student@workstation ~]$ helm repo list
Error: no repositories to showIf the do280-repo repository is present, then continue to the next step.
Otherwise, add the repository.
[student@workstation ~]$ helm repo add \
do280-repo http://helm.ocp4.example.com/charts
"do280-repo" has been added to your repositoriesUse the helm search command to list all the charts in the repository.
[student@workstation ~]$ helm search repo
NAME CHART VERSION APP VERSION DESCRIPTION
do280-repo/mysql-persistent 0.0.2 0.0.2 This content is...
...output omitted...The mysql-persistent chart is in the classroom repository.
This chart is a copy of a chart from the https://github.com/openshift-helm-charts/charts/ repository.
Create a compreview-package project.
Log in to the cluster as the developer user with the developer password.
[student@workstation ~]$ oc login -u developer -p developer \
https://api.ocp4.example.com:6443
Login successful.
...output omitted...Create the compreview-package project.
[student@workstation ~]$ oc new-project compreview-package
Now using project "compreview-package" on server "https://api.ocp4.example.com:6443".
...output omitted...Deploy the do280-repo/mysql-persistent chart.
Use the helm install command to create a release of the do280-repo/mysql-persistent chart.
[student@workstation ~]$ helm install roster-database do280-repo/mysql-persistent
...output omitted...Use the watch command to verify that the pods are running.
Wait for the mysql-1-deploy pod to show a Completed status.
[student@workstation ~]$ watch oc get pods
NAME READY STATUS RESTARTS AGE
mysql-1-7w5bn 1/1 Running 0 150m
mysql-1-deploy 0/1 Completed 0 150mPress Ctrl+C to exit the watch command.
Examine the provided Kustomize configuration and the deployed chart, and verify that the production overlay generates a deployment, service, route, configuration map, and a secret.
Verify that the patch-roster-prod.yaml patch file applies the liveness and readiness probes to the roster deployment.
Change to the /home/student/DO280/labs/compreview-package/ directory.
[student@workstation ~]$ cd DO280/labs/compreview-package/Use the tree command to examine the directory structure.
[student@workstation compreview-package]$ tree
.
└── roster
├── base
│ ├── configmap.yaml
│ ├── kustomization.yaml
│ ├── roster-deployment.yaml
│ ├── roster-route.yaml
│ ├── roster-service.yaml
│ └── secret.yaml
└── overlays
└── production
├── kustomization.yaml
└── patch-roster-prod.yaml
4 directories, 8 filesThe Kustomization configuration includes a deployment, a route, and a service.
Examine the roster/base/roster-deployment.yaml file.
apiVersion: apps/v1 kind: Deployment metadata: ...output omitted... spec: replicas: 1 selector: matchLabels: app: roster template: ...output omitted... spec: containers: - image: registry.ocp4.example.com:8443/redhattraining/do280-roster:v1 name: do280-rosterenvFrom:- configMapRef:name: roster- secretRef:name: roster...output omitted...
The deployment does not set any configuration to access the database.
The deployment extracts environment variables from a roster configuration map and a roster secret.
Use the oc kustomize command to verify that the production overlay generates a deployment, service, route, configuration map, and a secret, and configures the liveness and readiness probes to the roster deployment.
[student@workstation compreview-package]$oc kustomize roster/overlays/production/apiVersion: v1 data: ...output omitted... kind: ConfigMap ...output omitted... --- apiVersion: v1 kind: Secret ...output omitted... --- apiVersion: v1 kind: Service ...output omitted... --- apiVersion: apps/v1 kind: Deployment metadata: ...output omitted... spec: ...output omitted... template: ...output omitted... spec: containers: ...output omitted...livenessProbe:initialDelaySeconds: 20 periodSeconds: 30 tcpSocket: port: 9090 timeoutSeconds: 3 name: roster ports: - containerPort: 9090 protocol: TCPreadinessProbe:initialDelaySeconds: 3 periodSeconds: 10 tcpSocket: port: 9090 timeoutSeconds: 3 --- apiVersion: route.openshift.io/v1 kind: Route ...output omitted...
Deploy the Kustomize files.
Use the oc apply -k command to deploy the production overlay.
[student@workstation compreview-package]$ oc apply -k roster/overlays/production/
configmap/roster created
secret/roster created
service/roster created
deployment.apps/roster created
route.route.openshift.io/roster unchangedUse the watch command to verify that the pods are running.
Wait for the roster pod to show the Running status.
[student@workstation compreview-package]$ watch oc get pods
NAME READY STATUS RESTARTS AGE
...output omitted...
roster-5d4888dc6f-4rp4n 1/1 Running 0 166mPress Ctrl+C to exit the watch command.
Use the oc get route command to obtain the application URL.
[student@workstation compreview-package]$oc get routeNAME HOST/PORT ... rosterroster-compreview-package.apps.ocp4.example.com...
Open a web browser and navigate to https://roster-compreview-package.apps.ocp4.example.com.
Use the TLS/SSL protocol (HTTPS).
The application is displayed.
Change to the home directory.
[student@workstation compreview-package]$ cd