Deploying a Helm Artifact

Helm is an open source package manager for Kubernetes that provides the ability to share, package, and deploy the software built for Kubernetes. The Oracle Cloud Infrastructure (OCI) DevOps service supports the deployment of Helm charts to Kubernetes Engine (OKE) cluster. You can also run Helm commands that are specified as an inline artifact and added to the Helm stage for deployment.

The Helm chart deployment occurs only when the Helm chart is deployed for the first time, or if updates are detected in the artifact or Helm stage parameters. This is automatically validated before running the deployment. However, to deploy the Helm chart irrespective of the updates to the artifact or any other Helm stage parameter, during the deployment run, you must set the ENFORCE_HELM_DEPLOYMENT parameter to true. This parameter works at both stage and pipeline level. When the parameter is set for a specific stage, then its applicable only for that stage. If the parameter is set for a pipeline or deployment argument, then its applicable to all the stages in the pipeline. However, if the parameter is set for the pipeline or deployment argument and the stage override argument, then the pipeline parameter or deployment argument take precedence over the stage override argument. The parameter is applicable to all the stages in the pipeline.

For a specific Helm deployment stage, you have the option to use OCI_DEVOPS_DEPLOY_USE_CREATE_NAMESPACE_FLAG as a stage parameter override. The parameter can be set to true or false to control the --create-namespace flag when using the helm upgrade command for deploying Helm charts. This parameter operates at the stage level, offering enhanced granularity in the deployment configurations. For more information, see Configuring Parameters.

Before you begin, you must have a deployment pipeline and create a Kubernetes Engine cluster. You can deploy to both public and private OKE clusters.

For creating dynamic groups and policies for deployment pipelines, see Deployment Pipeline Policies. For more details, see DevOps IAM Policies.

The Helm charts must be located in the OCI Container Registry repository for deployment. See Adding a Helm Chart. For running Helm commands, you must specify the Helm commands as an inline artifact. See Helm Command Specification.

Helm charts contain templates of Kubernetes YAML manifest files and a values.yaml file to supply the default template values. The values.yaml is a generic file that's located in the OCI Artifact Registry. You must create a reference to this file. See Adding an Artifact Registry Artifact.

Note

The deployment doesn't support parameter substitution in the Helm chart tarball. However, it's supported in the values.yaml file.

For accessing DevOps using the Oracle Cloud Console, REST API, and CLI, see Accessing DevOps.

    1. Open the navigation menu and click Developer Services. Under DevOps, click Projects.
    2. Select a project, and a deployment pipeline.
    3. To add a stage to the pipeline, click the + icon and select Add stage.
    4. For stage type, select Install Helm chart to Kubernetes cluster or run Helm commands on Kubernetes cluster, and then click Next.
    5. Enter a name and description for the stage. Adding a description is optional.
    6. For Environment, select an existing cluster environment.
    7. Select the Purpose of creating the Helm stage. Options are:

      • Install or upgrade Helm chart on Kubernetes cluster
      • Run Helm commands on Kubernetes cluster
    8. If you select the option to run Helm commands then, select the Helm command specification artifact, and add the stage. For more information, see Helm Command Specification.
    9. If you select the option to install or upgrade Helm chart then, enter a Release name. Example: helm-release.

      A release refers to the running instance of the Helm chart with specific configuration. A single chart can be installed many times into the same cluster, and create different releases. The release name can be parameterized for example, helm-release-${version}.

      Release names must follow the RFC 1123 standard. They can only contain lowercase alphanumeric characters or '-', must start and end with an alphanumeric character.

    10. To uninstall the Helm release from the OKE cluster when this stage is deleted from the pipeline, select the Uninstall the Helm release on stage deletion checkbox.
    11. Click Select Artifact to select the Helm chart for deployment.
    12. (Optional) Click Select Artifact to select the values.yaml file containing the values that 's passed to the helm chart. The file contains default parameters that you can override.
    13. (Optional) To override the default environment namespace, enter value for Override Kubernetes namespace. The value can be parameterized for example, helm-${namespace}.

      Namespace values must follow the RFC 1123 standard. They can only contain lowercase alphanumeric characters or '-', must start and end with an alphanumeric character.

    14. (Optional) Enter a timeout value for deployment in seconds.
    15. (Optional) Specify Helm upgrade options to upgrade the Helm chart version or change the configuration of your Helm release. See Helm Upgrade.

      You can set values and string values for the Helm command during the Helm chart deployment.

      Specify the maximum number of upgrades per deployment. By default, the value is set to 10. Enter zero if you don't want to set any limit for the upgrades.

    16. To automatically roll back to the last successful release version if the validation fails, select Yes. For more information, see Rolling Back a Deployment.
    17. (Optional) To add tags to the pipeline, click Show tagging options. Tagging is a metadata system that lets you organize and track the resources in the tenancy.

      If you have permissions to create a resource, you also have permissions to add free-form tags to it.

      To add a defined tag, you must have permissions to use the tag namespace.

      For more information, see Resource Tags.

    18. To add the stage to the pipeline, click Add.

      If you have selected the checkbox to uninstall the helm release during the stage deletion, then click Confirm in the Uninstall Helm Release Warning dialog box. When the Helm release is uninstalled, a work request is created to uninstall the release, the status of which is tracked in the Deployment section on the Deployment Pipelines page.

      A stage preview provides a snapshot of the configuration.

    Add more stages sequentially or in parallel to the pipeline, as needed. To deploy the build output to the target environment, run the deployment pipeline.

    During the deployment, you can cancel the deployment of this stage that results in rollback to the previous state. If you cancel the deployment when a Helm release upgrade is in progress, then the upgrade is canceled and the release is rolled back to the previous state.

    To automatically trigger a deployment from the build pipeline, you can add a Trigger Deployment stage to the build pipeline.

  • To create an OKE Helm stage for the pipeline, run the create-oke-helm-chart-stage command:

    oci devops deploy-stage create-oke-helm-chart-stage

    Required parameters:

    • --helm-chart-artifact-id
    • --oke-cluster-environment-id
    • --pipeline-id
    • --stage-predecessor-collection
    • --release-name

    To add Purpose field to the Helm stage, run the update-oke-helm-chart-stage command:

    oci devops deploy-stage update-oke-helm-chart-stage --helm-command-artifact-ids --purpose

    To uninstall Helm stage, run the create-oke-helm-chart-stage command:

    oci devops deploy-stage create-oke-helm-chart-stage --is-uninstall-on-stage-delete

    To get all the commands for deploy-stage:

    oci devops deploy-stage -h

    To get help for the create-oke-helm-chart-stage command:

    oci devops deploy-stage create-oke-helm-chart-stage -h
  • To create a Kubernetes cluster stage for the pipeline, use the CreateDeployStage operation. For the deployStageType attribute, specify the value as OKE_HELM_CHART_DEPLOYMENT.