Helm is a kubernetes-based package manager. It is to Kubernetes what yum is to centos, PIP is to Python, and NPM is to javascript

How does the introduction of HELM help manage clusters?

  1. Easier deployment of infrastructure such asgitlab.postgres.prometheus.grafana
  2. Make it easier to deploy your own application, configure Chart for internal projects, and use ithelmCombined with CI, deploying applications in K8S is as simple as a one-line command

Of course, helm’s greater role lies in the separation of responsibilities between operations and developers.

It is not practical for developers to write K8S resource profiles

  1. Not all developers know k8S, or very little, and it is difficult to write resource configuration deployment files without knowing K8S
  2. The main function of development is still in the business

So helm goes out every now and then, writes configuration files, and develops them with few parameters

This article focuses on how to install the HELM and how to deploy basic services and businesses using the HELM

  • Installation and use of helm
  • Series of articles: Personal server operation and maintenance guide

If you are new, there will be a discount to buy the machine in Ali Cloud, you can click the link to buy. You can follow my notes server operation guide to get started on maintaining the server and setting up the application.

  • Invite you together 86 yuan/year to buy cloud server

introduce

  • Chart: name of a series of K8S resource sets. It contains a series of TEMPLATES and parameters of K8S resource configuration files, which can be flexibly configured
  • releaseChart /relase: When a Chart is deployed, a release is generated. Chart /relase is similar to image/ Container in docker
  • repo: Chart warehouse, where there are many charts to choose from, such as officialhelm/charts

Create a chart using helm Create to see the directory structure of a simple chart

Refer to the next section for information on how to install the HELM

Create a chart
$ helm create todo
Creating todo

$ cd todo

Yaml and values.yaml are the main files
# --dirsfirst Prints the folder name first$tree -- Bass Exercises. └─ Charts ├─ │ ├─ tests │ ├─test- connection. Yaml │ ├ ─ ─ the TXT │ ├ ─ ─ _helpers. TPL │ ├ ─ ─ deployment. The yaml │ ├ ─ ─ ingress. The yaml │ └ ─ ─ service. The yaml ├ ─ ─ Chart.yaml ├ ─ values. Yaml 3 directories, 8 filesCopy the code

Look at the two main file directories

  • templates/This is a configuration file template written by o&M. The example is resource configuration for the simplest application, but complex applications can also have PVC, role, service-acount, and so on
  • values.yaml: This is an optional parameter for the developer, but most of the parameters are built in

Deploy the underlying services using HELM

For real examples, see other chapters in my series

  • Deploy Redis using helm
  • Deploy Postgres using helm
  • Deploy drone using helm

Here are some general steps for deploying basic services. Suppose we need to deploy Redis

Helm V3 is used here, and the syntax may differ slightly from v2

01 Find the relevant Chart

Use the Helm Search Hub

$helm search hub redis URL CHART VERSION APP VERSION 9.5.0 DESCRIPTION https://hub.helm.sh/charts/bitnami/redis 5.0.5 Opensource, advanced key-value store. It is of...
https://hub.helm.sh/charts/hephy/redis                  v2.4.0                          A Redis database foruse inside a Kubernetes cl... https://hub.helm.sh/charts/incubator/redis-cache 0.5.0 4.0.12 - alpine pure Ain-memory redis cache, using statefulset...
Copy the code

02 Select Chart and follow up the official document of Chart

We selected the chart stable/redis.

Track official documents, set related parameters and store as values-production.yaml

# Production configuration
$ helm install stable/redis --values values-production.yaml
Copy the code

The REPO is added if necessary: Helm repo Add

# helm repo add stable https://kubernetes-charts.storage.googleapis.com/

List all repOs
$ helm repo list
NAME            URL
stable          https://kubernetes-charts.storage.googleapis.com/
apphub          https://apphub.aliyuncs.com
jetstack        https://charts.jetstack.io
Copy the code

03 Verifying the deployment status

This depends on the resources that need to be deployed, but is generally divided into Services, PODS, and PVC

Install the helm

Install the HELM by referring to the official document

Helm at helm V2 is divided into two parts: the helm Client (command line tool) and the helm Server (Helm Server). The server is also called Tiller. When Tiller is installed, a Pod is deployed in the cluster.

