1.nginx.yaml
[root@k8s186 nginx]# cat nginx_deployment.yaml apiVersion: apps/v1 kind: Deployment metadata: name: nginx-deploy spec: selector: matchLabels: app: nginx replicas: 2 template: metadata: labels: app: nginx spec: containers: - name: ngixn-cluster image: nginx:latest ports: - containerPort: 8081 volumeMounts: - name: nginx1 mountPath: /etc/nginx/nginx.conf subPath: nginx.conf volumes: - name: nginx1 configMap: name: nginxconf items: - key: nginx.conf path: nginx.conf
2.创建configmap
kubectl create configmap nginxconf --from-file=nginx.conf
3.kubectl create -f nginx.yaml
注:无法做到热更新,可以手动重启pod