helm installation and use-deploy k8s application through helm

helm installation

Helm equivalent yum guarantee linux environment management tool. Helm is a command line client tool in k8s, helm is the client of tiller, tiller is a daemon process that receives helm requests, helm hands the requests to tiller, tiler interacts with apiserver, apiserver is responsible for completing the creation, we Which chart to use needs to be downloaded locally, based on the local deployment instance of this chart, this deployment instance is called release.

1. What is a chart?

A helm package, for example, when we deploy nginx, we need deployment yaml and service yaml. These two manifest files are a helm package. In k8s, these yaml manifest files are called chart charts.

2.values.yaml file

The values.yaml file assigns values ​​to the files in the template, which can realize our custom installation. If it is a chart developer, you need to customize the template, if it is a chart user, you only need to modify the values.yaml.

3.helm can be understood as follows

Helm packs kubernetes resources into a chart, makes and completes the dependencies between each chart and the chart itself, and uses the chart warehouse to realize external distribution, and helm can also realize configurable external release, and complete configurable release through the values.yaml file. If the chart version is updated, helm automatically supports the rollover update mechanism, and can also be rolled back with one click, but it is not suitable for use in a production environment, unless it has the ability to define self-made charts. Helm belongs to a project of kubernetes, download address:

https://github.com/helm/helm/releases

Find this checksum, after decompression, press the following to decompress

Helm official website:

https://helm.sh/

Official helm chart site:

https://hub.kubeapps.com/

4. Repository, release, chart relationship

repository: A repository for storing charts, providing those yaml manifest files needed to deploy k8s applications

release: an instance of a specific chart deployed on the target cluster

chart--->Assign values ​​through the values.yaml file-->Generate release instance

Helm is also developed in go language

5. Install the helm client and operate on the master node of k8s

Download the software package, the address of the Baidu network disk where the software package is located is as follows:

Link: https://pan.baidu.com/s/15Qlcng6--QwCxoZjt1TGeA Extraction code: c70b

tar -xzvf helm-v2.13.1-linux-amd64.tar.gz 

cd linux-amd64

cp helm /usr/local/bin 

helmet version

An error is reported, showing that there is no tiller server

Install the server-side tiller of helm

Install helm server tiller

The reference link of rbac.yaml is as follows:

https://github.com/helm/helm/blob/master/docs/rbac.md

cat rbac.yaml

apiVersion: v1kind: ServiceAccountmetadata:  name: tiller  namespace: kube-system---apiVersion: rbac.authorization.k8s.io/v1beta1kind: ClusterRoleBindingmetadata:  name: tillerroleRef:  apiGroup: rbac.authorization.k8s.io  kind: ClusterRole  name: cluster-adminsubjects:  - kind: ServiceAccount    name: tiller    namespace: kube-system


Update yaml file

kubectl apply -f rbac.yaml


Transfer the tiller image compression package to each node node of k8s, and then manually decompress the image with docker load -i to the local. The address of the Baidu network disk where the image is located is as follows:

Link: https://pan.baidu.com/s/1Z_yuava-8W65mn5tla7cFw Extraction code: bd2n

Unzip the image on the node node of k8s

docker load -i tiler_2_13_1.tar.gz


cat tiller.yaml

---apiVersion: apps/v1kind: Deploymentmetadata:  creationTimestamp: null  labels:    app: helm    name: tiller  name: tiller-deploy  namespace: kube-systemspec:  selector:    matchLabels:     app: helm     name: tiller  replicas: 1  strategy: {}  template:    metadata:      creationTimestamp: null      labels:        app: helm        name: tiller    spec:      automountServiceAccountToken: true      serviceAccount:  tiller      containers:      - env:        - name: TILLER_NAMESPACE          value: kube-system        - name: TILLER_HISTORY_MAX          value: "0"        image: gcr.io/kubernetes-helm/tiller:v2.13.1        imagePullPolicy: IfNotPresent        livenessProbe:          httpGet:            path: /liveness            port: 44135          initialDelaySeconds: 1          timeoutSeconds: 1        name: tiller        ports:        - containerPort: 44134          name: tiller        - containerPort: 44135          name: http        readinessProbe:          httpGet:            path: /readiness            port: 44135          initialDelaySeconds: 1          timeoutSeconds: 1        resources: {}status: {}
---apiVersion: v1kind: Servicemetadata:  creationTimestamp: null  labels:    app: helm    name: tiller  name: tiller-deploy  namespace: kube-systemspec:  ports:  - name: tiller    port: 44134    targetPort: tiller  selector:    app: helm    name: tiller  type: ClusterIPstatus:  loadBalancer: {}
...

Update yaml file

kubectl apply -f tiller.yaml


Verify that tiller is deployed successfully:

kubectl get pods -n kube-system is
displayed as follows, indicating that the deployment is successful

tiller-deploy-7bd89687c8-tv7cn    1/1     Running   0          2d8h


Verify the helm version

helmet version

It can be seen as follows:

Client: &version.Version{SemVer:"v2.13.1", GitCommit:"618447cbf203d147601b4b9bd7f8c37a5d39fbb4", GitTreeState:"clean"}Server: &version.Version{SemVer:"v2.13.1", GitCommit:"618447cbf203d147601b4b9bd7f8c37a5d39fbb4", GitTreeState:"clean"}

The above results can see that the helm client and server versions are the same, and they are all installed.

Common commands for helm are as follows

(1) Related to release

Upgrade a version

helm upgrade

helm upgrade [RELEASE] [CHART] [flags]

Roll back a version

helm rollback

helm rollback [flags] [RELEASE] [REVISION]

Create a release instance

helm install

Delete a release

helm delete

View history

helm  history

(2) Related to chart

View the detailed information of the chart

helm inspect

Download the chart

helm  fetch

Pack the chart

helm  package


Guess you like

Origin blog.51cto.com/15127502/2655046