目录
1、为什么需要helm?
2、helm介绍
3、helm工作流程
4、使用helm
Helm管理应用生命周期:
helm模板功能试用
helm动态传参使用
helm动态文件传参
helm版本管理
回滚
拓展命令
卸载应用:
附属
服务打包
wget https://get.helm.sh/helm-v3.2.4-linux-amd64.tar.gz
tar zxvf helm-v3.2.4-linux-amd64.tar.gz
mv linux-amd64/helm /usr/bin/
helm create mychart
helm create my-chart
cd my-chart/
mkdir chart-demo
cd chart-demo
vi Chart.yaml
apiVersion: v2name: chart-demodescription: A Helm chart for Kubernetestype: applicationversion: 0.1.0 # chart的版本号appVersion: 1.0.0 #chart应用默认的版本
touch values.yaml
mkdir templates
cd templates
vi deployment.yaml
apiVersion: apps/v1kind: Deploymentmetadata:labels:app: webname: webspec:replicas: 1selector:matchLabels:app: webstrategy: {}template:metadata:labels:app: webspec:containers:- image: nginxname: nginxresources: {}
vi service.yaml
apiVersion: v1kind: Servicemetadata:labels:app: webname: webspec:ports:- name: 80-80port: 80protocol: TCPtargetPort: 80selector:app: webtype: NodePort
vi NOTES.txt
touch _helpers.tpl
mkdir templates
yum install tree -y
tree .
helm install web /root/chart-demo/
helm list
vi values.yaml
#这里定义默认变量name: "web2"replicas: 1labels:project: demoapp: nginximage:repository: nginxtag: "latest"service:port: 80targetport: 80type: ClusterIP这样,将常用参数存入values
vi deployment.yaml
apiVersion: apps/v1kind: Deploymentmetadata:name: {{ .Values.name }}spec:replicas: {{ .Values.replicas }}selector:matchLabels:project: {{ .Values.labels.project }}app: {{ .Values.labels.app }}strategy: {}template:metadata:labels:project: {{ .Values.labels.project }}app: {{ .Values.labels.app }}spec:containers:- image: {{ .Values.image.repository }}:{{ .Values.image.tag }}name: webresources: {}vi service.yamlapiVersion: v1kind: Servicemetadata:name: {{ .Values.name }}spec:ports:- name: 80-80port: {{ .Values.service.port }}protocol: TCPtargetPort: {{ .Values.service.targetport }}selector:project: {{ .Values.labels.project }}app: {{ .Values.labels.app }}type: {{ .Values.service.type }}
helm install web2 /root/chart-demo/
helm install web2 /root/chart-demo/ --dry-run
helm install web3 /root/chart-demo/ --set name="web3" --set image.repository=httpd --set labels.app=httpd
vi abc.yaml
name: "web5"replicas: 3labels:app: nginximage:repository: nginxtag: "1.16"service:type: NodePort
helm install web5 /root/chart-demo/ --set name="web4" -f abc.yaml
vi abc.yaml
name: "web6"replicas: 3labels:project: msapp: nginximage:repository: nginxtag: "1.17"service:type: NodePort
helm upgrade web6 /root/chart-demo/ -f abc.yaml
helm list
helm history web6
helm rollback web
helm history web
helm rollback web 2
helm uninstall web
helm uninstall xxx
helm install web7 /root/chart-demo/ --description="nginx:1.17"
helm package chart-demo/