Bookmark this page

Guided Exercise: Helm Charts

Deploy and update an application from a chart that is stored in a catalog.

Outcomes

  • Deploy an application and its dependencies from a Helm chart.

  • Customize the deployment, including scaling and using a custom image.

As the student user on the workstation machine, use the lab command to prepare your system for this exercise.

This command ensures that the cluster API is reachable.

[student@workstation ~]$ lab start packaged-charts

Instructions

  1. Add the classroom Helm repository at the following URL and examine its contents.

    http://helm.ocp4.example.com/charts

    1. 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 show

      If 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 repositories
    2. Use the helm search command to list all the chart versions in the repository.

      [student@workstation ~]$ helm search repo --versions
      NAME                     CHART VERSION  APP VERSION  ...
      do280-repo/etherpad      0.0.7          latest       ...
      do280-repo/etherpad      0.0.6          latest       ...
      ...output omitted...

      The etherpad chart has the 0.0.7 and 0.0.6 versions. This chart is a copy of a chart from the https://github.com/redhat-cop/helm-charts repository.

  2. Install the 0.0.6 version of the etherpad chart to a new packaged-charts-development project, with the example-app release name.

    Use the registry.ocp4.example.com:8443/etherpad/etherpad:1.8.18 image in the offline classroom registry. Expose the application at the https://development-etherpad.apps.ocp4.example.com URL.

    1. Examine the values of the chart.

      [student@workstation ~]$ helm show values do280-repo/etherpad --version 0.0.6
      # Default values for etherpad.
      replicaCount: 1
      
      defaultTitle: "Labs Etherpad"
      defaultText: "Assign yourself a user and share your ideas!"
      
      image:
        repository: etherpad
        name:
        tag:
        pullPolicy: IfNotPresent
      ...output omitted...
      route:
        enabled: true
        host: null
        targetPort: http
      ...output omitted...
      resources: {}
      ...output omitted...

      You can configure the image, the replica count, and other values. By default, the chart creates a route. You can customize the route with the route.host key.

      With the default configuration, the chart uses the docker.io/etherpad/etherpad:latest image. The classroom environment is designed for offline use. Use the registry.ocp4.example.com:8443/etherpad/etherpad:1.8.18 image from the local registry instead.

    2. Create a values.yaml file with the following content:

      image:
        repository: registry.ocp4.example.com:8443/etherpad
        name: etherpad
        tag: 1.8.18
      route:
        host: development-etherpad.apps.ocp4.example.com
    3. 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
      ...output omitted...
    4. Create a packaged-charts-development project.

      [student@workstation ~]$ oc new-project packaged-charts-development
      Now using project "packaged-charts-development" on server ...
      ...output omitted...
    5. Install the etherpad chart to the packaged-charts-development project. Use the values.yaml file that you created in a previous step. Use example-app as the release name.

      [student@workstation ~]$ helm install example-app do280-repo/etherpad \
        -f values.yaml --version 0.0.6
      NAME: example-app
      LAST DEPLOYED: Mon Jun  5 06:31:26 2023
      NAMESPACE: packaged-charts-development
      STATUS: deployed
      REVISION: 1
      TEST SUITE: None
    6. Get the route to verify that you customized the route correctly.

      [student@workstation ~]$ oc get route
      NAME                   HOST/PORT                                    ...
      example-app-etherpad   development-etherpad.apps.ocp4.example.com   ...
    7. Open a web browser and navigate to https://development-etherpad.apps.ocp4.example.com. The application welcome page appears.

  3. Upgrade a Helm chart by installing the 0.0.7 version of the chart.

    1. Use the helm list command to verify the installed version.

      [student@workstation ~]$ helm list
      NAME         NAMESPACE                    REVISION ... STATUS    CHART
      example-app  packaged-charts-development  1        ... deployed  etherpad-0.0.6
    2. Use the helm search command to verify that the repository contains a later version.

      [student@workstation ~]$ helm search repo --versions
      NAME                     CHART VERSION  APP VERSION  ...
      do280-repo/etherpad      0.0.7          latest       ...
      do280-repo/etherpad      0.0.6          latest       ...
      ...output omitted...
    3. Use the helm upgrade command to upgrade to the latest version of the chart.

      [student@workstation ~]$ helm upgrade example-app do280-repo/etherpad \
        -f values.yaml --version 0.0.7
      Release "example-app" has been upgraded. Happy Helming!
      NAME: example-app
      LAST DEPLOYED: Mon Jun  5 06:41:00 2023
      NAMESPACE: packaged-charts-development
      STATUS: deployed
      REVISION: 2
      TEST SUITE: None
    4. Use the helm list command to verify the installed version.

      [student@workstation ~]$ helm list
      NAME         NAMESPACE                    REVISION ... STATUS    CHART
      example-app  packaged-charts-development  2        ... deployed  etherpad-0.0.7
    5. Reload the application welcome page in the web browser.

      The updates in the new version of the chart do not affect the deployment in this exercise. When you reload the application, the browser displays the same application welcome page.

  4. Create a second deployment of the chart to a new packaged-charts-production project, with the example-app release name.

    Expose the application at the https://etherpad.apps.ocp4.example.com URL, by customizing the route.host key.

    1. Create a packaged-charts-production project.

      [student@workstation ~]$ oc new-project packaged-charts-production
      Now using project "packaged-charts-production" on server ...
      ...output omitted...
    2. Edit the values.yaml file to configure the host route to etherpad.apps.ocp4.example.com.

      image:
        repository: registry.ocp4.example.com:8443/etherpad
        name: etherpad
        tag: 1.8.18
      route:
        host: etherpad.apps.ocp4.example.com
    3. Install the 0.0.7 version of the etherpad chart to the packaged-review-production project.

      Use the values.yaml file that you edited in a previous step. Use production as the release name.

      [student@workstation ~]$ helm install example-app do280-repo/etherpad \
        -f values.yaml --version 0.0.7
      ...output omitted...
    4. Verify the deployment by opening a web browser and navigating to the application URL. https://etherpad.apps.ocp4.example.com

      This URL corresponds to the host that you specified in the values.yaml file. The application welcome page appears in the production URL.

  5. Reconfigure the production deployment to sustain heavier use. Change the number of replicas to 3.

    1. Verify that the application has a single pod.

      [student@workstation ~]$ oc get pods
      NAME                                    READY   STATUS    RESTARTS   AGE
      example-app-etherpad-6b85b94975-qfpqm   1/1     Running   0          12s
    2. Edit the values.yaml file. Add a replicaCount key with the 3 value.

      image:
        repository: registry.ocp4.example.com:8443/etherpad
        name: etherpad
        tag: 1.8.18
      route:
        host: etherpad.apps.ocp4.example.com
      replicaCount: 3
    3. Use the helm upgrade command to update the parameters.

      [student@workstation ~]$ helm upgrade example-app do280-repo/etherpad \
        -f values.yaml
      ...output omitted...
    4. Verify that the application has three pods.

      [student@workstation ~]$ oc get pods
      NAME                                    READY   STATUS    RESTARTS   AGE
      example-app-etherpad-6b85b94975-h9qgz   1/1     Running   0          13s
      example-app-etherpad-6b85b94975-lbr8h   1/1     Running   0          13s
      example-app-etherpad-6b85b94975-qfpqm   1/1     Running   0          94s
    5. Reload the application welcome page in the web browser.

      The deployment continues working after adding replicas.

  6. Remove the values.yaml file.

    [student@workstation ~]$ rm values.yaml

Finish

On the workstation machine, use the lab command to complete this exercise. This step is important to ensure that resources from previous exercises do not impact upcoming exercises.

[student@workstation ~]$ lab finish packaged-charts

Revision: do280-4.14-08d11e1