3.安装mychart
[root@master ~]# helm install web1 mychart/NAME: web1
LAST DEPLOYED: Fri Jun 11 17:05:55 2021
NAMESPACE: default
STATUS: deployed
REVISION: 1
TEST SUITE: None
[root@master ~]# kubectl get pods
web1-6fbb48567f-ch86p 1/1 Running 0 61s
root@master ~]# kubectl get svc
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 5d20h
ui3-weave-scope NodePort 10.103.97.141 <none> 80:31674/TCP 53m
web NodePort 10.111.111.127 <none> 80:32079/TCP 20h
web1 NodePort 10.96.150.188 <none> 80:31544/TCP 79s
4.应用升级
helm upgrade chart名称 [root@master ~]# helm upgrade web1 mychart/Release "web1" has been upgraded. Happy Helming!
NAME: web1
LAST DEPLOYED: Fri Jun 11 17:12:01 2021
NAMESPACE: default
STATUS: deployed
REVISION: 2
TEST SUITE: None
实现yaml高效复用
通过传递参数,动态渲染模板,yaml内容动态传入参数生成
在chart中有values.yaml文件,定义yaml文件全局变量
[root@master mychart]# lscharts Chart.yaml templates values.yaml
[root@master mychart]#
1.在values.yaml定义变量和值
2.在具体yaml文件中,获取定义变量值
yaml文件大体有几个地方不同
image
tag
label
port
replicas
一、在values.yaml定义变量和值
这个是原本文件里面的内容
# Default values for mychart.# This is a YAML-formatted file.
# Declare variables to be passed into your templates.
replicaCount: 1
image:
repository: nginx
pullPolicy: IfNotPresent
# Overrides the image tag whose default is the chart appVersion.
tag: ""
imagePullSecrets: []
nameOverride: ""
fullnameOverride: ""
serviceAccount:
# Specifies whether a service account should be created
create: true
# Annotations to add to the service account
annotations: {}
# The name of the service account to use.
# If not set and create is true, a name is generated using the fullname template
name: ""
podAnnotations: {}
podSecurityContext: {}
# fsGroup: 2000
securityContext: {}
# capabilities:
# drop:
# - ALL
# readOnlyRootFilesystem: true
# runAsNonRoot: true
# runAsUser: 1000
service:
type: ClusterIP
port: 80
ingress:
enabled: false
className: ""
annotations: {}
# kubernetes.io/ingress.class: nginx
# kubernetes.io/tls-acme: "true"
hosts:
- host: chart-example.local
paths:
- path: /
[root@master mychart]# vim values.yaml