Helm plugin use cases

5 minute readExtensibilityDeveloper productivity

The following examples illustrate how you can use the Helm plugin in CloudBees CD/RO to:

Create a pipeline

This example shows how to add tasks to a pipeline stage to:

Prepare Google Cloud Platform

You must first create a pipeline and add tasks to the pipeline stage to prepare Google Cloud Platform (GCP).

To create a pipeline and add tasks:

  1. Create a new pipeline. For more information, refer to Create a pipeline.

  2. Add a Command task to the pipeline stage to clean up the configuration.

    1. For the pipeline stage, select Add+ to add a new pipeline stage task.

    2. Enter a task name.

    3. Click Select Task Type to define the task.

    4. From the Native list, select Command.

    5. Select Define, specify the settings, and then select OK.

      Configuration cleanup
      Figure 1. Clean up GCP configurations
  3. Add another Command task to the pipeline stage to create a new configuration.

    New configuration
    Figure 2. New configuration
  4. Add another Command task to the pipeline stage to activate the GCP service account.

    Activate service account
    Figure 3. Activate the GCP service account
  5. Add another Command task to the pipeline stage to add the config set compute command.

    Add the config set compute command
    Figure 4. Add the config set compute command
  6. Add another Command task to the pipeline stage to retrieve the cluster credentials.

    Cluster credentials
    Figure 5. Retrieve cluster credentials
  7. Add another Command task to the pipeline stage to create the namespace.

    Create namespace
    Figure 6. Create the namespace
  8. Add another Command task to the pipeline stage to configure the cluster admin permissions.

    Cluster admin permissions
    Figure 7. Configure cluster admin permissions

Prepare Helm

Once you have prepared GCP, you must add another pipeline stage to prepare Helm.

To prepare Helm:

  1. Select Add stage to add a new pipeline stage.

  2. Name the stage Preparation Helm and select OK.

  3. Add a Plugins task to the pipeline stage to initiate Helm.

    1. For the pipeline stage, select Add+.

    2. Enter a task name.

    3. Click Select Task Type to define the task.

    4. From the Plugins list, select EC-Helm, and then select the Run Custom Command plugin procedure.

    5. Select Define, configure the plugin task’s input and output parameters to initiate Helm, and then select OK.

      Initiate Helm
      Figure 8. Initiate Helm
  4. Add another Plugins task to the pipeline stage and configure the Run Custom Command plugin procedure to install the Helm plugin.

    Install the Helm plugin
    Figure 9. Install the Helm plugin
  5. Add another Plugins task to the pipeline stage and configure the Run Custom Command plugin procedure to start the Helm tiller.

    Start Helm tiller
    Figure 10. Start the Helm tiller
  6. Add another Plugins task to the pipeline stage and configure the Run Custom Command plugin procedure to add the CloudBees Helm chart repository.

    Add the Helm repository
    Figure 11. Add the CloudBees Helm chart repository
  7. Add another Plugins task to the pipeline stage and configure the Run Custom Command plugin procedure to update the repositories.

    Update
    Figure 12. Update the repositories
  8. Add another Plugins task to the pipeline stage and configure the Delete Releases plugin procedure to clean up the old release.

    Clean up the old release
    Figure 13. Clean up the old release
  9. Add another Plugins task to the pipeline stage and configure the Delete Releases plugin procedure to clean up the old Ingress controller.

    Clean up the Ingress controller
    Figure 14. Clean up the old Ingress controller

Install the Ingress controller

Once you have prepared Helm, you must add another pipeline stage to install the Ingress controller.

