Help Center> Cloud Container Engine> Best Practices> Cluster> Interconnecting CCE with Helm

Interconnecting CCE with Helm

Overview

Helm is a package manager for Kubernetes and manages charts. A Helm chart is a series of YAML files used to encapsulate native Kubernetes applications. When deploying an application, you can customize some metadata of the application for easy application distribution. Application releasers can use Helm to package applications, manage application dependencies and application versions, and release applications to the software repository. After using Helm, users do not need to compile complex application deployment files. They can easily search for, install, upgrade, roll back, and uninstall applications on Kubernetes.

The relationship between Helm and Kubernetes is as follows:

  • Helm <–> Kubernetes
  • Apt <–> Ubuntu
  • Yum <–> CentOS
  • Pip <–> Python

The following figure shows the solution architecture:

Helm can help application orchestration for Kubernetes:

  • Manages, edits, and updates a large number of Kubernetes configuration files.
  • Deploys a complex Kubernetes application that contains a large number of configuration files.
  • Shares and reuses Kubernetes configurations and applications.
  • Supports multiple environments with parameter-based configuration templates.
  • Manages the release of applications, including rolling back the application, finding differences (using the diff command), and viewing the release history.
  • Controls phases in a deployment cycle.
  • Tests and verifies the released version.

Prerequisites

The created cluster in CCE has been connected to kubectl. For details, see Connecting to a CCE Cluster Using kubectl or web-terminal.

Installing Helm

Install Helm on CCE nodes.

You can download Helm of a proper version from here. This section uses Helm v3.3.0 as an example.

  1. Download the Helm client on the CCE node.

    wget https://get.helm.sh/helm-v3.3.0-linux-amd64.tar.gz

  2. Decompress the Helm package.

    tar -xzvf helm-v3.3.0-linux-amd64.tar.gz

    Information similar to the following is displayed:

  3. Copy Helm to the system path, for example, /usr/local/bin/helm.

    mv linux-amd64/helm /usr/local/bin/helm

  4. View the Helm version information.

    helm version
    version.BuildInfo{Version:"v3.3.0", GitCommit:"e29ce2a54e96cd02ccfce88bee4f58bb6e2a28b6", GitTreeState:"clean", GoVersion:"go1.13.4"}

  5. You do not need to install Tiller for Helm v3.0.0.

    In Helm v3.0.0 and later versions, tiller is no longer required. Therefore, you do not need to install it. Helm reads ~/.kube/config by default to connect to Kubernetes.

Installing the Helm Chart

If the charts provided by CCE do not meet requirements, download a chart and install it.

You can obtain the required chart in the stable directory on the website, download the chart, and upload it to the node.
  1. Download and decompress the obtained chart. Generally, the chart is in ZIP format.

    unzip chart.zip

  2. Install the Helm chart.

    helm install aerospike/ --generate-name

  3. After the installation is complete, run the helm list command to check the status of the chart releases.

Cloud-based Practice

This practice describes how to modify the files in the chart package using the created resources. The chart package consists of the chart.yaml, README.md, values.yaml, .helmianore, and templates folders. You can modify the chart package by modifying the parameters in the values.yaml folder according to the deployment.yaml, statefulset.yaml, and service.yaml files in the templates folder.

  1. Modify the image parameters in the values.yaml file based on the existing images and versions in the account.
  2. Change the values of the following service parameters in the values.yaml file:

    • Change the value of key in kubernetes.io/elb.class to union, indicating that a shared load balancer is used.
    • Change the value of loadBalancerIP to the address of the specified ELB.

FAQs

  • The following error message is displayed after the helm version command is run:
    Client:
    &version.Version{SemVer:"v3.3.0",
    GitCommit:"012cb0ac1a1b2f888144ef5a67b8dab6c2d45be6", GitTreeState:"clean"}
    E0718 11:46:10.132102    7023 portforward.go:332] an error occurred
    forwarding 41458 -> 44134: error forwarding port 44134 to pod
    d566b78f997eea6c4b1c0322b34ce8052c6c2001e8edff243647748464cd7919, uid : unable
    to do port forwarding: socat not found.
    Error: cannot connect to Tiller

    The preceding information is displayed because the socat is not installed. Run the following command to install the socat:

    yum install socat -y

  • The following error message is displayed after the helm version command is run (the socat has been installed):
    test@local:~/k8s/helm/test$ helm version
    Client: &version.Version{SemVer:"v3.3.0", GitCommit:"021cb0ac1a1b2f888144ef5a67b8dab6c2d45be6", GitTreeState:"clean"}
    Error: cannot connect to Tiller

    The Helm chart reads the configuration certificate from the .Kube/config file to communicate with Kubernetes. The preceding error information is displayed because the kubectl configuration is incorrect. In this case, reconnect to kubectl. For details, see Connecting to a CCE Cluster Using kubectl or web-terminal.

  • The storage fails to be created after the cloud storage is connected.

    This issue may be caused by the annotation field in the created PVC. Change the chart name and install the chart again.

  • If kubectl is not properly configured, the following error message is displayed after the helm install command is run:
    [root@prometheus-57046 ~]# helm install prometheus/ --generate-name
    WARNING: This chart is deprecated
    Error: Kubernetes cluster unreachable: Get "http://localhost:8080/version?timeout=32s": dial tcp [::1]:8080: connect: connection refused

    To rectify this fault, configure kubeconfig on the node. For details, see Connecting to a CCE Cluster Using kubectl or web-terminal.