K8s is composed for docker compose, which is composed for docker compose. For example, k8S is composed for Docker Compose, which is composed for Docker Compose. For example, k8S is composed for Docker Compose.

helm

Helm is divided into helm client and Tiller server. K8s deployment if kubectl one by one to create is too tedious; Helm was created in order for K8S to quickly start up a group of pods like Docker Compose.

Helm client is responsible for the creation and management of Chart and release as well as the interaction with Tiller, while Tiller server runs in THE K8S cluster. He is responsible for processing the requests of Helm client and then converting them into KubeApiServer’s requests to interact with K8S

  • Chart is an information collection for creating an application, including configuration templates, parameter definitions, dependencies, documentation, etc., of various K8S objects
  • Release is a running instance of Chart and represents a running application. When Chart is installed into the K8S cluster, a release is generated. Chart can be installed into the same cluster for many times, and each installation is a release

Helm deployment

The client

Downloading a Client

Download it and unzip it

Sudo tar ZXVF - helm - v2.16.1 - Linux - amd64. Tar. GzCopy the code

Decompress the package and put it in the Linux execution directory to change the permission

sudo cp linux-amd64/helm /usr/local/bin/
sudo chmod a+x /usr/local/bin/helm
Copy the code

If a message is displayed after helm is entered, the installation is successful

Install the Tiller server

Install tiller server, also need to configure kubectl tool and Kubeconfig file on the machine, ensure that kubectl tool can access apiserver on this machine

Since K8S apiserver enables ACCESS control of RBAC, it is necessary to create service Account: Tiller for tiller and assign appropriate roles to it. You can check the helm’s documentation link

Create clusterRoleBinding

apiVersion: v1
kind: ServiceAccount
metadata:
  name: tiller
  namespace: kube-system
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
  name: tiller
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: cluster-admin
subjects:
  - kind: ServiceAccount
    name: tiller
    namespace: kube-system
Copy the code

create

kubectl create -f rbac-config.yaml
Copy the code

Initialize the tiller

helm init --service-acount tiller --skip-refresh
Copy the code

This process may have problems pulling the image, will be dropped by the wall, you can go to the DockerHub to find

Gcr.io. Kubernetes – Helm. tiller: Kubectl describe is available in v2.16.1

Then make the container run by changing the tag

Docker tag fishead/GCR. IO. Kubernetes - helm. Tiller: v2.16.1 GCR. IO/kubernetes - helm/tiller: v2.16.1Copy the code

The helm is now installed

Helm use

Helm Warehouse Address

Create a chart package

Create a MyApp Chart package for the current directory

$ helm create myapp
Copy the code

After creation, the directory structure is as follows

Myapp-chart package Name ├─ Charts - Dependent sub-package directory, which can contain multiple dependent Chart package ├─ chart.yaml - chart definition, you can define chart name, version number information. ├── templates - K8S configuration template directory, we write the K8S configuration are in this directory, in addition to NOTES. TXT and the underlined files named, other files can be named at will. │ ├── deployme.yaml │ ├── helres. TPL - underlined files for the helm as common library definition files, mainly used to define common sub-templates, functions, etc. Helm will not submit the results of these common library files to K8S for processing. │ ├── Ingress.yaml │ ├── notes.txt - Help file for chart package. │ └ ─ ─ service. Yaml └ ─ ─ values. The yaml - chart package parameters configuration file, the template parameter can reference here.Copy the code

The deployment of application

Run the helm install app command to specify the path of the app folder

$ helm install /myapp
Copy the code

Update the application

Run the helm upgrade app name App folder path command

$ helm upgrade myapp /myapp
Copy the code

Delete the application

$ helm delete myapp
Copy the code

But Helm still keeps a historical version of chart that has been deleted, and an error will be reported when you recreate chart with the same name

Error: a release named nacos already exists.
Run: helm ls --all nacos; to check the status of the release
Or run: helm del --purge nacos; to delete it
Copy the code

This can be used if you want to delete the mirror completely

$ helm delete --purge myapp
Copy the code