To install the Ingress controller:

  1. Select Add stage to add a new pipeline stage.

  2. Name the stage Installation and select OK.

  3. Add a Command task to the pipeline stage to prepare values for the Ingress controller.

    1. For the pipeline stage, select Add+ to add a new pipeline stage task.

    2. Enter a task name.

    3. Click Select Task Type to define the task.

    4. From the Native list, select Command.

    5. Select Define, specify the settings, and then select OK.

      Ingress controller preparation
      Figure 15. Prepare values for the Ingress controller
  4. Add another Plugins task to the pipeline stage to configure the Install Chart plugin procedure to install the Ingress controller.

    Install the Ingress controller
    Figure 16. Install the Ingress controller
  5. Add another Command task to the pipeline stage to retrieve the host name for the Ingress controller.

    Retrieve the host name
    Figure 17. Retrieve the Ingress controller host name
  6. Add another Plugins task to the pipeline stage and configure the Install Chart plugin procedure to install the Helm chart.

    Helm chart installation
    Figure 18. Install the Helm chart
  7. Add another Plugins task to the pipeline stage and configure the Run Custom Command plugin procedure to retrieve the release status.

    Release status
    Figure 19. Retrieve the release status

    For example:

    STDOUT: LAST DEPLOYED: Tue Jan 21 12:47:29 2020 NAMESPACE: cloudbees-core STATUS: DEPLOYED RESOURCES: ==> v1/ClusterRole NAME AGE cjoc-master-management-cloudbees-core 59s ==> v1/ClusterRoleBinding NAME AGE cjoc-role-binding-cloudbees-core 59s ==> v1/ConfigMap NAME AGE cjoc-configure-jenkins-groovy 60s jenkins-agent 60s ==> v1/Pod(related) NAME AGE cjoc-0 56s ==> v1/Role NAME AGE cjoc-agents 58s cjoc-master-management 58s ==> v1/RoleBinding NAME AGE cjoc-master-role-binding 57s cjoc-role-binding 57s ==> v1/Service NAME AGE cjoc 57s ==> v1/ServiceAccount NAME AGE cjoc 60s jenkins 60s ==> v1/StatefulSet NAME AGE cjoc 56s ==> v1beta1/Ingress NAME AGE cjoc 55s
  8. Add another Command task to the pipeline stage to retrieve the initial admin password.

    Initial admin password
    Figure 20. Retrieve the initial admin password

Finalize the pipeline

Once you have installed the Ingress {CTRL, you must add another pipeline stage to finalize the pipeline.

To finalize the pipeline:

  1. Select Add stage to add a new pipeline stage.

  2. Add a Plugins task to the pipeline stage to initiate Helm.

    1. For the pipeline stage, select Add+.

    2. Enter a task name.

    3. Click Select Task Type to define the task.

    4. From the Plugins list, select EC-Helm, and then select the Run Custom Command plugin procedure.

    5. Select Define, configure the plugin task’s input and output parameters to stop the Helm tiller, and then select OK.

      Stop the Helm tiller
      Figure 21. Stop the Helm tiller

Once configured, your new pipeline should have the following four stages configured:

Pipeline
Figure 22. Pipeline stages

OpenShift: Deploy Jenkins using Helm v3

This example demonstrates how microservices can be deployed to an OpenShift cluster. In this example, Jenkins is deployed to an OpenShift cluster.

  1. Generate a kubectl configuration for Helm.

    If you do not have kubectl config for an OpenShift cluster, you can easily generate it using the operations center command line interface. For example:

    oc login https://your-openshift-cluster-endpoint-url oc new-project helm-test-openshift cat ~/.kube/config
  2. Create an environment. For more information, refer to Create environments.

  3. Create a cluster in the environment and add a new utility resource in the environment. For more information, refer to Create an environment cluster.

    Create cluster and utility resource
    Figure 23. Create a cluster and add a utility resource
  4. Create a new application. For more information, refer to Create an application.

    New application
    Figure 24. New application
  5. Create a new microservice in the application and define the microservice details for Helm. In this example, the following microservice details are used:

    • Name: Jenkins-OpenShift

    • Definition type: Helm

    • Definition source: Helm repository

    • Repository URL: https://charts.jenkins.io

    • Repository name: jenkins

    • Release name: myrelease

    • Chart: mychart

    For more information, refer to Define microservice details for Helm.

  6. Configure the microservice process. For more information, refer to Configure a microservice process.

  7. Define the cluster environment into which the microservice is deployed. For more information, refer to Define the environment.

  8. Deploy the application. For more information, refer to Deploy the application.

    Application deployment
    Figure 25. Deploy the application
  9. Check the environment inventory. For more information, refer to Environment inventory.

    Environment inventory
    Figure 26. Environment inventory

    You can also check the deployment status via the operations center CLI:

    $ oc status In project default on server https://xx.xx.xxx.xxx svc/myrelease-jenkins-agent - 10.7.253.124:50000 svc/myrelease-jenkins - 10.7.248.179:8080 statefulset/myrelease-jenkins manages jenkins/jenkins:2.277.3-jdk11,kiwigrid/k8s-sidecar:0.1.275 created 9 minutes ago - 1 pod $ oc get pods NAME READY STATUS RESTARTS AGE myrelease-jenkins-0 2/2 Running 0 13m