Push and pull charts with Helm cm-push

更新时间:
复制 MD 格式

The Helm cm-push plug-in is a Helm extension that lets you push and pull charts. A chart is a package containing the resource definitions required to run an application, tool, or service in a Kubernetes cluster. To push a chart to a remote chart repository, you must first install the plug-in locally using the helm plugin install command. You can then use the helm push command to push charts.

Important

To use the Helm cm-push plug-in to push and pull charts over HTTP, you must first submit a ticket to add your client IP address to the internet whitelist.

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. On 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, enter a Namespace name, set Automatically Create Repository and Default Configurations for Automatically Created Repositories, and then click Confirm.

  2. Create a chart repository.

    Note

    If you enable Automatically Create Repository for the namespace, you do not need to create a chart repository in the console. You can push the chart directly from the Helm CLI.

    The chart repository in an Enterprise Edition instance must be in the format <instance-name>-chart.<Region ID>.cr.aliyuncs.com/<namespace>/<chart-repository-name>. The chart version is in the format <chart-name>-<version-number>. To access the repository over a VPC, use the format <instance-name>-chart-vpc.<Region ID>.cr.aliyuncs.com/<namespace>/<chart-repository-name>.

    1. On the Overview page of the Enterprise Edition instance, go to the Component Settings section and turn on the switch for Charts.

    2. On the management page of the Enterprise Edition instance, choose Helm Chart > Chart Repositories.

    3. On the Chart repository page, click Create chart repository.

    4. In the Create Helm chart dialog box, select a Namespace, set the Chart repository name and Type, and then click Confirm.

  3. Configure an access credential.

    The following steps show how to set a permanent password:

    1. On the management page of the Enterprise Edition instance, choose Instances > Access Credentials.

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

    3. In the Set Password dialog box, enter a Password, enter it again in the Confirm Password field, and then click Confirm.

  4. Configure an access control policy.

    Enable access from the Internet or a specified VPC so that you can push Helm charts. This topic uses access control over the Internet as an example. For more information about how to configure access control over a VPC, see Configure access control for a VPC.

    1. On the management page of the Enterprise Edition instance, choose Helm Chart > 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, enter the IP address range allowed to access the instance and a description, and then click Confirm.

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

    After you turn on the Pull from Anonymous Users switch, you can pull charts from public chart repositories without logging in.

    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. On the Overview page, go to the Instance Settings section on the right and turn on the Pull from Anonymous Users switch.

    6. In the Tips dialog box, click Confirm.

Step 2: Install and configure the Helm client

  1. Download Helm.

    Note

    This topic uses Helm 3.7 or later to push and pull charts. You can run the helm version command to check the client version. This topic uses Helm 3.10.0 as an example.

  2. Run the following commands to decompress the Helm package and move the executable file to a directory in your PATH.

    # Decompress the package.
    tar -zxvf helm-v3.10.0-rc.1-linux-amd64.tar.gz
    # Move the executable file to a specified directory.
    mv linux-amd64/helm /usr/local/bin/helm    
  3. To push a chart directory to a Container Registry repository, use the helm cm-push command. This command is provided by the Helm cm-push plug-in. Run the following command to install the plug-in.

    Note

    Before you install the Helm plug-in, run the yum install git command to install Git.

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

Step 3: Push and pull charts

  1. Run the following command to add a remote chart repository and assign it a local alias. This command maps the alias to the URL of a chart repository in a specific namespace.

    helm repo add <local-repository-alias> https://test9-7-chart****.cn-hangzhou.cr.aliyuncs.com/ns1/repo1 --username <username> --password <password>
  2. Run the following commands to push a chart.

    # Create a chart locally.
    helm create <chart-name>
     
    # Push the chart directory.
    helm cm-push <chart-name> <local-repository-alias>

    On the Chart repository page, click the name of the target chart repository, and then click Versions. On the Versions page, you can view the newly pushed chart.

  3. Run the following commands to install and pull a chart.

    # Update the local chart index from the remote chart repository.
    helm repo update
     
    # Pull the chart.
    helm fetch <local-repository-alias>/<chart-name> --version <chart-version>
    # Alternatively, install the chart directly.
    helm install -f values.yaml <local-repository-alias>/<chart-name> --version <chart-version>