k8s of Helm (yaml fast download document templates)

A, helm Introduction

Cloud application deployment container in Kubernetes is also a challenging job, Helm is to simplify the installation of a client deployment tool container in cloud applications in Kubernetes. By helm can help developers to define, container cloud application installations and upgrades Kubernetes the same time, also can share container cloud applications through helm. Common applications include providing a Redis, MySQL and Jenkins et al Kubeapps Hub, you can use a command helm will be able to deploy their own Kubernetes installed in the cluster.

1, helm architecture

helm overall structure is shown below, the architecture Helm Helm client, server and Chart Tiller consisting FIG warehouse; Tiller Kubernetes deployed, the client obtains Helm Chart Chart warehouse installation package and installed to deploy Kubernetes cluster.

k8s of Helm (yaml fast download document templates)

Helm is a tool for managing Kubernetes pack, Helm provides the following capabilities:

  • Creating new charts;
  • The charts packaged into tgz file;
  • Interact with the chart warehouse;
  • Install and uninstall applications Kubernetes of;
  • Helm installation management and use of the life cycle of the charts;

2, important concepts helm of

In Helm, there are three important concepts you need to know:

  • Charts: Creating an application instance Kubernetes is a collection of information, which is a helm of the package that contains all application needs to run a k8s mirroring, dependencies, and resource definitions, but also includes Service resource definition, if necessary, it is similar to the yum rpm files;
  • Repository: Chart warehouse for centralized storage and distribution Charts.
  • Config: Run configuration example of information used when installing the application;
  • Release: running instance chart comprising specific config;

In the same cluster, a different config Charts can be used to install repeated several times, each installation will create a new Release.

3, helm components

There are two main components in Helm, i.e. Helm Tiller client and the server:

Helm client: is a command-line tool for end-user use.

The client is responsible for the following tasks:

  • Local chart development;
  • Warehouse Management
  • Tiller interact with the server (send charts need to be installed, request information about the release version of the request to update or uninstall the release version is installed)

Tiller server: Tiller Kubernetes services deployed in a cluster, Helm clients by interacting with Tiller server, and eventually interact with Kubernetes API server.

Tiller server is responsible for the following tasks:

  • Listen for requests from the client's Helm
  • Combinations and configurations to build a chart released
  • In Kubernetes installed, and track subsequent release
  • By interacting with Kubernetes, update or chart

Second, the deployment helm

1, the client installation helm

#从github下载helm
[root@master ~]# wget https://get.helm.sh/helm-v2.14.3-linux-amd64.tar.gz
 #解包,只需要包中的一个命令
[root@master ~]# tar zxf helm-v2.14.3-linux-amd64.tar.gz    
[root@master ~]# mv linux-amd64/helm /usr/local/bin/
[root@master ~]# chmod +x /usr/local/bin/helm 
#设置命令自动补全
[root@master ~]# echo 'source <(helm completion bash)' >> /etc/profile
[root@master ~]# . /etc/profile    #重载环境变量

2, installation Tiller server (you need to create an authorized user)

[root@master ~]# vim tiller-rbac.yaml   #创建授权用户
apiVersion: v1
kind: ServiceAccount
metadata:
  name: tiller
  namespace: kube-system
---
apiVersion: rbac.authorization.k8s.io/v1beta1
kind: ClusterRoleBinding
metadata:
  name: tiller
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: cluster-admin
subjects:
  - kind: ServiceAccount
    name: tiller
    namespace: kube-system
[root@master ~]# kubectl apply -f tiller-rbac.yaml    #执行yaml文件
[root@master ~]# helm init --service-account=tiller   #Tiller server的环境初始化
#helm的服务端就是Tiller
[root@master ~]# kubectl get pod -n kube-system |  grep tiller   #查看tiller的pod名称
tiller-deploy-8557598fbc-tvfsj   0/1     ContainerCreating   0          2m16s
[root@master ~]# kubectl edit pod tiller-deploy-8557598fbc-tvfsj -n kube-system
#编辑pod的yaml文件,将其使用的镜像改为国内阿里云的,默认是Google的镜像,下载不下来
#修改spec字段的image指定的镜像,如下:
    image: gcr.io/kubernetes-helm/tiller:v2.14.3
#修改如下:
    image: registry.cn-hangzhou.aliyuncs.com/google_containers/tiller:v2.14.3
#修改后,自己想办法使其去下载新的镜像,也或者说换一种方法
#就是查看到这个pod运行在哪个节点,然后手动下载阿里云的镜像并更改名字为yaml文件中默认指定的名字
#这样,还省得改yaml文件了
#我这里改完以后,也不知道是删除pod后更改生效了还是....
[root@master ~]# kubectl get pod -n kube-system | grep tiller
#只要保证tiller的pod正常运行即可
tiller-deploy-8557598fbc-m986t   1/1     Running   0          7m54s

3, equipped helm warehouse

[root@master ~]# helm repo list      #查看其仓库信息
NAME    URL                                             
stable  https://kubernetes-charts.storage.googleapis.com
#如上,默认是Google,在国外,速度特别慢
local   http://127.0.0.1:8879/charts    
#执行下面命令,更改为国内阿里云的仓库
[root@master ~]# helm repo add stable https://kubernetes.oss-cn-hangzhou.aliyuncs.com/charts
[root@master ~]# helm repo list   #再次查看,可以发现更改生效了
NAME    URL                                                   
stable  https://kubernetes.oss-cn-hangzhou.aliyuncs.com/charts
local   http://127.0.0.1:8879/charts        
[root@master ~]# helm repo update      #更新一下helm仓库
[root@master ~]# helm version     #查看helm版本信息,必须保证可以查看出来client和server,才可正常使用helm
Client: &version.Version{SemVer:"v2.14.3", GitCommit:"0e7f3b6637f7af8fcfddb3d2941fcc7cbebb0085", GitTreeState:"clean"}
Server: &version.Version{SemVer:"v2.14.3", GitCommit:"0e7f3b6637f7af8fcfddb3d2941fcc7cbebb0085", GitTreeState:"clean"}

4, whether the test can be used normally helm

[root@master ~]# helm search mysql      #搜索MySQL
#查看到的是charts包文件,查出来的版本是helm的Charts包的版本
[root@master ~]# helm inspect stable/mysql    #查看其详细信息
[root@master ~]# helm fetch stable/mysql        #下载搜索到的包到本地
[root@master templates]# helm install stable/mysql       #在线安装这个MySQL

If the above test commands can be executed properly, then the helm is configured correctly.

-------- end of this article so far, thanks for reading --------

Guess you like

Origin blog.51cto.com/14154700/2453866