最近,我开始研究Kubernetes,我可以使用默认选项部署nginx。但是,如何在Kubernetes中部署我自己nginx.conf? 有人可以举一个简单的例子吗?
发表于 2019-10-16
最近,我开始研究Kubernetes,我可以使用默认选项部署nginx。但是,如何在Kubernetes中部署我自己nginx.conf? 有人可以举一个简单的例子吗?
创建nginx的deployment yaml:
kubectl run --image=nginx nginx -oyaml --dry-run apiVersion: apps/v1 kind: Deployment metadata: creationTimestamp: null labels: run: nginx name: nginx spec: replicas: 1 selector: matchLabels: run: nginx strategy: {} template: metadata: creationTimestamp: null labels: run: nginx spec: containers: - image: nginx name: nginx resources: {} status: {}
配置创建Nginx的Config ConfigMap
kubectl create configmap nginx-conf --from-file=./nginx.conf
挂载文件
apiVersion: apps/v1 kind: Deployment metadata: creationTimestamp: null labels: run: nginx name: nginx spec: replicas: 1 selector: matchLabels: run: nginx strategy: {} template: metadata: creationTimestamp: null labels: run: nginx spec: containers: - image: nginx name: nginx resources: {} volumeMounts: - mountPath: /etc/nginx/nginx.conf name: nginx-conf subPath: nginx.conf volumes: - configMap: name: nginx-conf name: nginx-conf
感谢,挂载文件亮了!!
你的答案