Helm-chart学习-简单介绍与使用
?
目錄
為什么需要Helm?直接kubectl有什么問題嗎?
Helm介紹
Helm基本使用
Helm模板設(shè)置?
流程控制
Chart模板:命名模板
?寫一個通用的Chart
使用Harbor作為Chart倉庫
為什么需要Helm?直接kubectl有什么問題嗎?
? ? 常規(guī)K8s部署應(yīng)用方式:將需要的資源編寫YAML文件,然后apply? -f進(jìn)行部署,當(dāng)然也有使用圖形界面操作的,這里不做討論。 ? ? 例如部署一個常規(guī)web程序,一般我們需要部署deployment、service、ingress資源。Deployment.yaml
apiVersion: apps/v1 kind: Deployment metadata:name: webnamespace: default spec:replicas: 3selector:matchLabels:app: webtemplate:metadata:labels:app: webspec:containers:- name: webimage: nginx:1.19ports:- containerPort: 80Service.yaml
apiVersion: v1 kind: Service metadata:labels:app: webname: web spec:ports:- port: 80protocol: TCPtargetPort: 8080selector:app: webIngress.yaml
apiVersion: networking.k8s.io/v1 kind: Ingress metadata:name: web spec:rules:- host: web.linux.comhttp:paths:- path: /pathType: Prefixbackend:service:name: webport:number: 80 因?yàn)镵ubernetes缺少對發(fā)布的應(yīng)用版本管理和控制,使得部署的應(yīng)用維護(hù)和更新等面臨許多的問題: 1.如何將這些服務(wù)作為一個整體管理? 例如業(yè)務(wù)下線,去卸載的話得一個一個yaml文件執(zhí)行delete,上線也得一個個去apply,雖然可以在目錄里執(zhí)行 kubectl apply -f . 來執(zhí)行當(dāng)前目錄所有yaml文件,但是不能保證每次都會再同一個目錄。 2.這些資源文件如何高效復(fù)用? 就像上面的yaml文件我部署了一個名稱為web的deployment,下次我要部署一個web2,該怎么辦,又得重新復(fù)制過來修改重新部署。 3.而且k8s并不支持應(yīng)用級別的版本管理。 這個怎么理解呢,就是說k8s目前只支持deployment的回滾,像ingress,service這些資源并沒有一個版本記錄,不支持回滾。 所以我們可以helm來解決這3個問題,當(dāng)然它也不是萬能的,不能完全替代kubectl。Helm介紹
Helm是一個Kubernetes的包管理工具,就像Linux下的包管理器,如yum/apt等,可以很方便的將之前 打包好的yaml文件部署到kubernetes上。 Helm有3個重要概念: helm:一個命令行客戶端工具,主要用于Kubernetes應(yīng)用chart的創(chuàng)建、打包、發(fā)布和管理。 Chart:應(yīng)用描述,一系列用于描述 k8s 資源相關(guān)文件的集合。 Release:基于Chart的部署實(shí)體,一個 chart 被 Helm 運(yùn)行后將會生成對應(yīng)的一個release;將在 k8s中創(chuàng)建出真實(shí)運(yùn)行的資源對象。 Helm目前有兩個大版本:v2和v3,查資料時注意一下版本。 2019年11月Helm團(tuán)隊(duì)發(fā)布v3版本,相比v2版本最大變化是將Tiller刪除,并大部分代碼重構(gòu)。 也就是說v3版本是直接會通過kubeconfig配置($HOME/.kube/config)來連接Kubernetes。 kubectl可以使用這個helm就能正常使用。 Helm項(xiàng)目地址:https://github.com/helm/helm 下載Helm客戶端: wget https://get.helm.sh/helm-v3.9.0-linux-amd64.tar.gz tar zxvf helm-v3.9.0-linux-amd64.tar.gz? #解壓 mv linux-amd64/helm /usr/bin/? ? ? ? ? ? ? ? #將這個文件移動到系統(tǒng)的二進(jìn)制目錄下就能使用了。| completion | 命令補(bǔ)全,source <(helm completion bash) |
| create | 創(chuàng)建一個chart并指定名字 |
| history | 獲取release歷史 |
| install | 安裝一個chart |
| list | 列出release |
| template | 本地呈現(xiàn)渲染模板 |
| uninstall | 卸載一個release |
| rollback | 從之前版本回滾 |
| upgrade | 更新一個release |
| package | 將chart目錄打包到chart存檔文件中 |
| pull | 從遠(yuǎn)程倉庫中下載chart并解壓到本地 # helm pull stable/mysql --untar |
| repo | 添加,列出,移除,更新和索引chart倉庫。可用子命令:add、index、list、remove、update |
| search | 根據(jù)關(guān)鍵字搜索chart。可用子命令:hub、repo |
| show | 查看chart詳細(xì)信息。可用子命令:all、chart、readme、values |
| status | 顯示已命名版本的狀態(tài) |
| version | 查看helm客戶端版本 |
| help | 命令的幫助文檔 |
| dependency | 管理chart依賴 |
| get | 下載一個release。可用子命令:all、hooks、manifest、notes、values |
下面我們來直接使用它:
使用helm前這里插個故障我之前遇到的,因?yàn)榧菏嵌M(jìn)制搭建的 k8s的config文件并不在~/.kube目錄下,所以使用時報錯:
Helm基本使用
helm create 創(chuàng)建Chart示例 helm install 部署 helm upgrade 更新 helm rollback 回滾 helm uninstall 卸載 創(chuàng)建Chart示例 創(chuàng)建chart: helm create mychart # 創(chuàng)建一個示例chartcharts:目錄里存放這個chart依賴的所有子chart。? #這個我沒有使用
Chart.yaml:用于描述這個 Chart的基本信息,包括名字、描述信息以及版本等。#只用于描述。
values.yaml :用于存儲 templates 目錄中模板文件中用到變量的值。
templates: 目錄里面存放所有yaml模板文件。
? ? NOTES.txt :用于介紹Chart幫助信息, helm install 部署后展示給用戶。例如:如何使用這個? ? ? ? Chart、列出缺省的設(shè)置等。
? ? _helpers.tpl:放置模板的地方,可以在整個chart中重復(fù)使用。
helm install web mychart #部署一個示例chart,示例這里是一個nginx。
這是一個官方的chart,演示示例。
我這邊不用它的示例,我們自己動手寫一個chart。
#這就已經(jīng)完成了一個基礎(chǔ)的chart,部署之后可以查看版本。
helm install web /root/test-chart/ -n test #指定在test名稱空間部署
helm ls -n test #查看chart列表
kubectl get pod,svc,ep -n test -o wide #查看資源部署情況
?#更新與回滾測試
sed -i "s/1.16.0/1.17.0/" /root/test-chart/Chart.yaml helm upgrade web /root/test-chart/ -n test sed -i "s/1.17.0/1.18.0/" /root/test-chart/Chart.yaml helm upgrade web /root/test-chart/ -n test #這里做2個版本升級用于測試回滾helm history web -n test
?helm rollback web 1 -n test#默認(rèn)不指定版本是回滾到上一個版本,我這里指定了版本號“1”。
?#到這里已經(jīng)學(xué)會了helm的基本使用,但是這個不是我們使用helm的最終目的,helm的強(qiáng)大之處在于它的模板渲染功能,下面我們學(xué)習(xí)模板使用。
--------------------------------------------------------------------------------------------------------------------------------
Helm模板設(shè)置?
在做模板之前,我們要知道每個yaml文件的差異化信息,這里大致整理了一下以下幾點(diǎn):
1.應(yīng)用名稱
2.標(biāo)簽
3.鏡像和tag
4.端口
5.命名空間
6.數(shù)據(jù)卷
7.副本數(shù)量
8.資源限制
| 內(nèi)置 | 作用 |
| Release.Name | release 名稱 |
| Release.Time | release 的時間 |
| Release.Namespace | release 的命名空間 |
| Release.Service | release 服務(wù)的名稱 |
| Release.Revision | release 的修訂版本號,從1開始累加 |
#helm 動態(tài)傳參演示。
?
#這里默認(rèn)values文件里使用的nginx鏡像,使用set命令將它更改成httpd。
如果執(zhí)行helm upgrade web3 /root/test-chart/ --set image.tag=1.19 -n test
我這里web3是一個httpd,在執(zhí)行完指定版本更新后,是否會變更release的鏡像?
做到這里時會發(fā)現(xiàn),如果用命令行執(zhí)行了set變更了values的值,我又沒有寫入到文件,我該怎么查詢我做的更改?
這里可以使用get命令獲取:
helm get values web3 -n test
helm get manifest web3 -n test 則可以獲取這個release部署的所有yaml文件內(nèi)容:
然后會發(fā)現(xiàn)我獲取的是我當(dāng)前版本的yaml,那我需要獲取的是某個部署失敗或者部署錯誤的yaml文件來拍錯,例如我之前部署的httpd版本yaml文件我該怎么查詢?
這里可以是用參數(shù) --revesion ,通history查詢到報錯的版本,我這里是版本號1.
helm history -n test web3 #查詢到版本號
helm get manifest --revision=1 web3 -n test? #指定版本號查詢release所渲染的yaml文件。
?
?我們會發(fā)現(xiàn)在使用set命令,只指定了values.yaml里的的tag參數(shù)時,默認(rèn)也會讀取image的信息,當(dāng)我不想讓它讀取默認(rèn)values.yaml里的其他參數(shù)時,我們也可以指定一個自定義需要變更的values文件來更新,不要對原有values.yaml來操作。
cat >/tmp/test.yaml <<EOF image:repository: nginxtag: "1.20" EOFhelm upgrade web3 /root/test-chart/ -f /tmp/test.yaml -n test| yaml | set |
| name: value | --set name=value |
| a:b c:d | --set a=b,c=d |
| outer: ? inner: value | --set outer.inner=value |
| name: ? - a ? - b ? - c | --set name={a,b,c} |
| servers: ? - port: 80 | --set servers[0].port=80 |
| servers: ? - port: 80 ? ? host: example | --set servers[0].port=80,servers[0].host=example |
| name: "value1,value2" | --set name=value1\,value2 |
| nodeSelector: ? kubernetes.io/role: master | --set?nodeSelector."kubernetes\.io/role"=master |
Chart模板:調(diào)試
我們在創(chuàng)建完chart時往往不確定渲染出來的yaml是否是自己所需要的,這是可以使用調(diào)試命令查看所渲染的yaml文件。
helm template /root/test-chart/ #直接本地渲染,使用了Releaes.Name處使用占位符顯示,因?yàn)槲覀儧]有提供release的名稱。
helm install web4 /root/test-chart/ -n test --dry-run #使用--dry-run 則會直接完整顯示release所渲染的結(jié)果。
?
Chart模板:函數(shù)與管道
常用函數(shù): quote:將值轉(zhuǎn)換為字符串,即加雙引號 default:設(shè)置默認(rèn)值,如果獲取的值為空則為默認(rèn)值 indent和nindent:縮進(jìn)字符串 toYaml:引用一塊YAML內(nèi)容? quote:將值轉(zhuǎn)換為字符串,即加雙引號 示例:nodeSelector標(biāo)簽的值用了true正常使用會報錯,這是因?yàn)樗且粋€布爾值,需要加引號才可以。 在values.yaml增加:
在deployment.yaml增加:
部署時會發(fā)現(xiàn)報錯:
?在deployment.yaml增加函數(shù)quote?解決
?渲染結(jié)果:
?indent和nindent:都是縮進(jìn)字符串,主要區(qū)別在于nindent會在縮進(jìn)前多添加一個換行符。
示例: apiVersion: apps/v1kind: Deployment
metadata:
? labels:
? ? app: {{ .Release.Name |indent 6}}
? ? app: {{ .Release.Name |nindent 6}}
所以常用的是nindent,因?yàn)閕ndent直接按空格就能實(shí)現(xiàn)。
? toYaml:引用一塊YAML內(nèi)容 示例:在values.yaml里寫結(jié)構(gòu)化數(shù)據(jù),引用內(nèi)容塊 在values增加resources資源配額。
{{ toYaml .Values.resources | nindent 10 }}
渲染結(jié)果:
動態(tài)讀取文件內(nèi)容 有時想從文件中導(dǎo)入內(nèi)容,可通過.Files對象實(shí)現(xiàn)與toYaml類似。 示例:通過configmap存儲redis的配置文件 cat > /root/test-chart/templates/configmap.yaml << EOF apiVersion: v1 kind: ConfigMap metadata:name: configmap-test data:config.yaml: | {{ .Files.Get "redis.properties" | indent 4 }} #引用chart根目錄下的redis.properties文件內(nèi)容 EOFcat > /root/test-chart/redis.properties << EOF redis.host=127.0.0.1 redis.port=6379 redis.passwd=123456 EOFhelm install web4 /root/test-chart/ -n test --dry-run #渲染測試 渲染結(jié)果:
?Files.Glob方法返回所有匹配的文件路徑列表,當(dāng)多個文件時,可以更靈活提取某些文件。
mkdir /root/test-chart/files mv /root/test-chart/redis.properties /root/test-chart/files cat >/root/test-chart/files/mysql.properties << EOF mysql.host=127.0.0.1 mysql.port=3306 EOFcat >/root/test-chart/templates/configmap << EOF apiVersion: v1 kind: ConfigMap metadata:name: configmap-test data:{{- $root := . }} #設(shè)置作用域?yàn)閏hart根目錄{{- range $path,$bytes := .Files.Glob "files/*.properties" }} #將文件名稱賦值給path{{ base $path }}: | #打印出文件名稱 {{ $root.Files.Get $path |indent 4 }} #獲取文件內(nèi)容{{- end -}} #循環(huán)結(jié)束符 EOFhelm install web4 /root/test-chart/ -n test --dry-run #渲染模板#這個步驟我留了一個坑,做到這里就會發(fā)現(xiàn)^^?測試渲染結(jié)果:
流程控制
Helm模板語言提供以下流程控制語句: if/else:條件判斷 range:循環(huán) with:指定變量作用域?流程控制之if/else
在values增加:
?在templates目錄下創(chuàng)建ingress.yaml,并在yaml文件增加if判斷,為true時執(zhí)行。
?helm install web4 ?/root/test-chart/ -n test --dry-run --set ingress.enabled=true#默認(rèn)不部署ingress,執(zhí)行ingress.enabled=true則部署?如果值為以下幾種情況則為false:
一個布爾類型 false
一個數(shù)字 0
一個空的字符串
一個 nil(空或 null)
一個空的集合( map、 slice、 tuple、 dict、 array)
條件表達(dá)式也支持操作符:
?eq 等于
?ne 不等于
?lt 小于
?gt 大于
?and 邏輯與
?or 邏輯或
values.yaml:
deployment.yaml:
#增加if判斷后,渲染出來的模板有空行,增加減號刪除空行。
?流程控制之range
?range相當(dāng)于shell的for循環(huán)。
示例:遍歷數(shù)據(jù) values.yaml:configmap.yaml:
?流程控制之with
with:指定變量作用域 語法: {{ with <值> }} # 限制范圍 {{ end }} with語句可以允許將當(dāng)前范圍 . 設(shè)置為特定的對象,比如我們前面一直使用的 .Values.nodeSelecotr,我們可以使用 with來將 . 范圍指向.Values.nodeSelecotr: values.yaml?deployment.yaml
渲染結(jié)果:?
?
?變量:
變量是實(shí)際應(yīng)用中不多,但有時候結(jié)合with、range能更好處理數(shù)據(jù)。 示例:k8s變量是鍵值,可以range遍歷生成? # values.yaml env:NAME: "wang"CLASS: "graduate" #deployment.yaml env:{{- range $k,$v := .Values.env }}- name: {{ $k }}value: {{ $v }}{{- end }}?
渲染結(jié)果:
Chart模板:命名模板
命名模板類似于開發(fā)語言中的函數(shù),指一段可以直接被另一段程序或代碼引用的程序或代碼。 在編寫chart時,可以將一些重復(fù)使用的內(nèi)容寫在命名模板文件中供公共使用,這樣可減少重 復(fù)編寫程序段和簡化代碼結(jié)構(gòu)。 命名模塊使用define定義,template(不支持管道)或include引入,在templates目錄中默 認(rèn)下劃線開頭的文件為公共模板(helpers.tpl)。 # cat templates/_helpers.tpl {{- define "fullname" -}} {{- .Chart.Name -}}-{{ .Release.Name }} {{- end -}}# cat templates/deployment.yaml apiVersion: apps/v1 kind: Deployment metadata:labels:app: {{ .Release.Name |indent 6}}app: {{ .Release.Name |nindent 6}}name: {{ include "fullname" . }}渲染結(jié)果:?
?
?寫一個通用的Chart
編寫流程: 1. 先創(chuàng)建模板示例 helm create demo 2. 修改Chart.yaml,Values.yaml,參考示例預(yù)留變動的字段值 3. 在templates目錄下準(zhǔn)備部署應(yīng)用所需的yaml文件,并添加指令引用 Values.yaml字段 4. 將重復(fù)使用的內(nèi)容作為命名模板 5. 使用Chart結(jié)合參數(shù)部署多個同類服務(wù) [root@k8s-master ~]# mkdir example-chart/templates -p [root@k8s-master ~]# cp mychart/Chart.yaml example-chart/ [root@k8s-master ~]# touch example-chart/values.yaml [root@k8s-master ~]# touch example-chart/templates/{_helpers.tpl,NOTES.txt}#Chart.yaml 刪除空行與注釋文件就保留以下信息,修改name字段為自己的chart名字---------- [root@k8s-master ~]# cat example-chart/Chart.yaml apiVersion: v2 name: example-chart description: A Helm chart for Kubernetes type: application version: 0.1.0 appVersion: "1.16.0"#為chart設(shè)置所有yaml都通用的模板資源------------------------------- root@k8s-master templates]# cat _helpers.tpl {{/* 注釋模板 */}}{{/* 這個chart資源的名字 */}}{{- define "fullname" -}} {{ .Chart.Name }}-{{.Release.Name }} {{- end -}}{{/* 標(biāo)簽 */}} {{- define "labels" -}} chart_name: {{ .Chart.Name }} instance_name: {{ .Release.Name }} {{- end -}}#為values設(shè)置常用參數(shù)------------------------------------ [root@k8s-master templates]# cat ../values.yaml #副本數(shù) replicaCount: 1#鏡像選擇 image:repository: nginxtag: "latest"#資源配額 resources:limits:cpu: 200mmemory: 256Mirequests:cpu: 100mmemory: 128Mi#configmap開關(guān),默認(rèn)關(guān)閉 configmap:enabled: false#ingress開關(guān),默認(rèn)關(guān)閉 ingress:enabled: falseannotations:nginx.ingress.kubernetes.io/rewrite-target: /kubernetes.io/ingress.class: nginxhost: www.checkqq.compath: / #service端口模式 service:port: 80targetport: 80type: ClusterIP#環(huán)境變量 env:NAME: "wang"CLASS: "graduate"#存活檢查 livenessProbe:httpGet:path: /port: 80#就緒檢查 readinessProbe:httpGet:path: /port: 80#為configmap設(shè)置配置文件----------------------------------- [root@k8s-master templates]# cat ../files/redis.properties ../files/mysql.properties redis.host=127.0.0.1 redis.port=6379 ----------------------------------分割線,前面為redis,后面為mysql redis.passwd=123456 mysql.host=127.0.0.1 mysql.port=3306#configmap.yaml 最終模板------------------------------------ [root@k8s-master templates]# cat configmap.yaml apiVersion: v1 kind: ConfigMap metadata:name: {{ include "fullname" . }} data:{{- $root := . }} #設(shè)置作用域?yàn)閏hart根目錄{{- range $path,$bytes := .Files.Glob "files/*.properties" }} #將文件名稱賦值給path{{ base $path }}: | #打印出文件名稱 {{ $root.Files.Get $path |indent 4 }} #獲取文件內(nèi)容{{- end -}} #deployment.yaml 最終模板------------------------------------ #[root@k8s-master templates]# cat deployment.yaml apiVersion: apps/v1 kind: Deployment metadata:name: {{ include "fullname" . }} spec:replicas: {{ .Values.replicaCount }}selector:matchLabels:{{- include "labels" . | nindent 6 }}strategy: {}template:metadata:labels:{{- include "labels" . | nindent 8 }}spec:containers:- image: {{ .Values.image.repository }}:{{ .Values.image.tag }}name: webresources: {{ toYaml .Values.resources | nindent 10 }}env:{{- range $k,$v := .Values.env }}- name: {{ $k }}value: {{ $v }}{{- end }}{{- if .Values.livenessProbe }}livenessProbe: {{ toYaml .Values.livenessProbe | nindent 10 }}{{- end }}{{- if .Values.readinessProbe }}readinessProbe: {{ toYaml .Values.readinessProbe | nindent 10 }}{{- end }}#service.yaml 最終模板------------------------------------ [root@k8s-master templates]# cat service.yaml apiVersion: v1 kind: Service metadata:name: {{ include "fullname" . }} spec:ports:- port: {{ .Values.service.port }}protocol: TCPtargetPort: {{ .Values.service.targetport }}selector:{{- include "labels" . | nindent 4}}type: {{ .Values.service.type }}#ingress.yaml 最終模板------------------------------------ [root@k8s-master templates]# cat ingress.yaml {{ if .Values.ingress.enabled }} #如果ingress值為真啟用ingress apiVersion: networking.k8s.io/v1 kind: Ingress metadata:name: {{ include "fullname" . }}annotations: {{- toYaml .Values.ingress.annotations | nindent 4 }} spec:rules:- host: {{ .Values.ingress.host }}http:paths:- path: {{ .Values.ingress.path }}pathType: Prefixbackend:service:name: {{ include "fullname" . }}port:number: {{ .Values.service.port }} {{- end }}#####最后的最后為我們的chart寫入使用說明######## echo "這家伙很懶,什么也沒寫" > NOTES.txt到這里,我們的chart已經(jīng)書寫完畢,接下來是平常該怎么使用的說明。
#對我們的chart進(jìn)行打包 [root@k8s-master ~]# helm package example-chart/ Successfully packaged chart and saved it to: /root/example-chart-0.1.0.tgz [root@k8s-master ~]# ls anaconda-ks.cfg example-chart ingress-controller-1.1.yaml nfs-external-provisioner test-chart calico.yaml example-chart-0.1.0.tgz linux-amd64 nfs-external-provisioner.zip deployment.yaml helm-v3.6.0-linux-amd64.tar.gz mychart service.yaml也就是這個example-chart-0.1.0.tgz,后續(xù)使用是直接用這個chart包例如:[root@k8s-master templates]# helm install web /root/example-chart-0.1.0.tgz --dry-run -n test --dry-run --set ingress.enabled=true --set configmap.enabled=true --set replicaCount=3 --set image.tag=1.19 --set livenessProbe=false --set readinessProbe=false#--set ingress.enabled=true values默認(rèn)不啟用部署ingress #--set configmap.enabled=true values默認(rèn)不啟用部署configmap #--set replicaCount=3 設(shè)置pod的副本數(shù)為3 #--set image.tag=1.19 設(shè)置鏡像版本標(biāo)簽為1.19 #--set livenessProbe=false 不啟用存活檢查 #--set readinessProbe=false 不啟用就緒檢查使用Harbor作為Chart倉庫
Harbor是一個主流的鏡像倉庫系統(tǒng),在 v1.6 版本以后的 harbor 中新增加了 helm charts 的管理功能,可以存儲Chart文件。 使用步驟: 1、啟用Harbor的Chart倉庫服務(wù) # ./install.sh --with-chartmuseum 啟用后,默認(rèn)創(chuàng)建的項(xiàng)目就帶有helm charts功能了。 2、安裝push插件 helm plugin install https://github.com/chartmuseum/helm-push #自動安裝 如果安裝失敗可以手動安裝: mkdir -p /root/.local/share/helm/plugins/helm-push cd /root/.local/share/helm/plugins/helm-push tar zxvf helm-push_0.9.0_linux_amd64.tar.gz 3、添加repo [root@k8s-master ~]# helm repo add --username admin --password Harbor12345 myrepo http://192.168.31.90/chartrepo/library "myrepo" has been added to your repositories [root@k8s-master helm-push]# helm repo list NAME URL myrepo http://192.168.31.90/chartrepo/library [root@k8s-master ~]# helm repo list NAME URL myrepo http://192.168.31.90/chartrepo/library[root@k8s-master ~]# helm repo update 4、推送 [root@k8s-master ~]# helm push example-chart-0.1.0.tgz --username=admin --password=Harbor12345 http://192.168.31.90/chartrepo/library Pushing example-chart-0.1.0.tgz to http://192.168.31.90/chartrepo/library... Done. 5、部署 [root@k8s-master ~]# helm install web2 --version 0.1.0 myrepo/example-chart --set image.repository=nginx --set ingress.enabled=true -n test NAME: web2 LAST DEPLOYED: Mon Jul 11 01:08:15 2022 NAMESPACE: test STATUS: deployed REVISION: 1 TEST SUITE: None NOTES: 這家伙很懶,什么也沒寫 [root@k8s-master ~]# kubectl get pod,svc,ep -o wide -n test NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES pod/example-chart-web-f7bc75db4-572hn 1/1 Running 0 11m 10.244.36.78 k8s-node1 <none> <none> pod/example-chart-web2-7455c75b88-754xn 1/1 Running 0 38s 10.244.36.79 k8s-node1 <none> <none>NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE SELECTOR service/example-chart-web ClusterIP 10.102.212.0 <none> 80/TCP 11m chart_name=example-chart,instance_name=web service/example-chart-web2 ClusterIP 10.102.255.92 <none> 80/TCP 38s chart_name=example-chart,instance_name=web2NAME ENDPOINTS AGE endpoints/example-chart-web 10.244.36.78:80 11m endpoints/example-chart-web2 10.244.36.79:80 38s [root@k8s-master ~]#?這里我遇到個故障順便記錄下。
Error: Internal error occurred: failed calling webhook"validate.nginx.ingress.kubernetes.io": Post "https://ingress-nginx-controller-admission.ingress-nginx.svc:443/networking/v1/ingresses?timeout=10s": dial tcp 10.108.0.150:443: i/o timeout#部署ingress報錯刪除ValidatingWebhookConfiguration。kubectl delete -A ValidatingWebhookConfiguration ingress-nginx-admission?最后通過部署的ingress測試剛剛部署的chart,域名+ingress的端口
?
總結(jié)
以上是生活随笔為你收集整理的Helm-chart学习-简单介绍与使用的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: import requests
- 下一篇: 【损失函数】生成任务感知损失小结