curl https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3 | bash
helm create cnblogs-chart
cnblogs-chart
├── charts
├── Chart.yaml
├── templates
│ ├── deployment.yaml
│ ├── _helpers.tpl
│ ├── ingress.yaml
│ ├── NOTES.txt
│ ├── serviceaccount.yaml
│ ├── service.yaml
│ └── tests
│ └── test-connection.yaml
└── values.yaml
将 metadata.name 的值修改为 .Release.Name
将 containers.name 的值改为 .Release.Name
将 containers. image 的值改为 {{ .Release.Name }}:{{ .Values.image.version }}
添加 containers. workingDir 容器工作目录配置
添加 containers.command 容器启动命令配置
添加 containers.env 环境变量配置
将 matchLabels 与 labels 的值都改为 {{ .Release.Name }}
添加将 configMap 安装为 volume 的配置用于应用读取 appsettings.Production.json 。
metadata:
name: {{ .Release.Name }}
labels:
name: {{ .Release.Name }}
spec:
selector:
matchLabels:
app: {{ .Release.Name }}
template:
metadata:
labels:
app: {{ .Release.Name }}
spec:
containers:
- name: {{ .Release.Name }}
image: "{{ .Release.Name }}:{{ .Values.image.version }}"
workingDir: /app
command:
- sh
- run.sh
env:
- name: TZ
value: "Asia/Shanghai"
volumeMounts:
- name: appsettings
mountPath: /app/appsettings.Production.json
subPath: appsettings.Production.json
readOnly: true
volumes:
- name: appsettings
configMap:
name: "{{ .Release.Name }}-appsettings"
kind: Service
metadata:
name: {{ .Release.Name }}
labels:
name: {{ .Release.Name }}
spec:
type: {{ .Values.service.type }}
ports:
- port: {{ .Values.service.port }}
targetPort: http
protocol: TCP
name: http
selector:
app: {{ .Release.Name }}
将 image.pullPolicy 修改为 Always 。
添加 image.version 并设置为 latest 。
在 imagePullSecrets 中添加 secret 名称。
将 serviceAccount.create 设置为 false 。
在 resources 的 limits 与 requests 中设置 CPU 与内存限制。
replicaCount: 1
image:
repository: {}
version: latest
pullPolicy: Always
imagePullSecrets:
- name: regcred
nameOverride: ""
fullnameOverride: ""
serviceAccount:
create: false
name:
podSecurityContext: {}
securityContext: {}
service:
type: ClusterIP
port: 80
ingress:
enabled: false
resources:
limits:
cpu: 2
memory: 2G
requests:
cpu: 100m
memory: 64Mi
nodeSelector: {}
tolerations: []
affinity: {}
helm install cache-api --set image.version=1.0 --dry-run --debug .
helm install cache-api --set image.version=1.0 .
helm ls
NAME NAMESPACE REVISION UPDATED STATUS CHART APP VERSION
cache-api production 1 2020-01-22 17:17:30.414863452 +0800 CST deployed cnblogs-chart-0.1.0 1
helm install news-web --set image.version=1.0.4,resources.limits.cpu=1 --dry-run --debug cnblogs-chart/
helm install ing-web --set image.version=1.3.11,resources.limits.cpu=1.5 --dry-run --debug cnblogs-chart/
出处:http://dwz.date/cAjn




●使用 Elastic 技术栈构建 Kubernetes 全栈监控(完结)
●运维精华
文章转载自51reboot运维开发,如果涉嫌侵权,请发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。




