關(guān)于Kubernetes中使用Helm部署應(yīng)用及私有Heml源搭建的一些筆記
寫在前面
學習K8s涉及,整理筆記記憶
博文偏實戰(zhàn),內(nèi)容涉及:
helm的基本概念及安裝,Helm源配置
chart包的安裝部署
私有Helm源的搭建及chart包的push和pull
“不愛也不恨”包含了全部世俗智慧的一半;“不要說話也不要相信”則包含了另一半的人生智慧。——叔本華《人生的智慧》
Heml
Helm是一個由CNCF孵化和管理的項目,用于對需要在Kubernetes上部署的復(fù)雜應(yīng)用進行定義、安裝和更新。Helm以Chart的方式對應(yīng)用軟件進行描述,可以方便地創(chuàng)建、版本化、共享和發(fā)布復(fù)雜的應(yīng)用軟件。
helm的作用就是把許多的資源定義 比如svc,deployment,一次性通過全部定義好,放在源里統(tǒng)一管理,這樣很容易在其他機器上部署,個人理解這個類似于自動化運維中ansible中的角色概念,前端項目中的npm包管理工具,后端項目中的maven等構(gòu)建工具一樣,類比Ansible使用角色來整合playbook.yaml達到復(fù)用性。同樣的,使用helm用于整合k8s中的資源對象yaml文件,實現(xiàn)復(fù)用性,同時講資源文件的參數(shù),和參數(shù)值通過temple和value進行了分離
Heml主要概念
Chart:一個Helm包,其中包含運行一個應(yīng)用所需要的工具和資源定義,還可能包含Kubernetes集群中的服務(wù)定義,類似Ansible中的rhel-system-roles軟件包
Release: 在Kubernetes集群上運行的一個Chart實例。在同一個集群上,一個Chart可以被安裝多次。
Repository:用于存放和共享Chart倉庫。簡單來說, Helm整個系統(tǒng)的主要任務(wù)就是,在倉庫中查找需要的Chart,然后將Chart以Release的形式安裝到Kubernetes集群中。
使用helm我們首先需要安裝,可以通過Github下載安裝包
Heml 安裝
安裝包下載:https://github.com/helm/helm/releases:
解壓安裝
┌──[root@vms81.liruilongs.github.io]-[~] └─$tar zxf helm-v3.2.1-linux-amd64.tar.gz ┌──[root@vms81.liruilongs.github.io]-[~] └─$cd linux-amd64/ ┌──[root@vms81.liruilongs.github.io]-[~/linux-amd64] └─$ls helm LICENSE README.md
之后直接將helm復(fù)制到/usr/local/bin/,配置完之后,即可以使用helm命令
┌──[root@vms81.liruilongs.github.io]-[~/linux-amd64] └─$cp helm /usr/local/bin/ ┌──[root@vms81.liruilongs.github.io]-[~/linux-amd64] └─$ls /usr/local/bin/ helm
配置命令自動補全,通過寫入/etc/profile?文件?souece < (helm completion bash)的方式配置命令自動補全。配置完記得使用source /etc/profile去刷新配置
┌──[root@vms81.liruilongs.github.io]-[~/ansible/k8s-helm-create] └─$helm --help | grep bash completion generate autocompletions script for the specified shell (bash or zsh) ┌──[root@vms81.liruilongs.github.io]-[~/ansible/k8s-helm-create] └─$vim /etc/profile ┌──[root@vms81.liruilongs.github.io]-[~/ansible/k8s-helm-create] └─$source /etc/profile ┌──[root@vms81.liruilongs.github.io]-[~/ansible/k8s-helm-create] └─$cat /etc/profile | grep -v ^# | grep source source <(kubectl completion bash) source <(helm completion bash) ┌──[root@vms81.liruilongs.github.io]-[~/ansible/k8s-helm-create] └─$
驗證安裝,查看Heml版本
┌──[root@vms81.liruilongs.github.io]-[~/ansible/k8s-helm-create] └─$helm version version.BuildInfo{Version:"v3.2.1", GitCommit:"fe51cd1e31e6a202cba7dead9552a6d418ded79a", GitTreeState:"clean", GoVersion:"go1.13.10"} ┌──[root@vms81.liruilongs.github.io]-[~/ansible/k8s-helm-create] └─$
配置helm源
使用helm需要配置yaml源,常見的有阿里。微軟,和Githup上的源
阿里云的源 https://apphub.aliyuncs.com
微軟azure的源 http://mirror.azure.cn/kubernetes/charts/
查看所以的源
┌──[root@vms81.liruilongs.github.io]-[~/ansible/k8s-helm-create] └─$helm repo list #查看所以的源 Error: no repositories to show
添加指定是源
┌──[root@vms81.liruilongs.github.io]-[~/ansible/k8s-helm-create] └─$helm repo add azure http://mirror.azure.cn/kubernetes/charts/ "azure" has been added to your repositories ┌──[root@vms81.liruilongs.github.io]-[~/ansible/k8s-helm-create] └─$helm repo add ali https://apphub.aliyuncs.com "ali" has been added to your repositories
查看剛才添加的yum源
┌──[root@vms81.liruilongs.github.io]-[~/ansible/k8s-helm-create] └─$helm repo list NAME URL azure http://mirror.azure.cn/kubernetes/charts/ ali https://apphub.aliyuncs.com ┌──[root@vms81.liruilongs.github.io]-[~/ansible/k8s-helm-create] └─$
Helm的常見用法
Helm的常見用法,包括搜索Chart、安裝Chart、自定義Chart配置、更新或回滾Release、刪除Release、創(chuàng)建自定義Chart、搭建私有倉庫等
helm search:搜索可用的Chart
┌──[root@vms81.liruilongs.github.io]-[~/ansible/k8s-helm-create] └─$helm search repo mysql NAME CHART VERSION APP VERSION DESCRIPTION ali/mysql 6.8.0 8.0.19 Chart to create a Highly available MySQL cluster ali/mysqldump 2.6.0 2.4.1 A Helm chart to help backup MySQL databases usi... ali/mysqlha 1.0.0 5.7.13 MySQL cluster with a single master and zero or ... ali/prometheus-mysql-exporter 0.5.2 v0.11.0 A Helm chart for prometheus mysql exporter with... azure/mysql 1.6.9 5.7.30 DEPRECATED - Fast, reliable, scalable, and easy... azure/mysqldump 2.6.2 2.4.1 DEPRECATED! - A Helm chart to help backup MySQL... azure/prometheus-mysql-exporter 0.7.1 v0.11.0 DEPRECATED A Helm chart for prometheus mysql 。。。。。。。。。。
chart包拉取
安裝chart可以直接使用命令安裝,也可以拉取到本地之后安裝,也可以直接通過命名行安裝
本地的Chart壓縮包(helm install mysql-1.6.4.tgz)
一個Chart目錄(helm install mysql/)
一個完整的URL(helm install https://example.com/charts/mysql-1.6.4.tgz)
chart包拉取
┌──[root@vms81.liruilongs.github.io]-[~/ansible/k8s-helm-create] └─$helm pull azure/mysql --version=1.6.4 ┌──[root@vms81.liruilongs.github.io]-[~/ansible/k8s-helm-create] └─$ls mysql-1.6.4.tgz
helm install:安裝Chart
chart包直接安裝
┌──[root@vms81.liruilongs.github.io]-[~/ansible/k8s-helm-create] └─$#helm install db azure/mysql --version=1.6.4 ┌──[root@vms81.liruilongs.github.io]-[~/ansible/k8s-helm-create] └─$
拉取的chart包詳細信息,通過解壓之后查看
┌──[root@vms81.liruilongs.github.io]-[~/ansible/k8s-helm-create] └─$ls mysql-1.6.4.tgz ┌──[root@vms81.liruilongs.github.io]-[~/ansible/k8s-helm-create] └─$tar zxf mysql-1.6.4.tgz ....... ┌──[root@vms81.liruilongs.github.io]-[~/ansible/k8s-helm-create] └─$ls mysql mysql-1.6.4.tgz ┌──[root@vms81.liruilongs.github.io]-[~/ansible/k8s-helm-create] └─$cd mysql/ ┌──[root@vms81.liruilongs.github.io]-[~/ansible/k8s-helm-create/mysql] └─$ls Chart.yaml README.md templates values.yaml
對于下載好的yaml文件,我們可以修改后使用helm package重新打包
┌──[root@vms81.liruilongs.github.io]-[~/ansible/k8s-helm-create] └─$rm -rf mysql-1.6.4.tgz ; helm package mysql/ Successfully packaged chart and saved it to: /root/ansible/k8s-helm-create/mysql-1.6.4.tgz ┌──[root@vms81.liruilongs.github.io]-[~/ansible/k8s-helm-create] └─$ls mysql mysql-1.6.4.tgz
下面我們修改chart中的對應(yīng)鏡像為已經(jīng)下載好的mysql和busybox鏡像
┌──[root@vms81.liruilongs.github.io]-[~/ansible] └─$ansible 192.168.26.82 -m shell -a "docker images | grep mysql" 192.168.26.82 | CHANGED | rc=0 >> mysql latest ecac195d15af 2 months ago 516MB mysql
┌──[root@vms81.liruilongs.github.io]-[~/ansible] └─$fg vim ./k8s-helm-create/mysql/values.yaml ┌──[root@vms81.liruilongs.github.io]-[~/ansible] └─$
通過修好的yaml文件創(chuàng)建chart,?使用helm ls查看當前運行的chart
┌──[root@vms81.liruilongs.github.io]-[~/ansible/k8s-helm-create] └─$helm ls NAME NAMESPACE REVISION UPDATED STATUS CHART APP VERSION
使用helm install運行Chart
這里我們使用之前的那個mysq chart來安裝一個mysql
┌──[root@vms81.liruilongs.github.io]-[~/ansible/k8s-helm-create] └─$cd mysql/ ┌──[root@vms81.liruilongs.github.io]-[~/ansible/k8s-helm-create/mysql] └─$helm install mydb . NAME: mydb LAST DEPLOYED: Thu Jan 13 01:51:42 2022 NAMESPACE: liruilong-network-create STATUS: deployed REVISION: 1 NOTES: MySQL can be accessed via port 3306 on the following DNS name from within your cluster: mydb-mysql.liruilong-network-create.svc.cluster.local To get your root password run: MYSQL_ROOT_PASSWORD=$(kubectl get secret --namespace liruilong-network-create mydb-mysql -o jsonpath="{.data.mysql-root-password}" | base64 --decode; echo) To connect to your database: 1. Run an Ubuntu pod that you can use as a client: kubectl run -i --tty ubuntu --image=ubuntu:16.04 --restart=Never -- bash -il 2. Install the mysql client: $ apt-get update && apt-get install mysql-client -y 3. Connect using the mysql cli, then provide your password: $ mysql -h mydb-mysql -p To connect to your database directly from outside the K8s cluster: MYSQL_HOST=127.0.0.1 MYSQL_PORT=3306 # Execute the following command to route the connection: kubectl port-forward svc/mydb-mysql 3306 mysql -h ${MYSQL_HOST} -P${MYSQL_PORT} -u root -p${MYSQL_ROOT_PASSWORD}
查看是否是否運行成功mydb的pod和SVC
┌──[root@vms81.liruilongs.github.io]-[~/ansible/k8s-helm-create/mysql] └─$kubectl get pods NAME READY STATUS RESTARTS AGE mydb-mysql-7f8c5c47bd-82cts 1/1 Running 0 55s pod1 1/1 Running 2 (7d17h ago) 9d pod2 1/1 Running 3 (3d3h ago) 9d
┌──[root@vms81.liruilongs.github.io]-[~/ansible/k8s-helm-create/mysql] └─$kubectl get svc NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE mydb-mysql ClusterIP 10.107.17.103
安裝一個mysql客戶端測試OK
┌──[root@vms82.liruilongs.github.io]-[~] └─$yum install mariadb -y
┌──[root@vms81.liruilongs.github.io]-[~/ansible/k8s-helm-create/mysql] └─$mysql -h10.107.17.103 -uroot -ptesting Welcome to the MariaDB monitor. Commands end with ; or \g. Your MySQL connection id is 7 Server version: 5.7.18 MySQL Community Server (GPL) Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. MySQL [(none)]> use mysql Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -A Database changed
刪除Release
┌──[root@vms81.liruilongs.github.io]-[~/ansible/k8s-helm-create/mysql] └─$helm del mydb release "mydb" uninstalled ┌──[root@vms81.liruilongs.github.io]-[~/ansible/k8s-helm-create/mysql] └─$helm ls NAME NAMESPACE REVISION UPDATED STATUS CHART APP VERSION ┌──[root@vms81.liruilongs.github.io]-[~/ansible/k8s-helm-create/mysql] └─$
搭建私有Repository
自建的Chart之后自然需要搭建私有倉庫。下面使用Nginx搭建一個簡單的Chart私有倉庫
倉庫搭建
倉庫搭建,找一臺機器運行一個Nginx服務(wù)做倉庫,需要注意要對主頁數(shù)據(jù)做映射
┌──[root@vms83.liruilongs.github.io]-[~] └─$netstat -ntulp | grep 80 ┌──[root@vms83.liruilongs.github.io]-[~] └─$docker run -dit --name=helmrepo -p 8080:80 -v /data:/usr/share/nginx/html/charts docker.io/nginx 7201e001b02602f087105ca6096b0816acb03db02296c35c098a3dfddcb9c8d0 ┌──[root@vms83.liruilongs.github.io]-[~] └─$docker ps | grep helmrepo 7201e001b026 nginx "/docker-entrypoint.…" 16 seconds ago Up 15 seconds 0.0.0.0:8080->80/tcp, :::8080->80/tcp helmrepo
訪問測試
┌──[root@vms83.liruilongs.github.io]-[~] └─$curl 127.0.0.1:8080
chart包上傳
打包之前的mysql包,上傳helm私有倉庫。這里需要本讀生成索引文件index.yaml
┌──[root@vms81.liruilongs.github.io]-[~/ansible/k8s-helm-create] └─$helm package mysql/ Successfully packaged chart and saved it to: /root/ansible/k8s-helm-create/mysql-1.6.4.tgz ┌──[root@vms81.liruilongs.github.io]-[~/ansible/k8s-helm-create] └─$helm repo index . --url http://192.168.26.83:8080/charts ┌──[root@vms81.liruilongs.github.io]-[~/ansible/k8s-helm-create] └─$ls index.yaml mysql mysql-1.6.4.tgz ┌──[root@vms81.liruilongs.github.io]-[~/ansible/k8s-helm-create] └─$cd ..
將索引文件和chart包一同上傳到私有倉庫
┌──[root@vms81.liruilongs.github.io]-[~/ansible] └─$ansible 192.168.26.83 -m copy -a "src=./k8s-helm-create/index.yaml dest=/data/" 192.168.26.83 | CHANGED => { "ansible_facts": { "discovered_interpreter_python": "/usr/bin/python" }, "changed": true, "checksum": "233a0f3837d46af8a50098f1b29aa524b751cb29", "dest": "/data/index.yaml", "gid": 0, "group": "root", "md5sum": "66953d9558e44ab2f049dc602600ffda", "mode": "0644", "owner": "root", "size": 843, "src": "/root/.ansible/tmp/ansible-tmp-1642011407.72-76313-71345316897038/source", "state": "file", "uid": 0 } ┌──[root@vms81.liruilongs.github.io]-[~/ansible] └─$ansible 192.168.26.83 -m copy -a "src=./k8s-helm-create/mysql-1.6.4.tgz dest=/data/" 192.168.26.83 | CHANGED => { "ansible_facts": { "discovered_interpreter_python": "/usr/bin/python" }, "changed": true, "checksum": "4fddb1c13c71673577570e61f68f926af7255bad", "dest": "/data/mysql-1.6.4.tgz", "gid": 0, "group": "root", "md5sum": "929267de36f9be04e0adfb2f9c9f5812", "mode": "0644", "owner": "root", "size": 11121, "src": "/root/.ansible/tmp/ansible-tmp-1642011437.58-76780-127185287864942/source", "state": "file", "uid": 0 } ┌──[root@vms81.liruilongs.github.io]-[~/ansible] └─$
倉庫索引文件更新
如果添加新的chart包到私有倉庫,需要對于索引文件進行更新
helm create 創(chuàng)建一個自定義的chart包
┌──[root@vms81.liruilongs.github.io]-[~/ansible/k8s-helm-create] └─$helm create liruilonghelm Creating liruilonghelm ┌──[root@vms81.liruilongs.github.io]-[~/ansible/k8s-helm-create] └─$ls index.yaml liruilonghelm mysql mysql-1.6.4.tgz ┌──[root@vms81.liruilongs.github.io]-[~/ansible/k8s-helm-create] └─$helm package liruilonghelm/ Successfully packaged chart and saved it to: /root/ansible/k8s-helm-create/liruilonghelm-0.1.0.tgz ┌──[root@vms81.liruilongs.github.io]-[~/ansible/k8s-helm-create] └─$ls index.yaml liruilonghelm liruilonghelm-0.1.0.tgz mysql mysql-1.6.4.tgz
使用同樣的命令跟新索引文件
┌──[root@vms81.liruilongs.github.io]-[~/ansible/k8s-helm-create] └─$helm repo index . --url http://192.168.26.83:8080/charts ┌──[root@vms81.liruilongs.github.io]-[~/ansible/k8s-helm-create] └─$cat index.yaml
查看新的索引文件
apiVersion: v1 entries: liruilonghelm: - apiVersion: v2 appVersion: 1.16.0 created: "2022-01-13T02:22:19.442365047+08:00" description: A Helm chart for Kubernetes digest: abb491f061cccc8879659149d96c99cbc261af59d5fcf8855c5e86251fbd53c1 name: liruilonghelm type: application urls: - http://192.168.26.83:8080/charts/liruilonghelm-0.1.0.tgz version: 0.1.0 mysql: - apiVersion: v1 appVersion: 5.7.30 created: "2022-01-13T02:22:19.444985984+08:00" description: Fast, reliable, scalable, and easy to use open-source relational database system. digest: 29153332e509765010c7e5e240a059550d52b01b31b69f25dd27c136dffec40f home: https://www.mysql.com/ icon: https://www.mysql.com/common/logos/logo-mysql-170x115.png keywords: - mysql - database - sql maintainers: - email: o.with@sportradar.com name: olemarkus - email: viglesias@google.com name: viglesiasce name: mysql sources: - https://github.com/kubernetes/charts - https://github.com/docker-library/mysql urls: - http://192.168.26.83:8080/charts/mysql-1.6.4.tgz version: 1.6.4 generated: "2022-01-13T02:22:19.440764685+08:00"
會發(fā)現(xiàn)索引文件已經(jīng)被更新,entries里有兩個對象,上傳相關(guān)的數(shù)據(jù)
┌──[root@vms81.liruilongs.github.io]-[~/ansible] └─$ansible 192.168.26.83 -m copy -a "src=./k8s-helm-create/index.yaml dest=/data/" 192.168.26.83 | CHANGED => { "ansible_facts": { "discovered_interpreter_python": "/usr/bin/python" }, "changed": true, "checksum": "dbdc550a24159764022ede9428b9f11a09ccf291", "dest": "/data/index.yaml", "gid": 0, "group": "root", "md5sum": "b771d8e50dd49228594f8a566117f8bf", "mode": "0644", "owner": "root", "size": 1213, "src": "/root/.ansible/tmp/ansible-tmp-1642012325.1-89511-190591844764611/source", "state": "file", "uid": 0 } ┌──[root@vms81.liruilongs.github.io]-[~/ansible] └─$ansible 192.168.26.83 -m copy -a "src=./k8s-helm-create/liruilonghelm-0.1.0.tgz dest=/data/" 192.168.26.83 | CHANGED => { "ansible_facts": { "discovered_interpreter_python": "/usr/bin/python" }, "changed": true, "checksum": "f7fe8a0a7585adf23e3e23f8378e3e5a0dc13f92", "dest": "/data/liruilonghelm-0.1.0.tgz", "gid": 0, "group": "root", "md5sum": "04670f9b7e614d3bc6ba3e133bddae59", "mode": "0644", "owner": "root", "size": 3591, "src": "/root/.ansible/tmp/ansible-tmp-1642012352.54-89959-104738456182106/source", "state": "file", "uid": 0 }
用私有倉庫chart部署應(yīng)用程序
┌──[root@vms81.liruilongs.github.io]-[~/ansible] └─$helm repo add liruilong_repo http://192.168.26.83:8080/charts "liruilong_repo" has been added to your repositories ┌──[root@vms81.liruilongs.github.io]-[~/ansible] └─$helm repo list NAME URL azure http://mirror.azure.cn/kubernetes/charts/ ali https://apphub.aliyuncs.com liruilong_repo http://192.168.26.83:8080/charts
私有源查找安裝的chart
┌──[root@vms81.liruilongs.github.io]-[~/ansible] └─$helm search repo mysql | grep liruilong liruilong_repo/mysql 1.6.4 5.7.30 Fast, reliable, scalable, and easy to use open-... ┌──[root@vms81.liruilongs.github.io]-[~/ansible] └─$
┌──[root@vms81.liruilongs.github.io]-[~/ansible] └─$helm list NAME NAMESPACE REVISION UPDATED STATUS CHART APP VERSION ┌──[root@vms81.liruilongs.github.io]-[~/ansible/k8s-helm-create] └─$helm install liruilongdb liruilong_repo/mysql NAME: liruilongdb LAST DEPLOYED: Thu Jan 13 02:42:41 2022 NAMESPACE: liruilong-network-create STATUS: deployed REVISION: 1 NOTES: MySQL can be accessed via port 3306 on the following DNS name from within your cluster: liruilongdb-mysql.liruilong-network-create.svc.cluster.local To get your root password run: MYSQL_ROOT_PASSWORD=$(kubectl get secret --namespace liruilong-network-create liruilongdb-mysql -o jsonpath="{.data.mysql-root-password}" | base64 --decode; echo) To connect to your database: 1. Run an Ubuntu pod that you can use as a client: kubectl run -i --tty ubuntu --image=ubuntu:16.04 --restart=Never -- bash -il 2. Install the mysql client: $ apt-get update && apt-get install mysql-client -y 3. Connect using the mysql cli, then provide your password: $ mysql -h liruilongdb-mysql -p To connect to your database directly from outside the K8s cluster: MYSQL_HOST=127.0.0.1 MYSQL_PORT=3306 # Execute the following command to route the connection: kubectl port-forward svc/liruilongdb-mysql 3306 mysql -h ${MYSQL_HOST} -P${MYSQL_PORT} -u root -p${MYSQL_ROOT_PASSWORD}
驗證安裝,查看chart列表
┌──[root@vms81.liruilongs.github.io]-[~/ansible/k8s-helm-create] └─$helm list NAME NAMESPACE REVISION UPDATED STATUS CHART APP VERSION liruilongdb liruilong-network-create 1 2022-01-13 02:42:41.537928447 +0800 CST deployed mysql-1.6.4 5.7.30 ┌──[root@vms81.liruilongs.github.io]-[~/ansible/k8s-helm-create] └─$
在helm install命令的執(zhí)行過程中,可以使用helm status命令跟蹤?Release的狀態(tài):Helm不會等待所有創(chuàng)建過程的完成,這是因為有些Chart的Docker鏡像較大,會消耗很長的時間進行下載和創(chuàng)建
┌──[root@vms81.liruilongs.github.io]-[~/ansible/k8s-helm-create] └─$helm status liruilongdb NAME: liruilongdb LAST DEPLOYED: Thu Jan 13 02:42:41 2022 NAMESPACE: liruilong-network-create STATUS: deployed REVISION: 1 NOTES: MySQL can be accessed via port 3306 on the following DNS name from within your cluster: liruilongdb-mysql.liruilong-network-create.svc.cluster.local To get your root password run: MYSQL_ROOT_PASSWORD=$(kubectl get secret --namespace liruilong-network-create liruilongdb-mysql -o jsonpath="{.data.mysql-root-password}" | base64 --decode; echo) To connect to your database: 1. Run an Ubuntu pod that you can use as a client: kubectl run -i --tty ubuntu --image=ubuntu:16.04 --restart=Never -- bash -il 2. Install the mysql client: $ apt-get update && apt-get install mysql-client -y 3. Connect using the mysql cli, then provide your password: $ mysql -h liruilongdb-mysql -p To connect to your database directly from outside the K8s cluster: MYSQL_HOST=127.0.0.1 MYSQL_PORT=3306 # Execute the following command to route the connection: kubectl port-forward svc/liruilongdb-mysql 3306 mysql -h ${MYSQL_HOST} -P${MYSQL_PORT} -u root -p${MYSQL_ROOT_PASSWORD}
在成功安裝Chart后,系統(tǒng)會在當前命名空間內(nèi)創(chuàng)建一個ConfigMap用于保存Release對象的數(shù)據(jù)
┌──[root@vms81.liruilongs.github.io]-[~/ansible/k8s-helm-create] └─$kubectl get configmaps NAME DATA AGE kube-root-ca.crt 1 12d liruilongdb-mysql-test 1 2d19h
┌──[root@vms81.liruilongs.github.io]-[~/ansible/k8s-helm-create] └─$kubectl describe configmaps liruilongdb-mysql-test Name: liruilongdb-mysql-test Namespace: liruilong-network-create Labels: app=liruilongdb-mysql app.kubernetes.io/managed-by=Helm chart=mysql-1.6.4 heritage=Helm release=liruilongdb Annotations: meta.helm.sh/release-name: liruilongdb meta.helm.sh/release-namespace: liruilong-network-create Data ==== run.sh: ---- @test "Testing MySQL Connection" { mysql --host=liruilongdb-mysql --port=3306 -u root -ptesting } BinaryData ==== Events:
可以通過?helm delete命令刪除運行的Release
┌──[root@vms81.liruilongs.github.io]-[~/ansible/k8s-helm-create] └─$kubectl get pods NAME READY STATUS RESTARTS AGE liruilongdb-mysql-5cbf489f65-6ff4q 1/1 Running 1 (56m ago) 26h ┌──[root@vms81.liruilongs.github.io]-[~/ansible/k8s-helm-create] └─$helm delete liruilongdb release "liruilongdb" uninstalled ┌──[root@vms81.liruilongs.github.io]-[~/ansible/k8s-helm-create] └─$kubectl get pods NAME READY STATUS RESTARTS AGE liruilongdb-mysql-5cbf489f65-6ff4q 1/1 Terminating 1 (57m ago) 26h ┌──[root@vms81.liruilongs.github.io]-[~/ansible/k8s-helm-create] └─$
關(guān)于Helm和小伙伴就分享到這里,其實還有很大,比如chart更新回滾,模板導(dǎo)出等。有遇到的做補充。生活加油
Kubernetes 云原生
版權(quán)聲明:本文內(nèi)容由網(wǎng)絡(luò)用戶投稿,版權(quán)歸原作者所有,本站不擁有其著作權(quán),亦不承擔相應(yīng)法律責任。如果您發(fā)現(xiàn)本站中有涉嫌抄襲或描述失實的內(nèi)容,請聯(lián)系我們jiasou666@gmail.com 處理,核實后本網(wǎng)站將在24小時內(nèi)刪除侵權(quán)內(nèi)容。