All Products
Search
Document Center

Container Registry:Use Helm 2 to push and pull charts

Last Updated:Dec 27, 2023

Helm is a package manager for Kubernetes. Helm uses a packaging format called charts. After you create or update a chart, you can push the chart to a chart repository. This way, others can pull the chart from the chart repository for use.

Step 1: Configure an Enterprise Edition instance

  1. Create a namespace.

    1. Log on to the Container Registry console.

    2. In the left-side navigation pane, click Instances.

    3. On the Instances page, click the Enterprise Edition instance that you want to manage.

    4. In the left-side navigation pane of the management page of the Enterprise Edition instance, choose Helm Chart > Namespace.

    5. On the Namespace page, click Create Namespace.

    6. In the Create Namespace dialog box, configure the Namespace, Automatically Create Repository, and Default Repository Type parameters, and then click Confirm.

  2. Create a chart repository.

    Note

    When Automatically Create Repository is enabled for the namespace, you can use Helm to push charts to a chart repository without the need to create the chart repository in advance in the Container Registry console.

    The chart repository of the Enterprise Edition instance is in the following format: <Instance name>-chart.<Region ID>.cr.aliyuncs.com/<Namespace>/<Chart repository name>. The version of the chart repository is <Chart name>-<Version number>. If you want to access the chart repository over a virtual private cloud (VPC), the chart repository must be in the following format: <Instance name>-chart-vpc.<Region ID>.cr.aliyuncs.com/<Namespace>/<Chart repository name>.

    1. On the Overview page of the Enterprise Edition instance, turn on Charts in the Component Settings section.

    2. In the left-side navigation pane of the management page of the Enterprise Edition instance, choose Helm Chart > Repositories.

    3. On the Repositories page, click Create Repositories.

    4. In the Create Helm Chart dialog box, configure the Namespace, Repository Name, and Type parameters, and then click Confirm.

  3. Configure an access credential.

    Set a password or a temporary token that is used to access Helm charts. In this example, a password is configured as the access credential.

    1. In the left-side navigation pane of the management page of the Enterprise Edition instance, choose Instances > Access Credential.

    2. On the Access Credential page, click Set Password.

    3. In the Set Password dialog box, configure the Password and Confirm Password parameters, and then click Confirm.

  4. Configure an access control policy.

    Enable Internet access or VPC access to ensure that Helm charts can be pushed to repositories. In this example, Internet access is enabled. For information about how to enable VPC access, see Configure a VPC ACL.

    1. In the left-side navigation pane of the management page of the Enterprise Edition instance, choose Access Control.

    2. On the Access Control page, click the Internet tab.

    3. On the Internet tab, turn on Enable Access over Internet and click Add Internet Whitelist.

    4. In the Add Internet Whitelist dialog box, specify the CIDR blocks that are allowed to access the Enterprise Edition instance and the notes, and then click Confirm.

  5. (Optional) Turn on Pull from Anonymous Users.

    After you turn on Pull from Anonymous Users, you can access the public chart repository anonymously without logging on.

    1. Log on to the Container Registry console.

    2. In the top navigation bar, select a region.

    3. In the left-side navigation pane, click Instances.

    4. On the Instances page, click the Enterprise Edition instance that you want to manage.

    5. In the Instance Settings section on the right side of the Overview page of the Enterprise Edition instance, turn on Pull from Anonymous Users.

    6. In the Tips dialog box, click OK.

Step 2: Install and configure the Helm client

  1. Download Helm of the required version from the official website.

    Note

    Make sure that the version of the client is V2.X. You can run the helm version -c command to check the version. In this example, the version of the client is V2.14.2.

  2. Run the following commands to decompress the installation package of Helm and store the extracted files to the specified directory:

    # Decompress the installation package. 
    tar -zxvf helm-v2.14.2-linux-amd64.tgz
    # Store the extracted files in the specified directory. 
    mv linux-amd64/helm /usr/local/bin/helm                    
  3. Install the Helm plug-in provided by Alibaba Cloud.

    Note

    Before you install the Helm plug-in, make sure that Git is installed.

    If your server resides outside the Chinese mainland or can access GitHub, run the following command to install the Helm plug-in.

    helm plugin install https://github.com/AliyunContainerService/helm-acr
  4. Initialize Helm.

    • If Helm is installed on a node of a Container Service for Kubernetes (ACK) cluster, the tiller has been initialized by default. You only need to initialize the client. If you do not want to access Google charts at the same time, run the following command to initialize Helm:

      helm init --client-only --skip-refresh
    • If Helm is installed on a node of a self-managed Kubernetes cluster and you do not want to access Google charts, run the following command:

      helm init --skip-refresh

Step 3: Push and pull charts

  1. Run the following commands to configure on-premises repository mapping:

    You must specify an on-premises repository and map it to a chart repository in a namespace in Container Registry.

    export HELM_REPO_USERNAME='<Account in the access credential of the Enterprise Edition instance>';
    export HELM_REPO_PASSWORD='<Password in the access credential of the Enterprise Edition instance>';
    helm repo add <Name of the on-premises repository> acr://<Instance name>-chart.<Region ID>.cr.aliyuncs.com/<Namespace>/<Chart repository> --username ${HELM_REPO_USERNAME} --password ${HELM_REPO_PASSWORD}            

    配置本地仓库映射

  2. Push a chart.

    1. Run the following commands to push the chart:

      # Create an on-premises chart. 
      helm create <Chart name>
      
      # Push the chart directory. 
      helm push <Chart name> <Name of the on-premises repository>
      
      # Push the compressed chart package. 
      helm cm-push <Chart name>-<Chart version>.tgz <Name of the on-premises repository>            

      推送chart

    In the left-side navigation pane of the Container Registry Enterprise Edition instance, choose Helm Chart > Repositories. On the Repositories page, click the name of the chart repository that you want to view and then click Versions. On the Versions page, you can view the new chart that you pushed.

  3. Run the following command to pull the chart:

    # Update the on-premises chart index from the chart repository in Container Registry. 
    helm repo update
    
    # Pull a chart. 
    helm fetch <Name of the on-premises repository>/<Chart name> --version <Chart version>
    
    # Directly install a chart. 
    helm install -f values.yaml <Name of the on-premises repository>/<Chart name> --version <Chart version>