使用同一套yaml部署多个应用时,yaml应该修改的位置有:
1.资源名字
2.镜像
3.标签
4.副本数
5.端口``
动态渲染
#修改全局变量文件内容
[root@k8s-master ~]# cd mychar/
[root@k8s-master mychar]# vim values.yaml
replica: 1
image: lizhenliang/java-demo
tag: latest
label: java-demo
port: 8080
重新定义yaml文件
[root@k8s-master mychar]# cd templates/
[root@k8s-master templates]# vim Nginx.yaml
apiVersion: apps/v1
kind: Deployment
Metadata:
name: {{ .Release.Name }}-dp
spec:
replicas: {{ .Values.replicas }}
selector:
matchLabels:
app: {{ .Values.label }}
template:
Metadata:
labels:
app: {{ .Values.label }}
spec:
containers:
- image: {{ .Values.image }}:{{ .Values.tag}}
name: Nginx
[root@k8s-master templates]# vim Nginx-svc.yaml
apiVersion: v1
kind: Service
Metadata:
labels:
name: {{ .Release.Name }}-svc
spec:
type: NodePort
ports:
- port: 80
protocol: TCP
targetPort: {{ .Values.port }}
nodePort: 30003
selector:
app: {{ .Values.label }}
status:
#测试
[root@k8s-master ~]# helm install --dry-run web1 mychar/
#测试没有问题后可直接安装
[root@k8s-master ~]# helm install web1 mychar/
web验证:http://NodeIP:Port
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。