Helm has now released V3, which has dropped Tiller compared to V2, and for more specific changes refer to the Helm V3 FAQ

Installing the Client (Helm Client)

Helm Client needs to be installed on any server where you can access the K8S cluster, like Kubectl, but generally you need to install it in two places

  1. Master node in the K8S cluster
  2. On your own PC/ MAC

On helm V3, you only need to install the Helm Client

Install on a MAC

$ brew install kubernetes-helm
Copy the code

Install on Linux

$ curl -LO https://git.io/get_helm.sh
$ chmod 700 get_helm.sh
$ ./get_helm.sh
Copy the code

Install rsync according to the source package, it is recommended (after all, there may be network problems using the above two solutions), as for how to use rsync see the following installation steps

Using script installation can cause network problems in the country, so you need to install it on the proxy node and move it to the target location using rsync or SCP

For example, install the helm in 2.14.3. For the latest version of the helm, see Helm/Helm Releases.

You can choose to install the 3.0+ version, the latest version is Helm V3.0.0-RC.1 (2019/11/01)

#Download the software package for MAC
#-l: traces redirected links
#-o: save to the local PC
#-s: Indicates an error
$The curl - SLO https://get.helm.sh/helm-v2.14.3-darwin-amd64.tar.gz

#Download the software packages applicable to CentOS
$The curl - SLO https://get.helm.sh/helm-v2.14.3-linux-amd64.tar.gz

#If you have network problems, download from the proxy node and rsync to the target node. If not, skip this step
$Rsync - avhzP proxy: / root/helm - v2.14.3 - Linux - amd64. Tar. Gz.

#If you're on a MAC
$The tar - ZXVF helm - v2.14.3 - Darwin - amd64. Tar. Gz

#If it's on centos
$Tar - ZXVF helm - v2.14.3 - Linux - amd64. Tar. Gz

#Go to the corresponding directory and go to the /bin directory
$ mv linux-amd64/helm /usr/local/bin/helm
Copy the code

Installing tiller (Helm Server)

If Helm V3 is used, tiller is not installed

01 Downloading an Image

IO/Kubernetes-Helm/Tiller: V2.14.3 on GCR. IO, this means that the domestic network needs to download to the proxy node first and then move to the target location. Refer to previous chapters for specific steps

  • Install the active node. – Prepare an offline image

02 installation Tiller

When the HELM command line tool is installed, install tiller using Helm Init. A POD will be deployed on the K8S when tiller is installed.

$ helm init
Creating /root/.helm
Creating /root/.helm/repository
Creating /root/.helm/repository/cache
Creating /root/.helm/repository/local
Creating /root/.helm/plugins
Creating /root/.helm/starters
Creating /root/.helm/cache/archive
Creating /root/.helm/repository/repositories.yaml
Adding stable repo with URL: https://kubernetes-charts.storage.googleapis.com
Adding localRepo with URL: http://127.0.0.1:8879/charts$HELM_HOME has been configured at /root/.helm.

Tiller (the Helm server-side component) has been installed into your Kubernetes Cluster.

Please note: by default, Tiller is deployed with an insecure 'allow unauthenticated users' policy.
To prevent this, run `helm init` with the --tiller-tls-verify flag.
For more information on securing your installation see: https://docs.helm.sh/using_helm/#securing-your-helm-installation
Copy the code

Verify the Pod status as prompted

Check whether tiller is running
$ kubectl get pods --all-namespaces

See helm and Tiller versions
$ helm version
Client: &version.Version{SemVer:"v2.14.3", GitCommit:"0e7f3b6637f7af8fcfddb3d2941fcc7cbebb0085", GitTreeState:"clean"}
Server: &version.Version{SemVer:"v2.14.3", GitCommit:"0e7f3b6637f7af8fcfddb3d2941fcc7cbebb0085", GitTreeState:"clean"}
Copy the code

More articles

  • Personal Server o&M guide
  • Deploy your first application with K8S: Pod, Deployment, and Service
  • Use K8S to configure the domain name for your application: Ingress

I am Shanyue, a programmer who dreams of running and mountain climbing. I will regularly share full stack articles in my personal public account. Welcome to exchange