https://cloud.sealos.io/
使用sealos选择nginx docker镜像部署
修改k8s部署的nginx image内部的nginx.conf来添加proxy_pass
需要在外部编写一个nginx.conf,覆盖掉镜像内部的nginx.conf
在k8s中,可以使用把编写的nginx.conf放到 configMap内 随后用configMap的内容挂载到nginx容器内覆盖掉configMap
gui 新增配置文件
创建后 实际生成了configMap
configmap.yaml
1 2 3 4 5 6 7 8 9 10 11 12
| apiVersion: v1 kind: ConfigMap metadata: name: nginx-test data: etcvn-nginxvn-nginxvn-conf: |- user nginx; worker_processes auto;
error_log /var/log/nginx/error.log notice; pid /var/run/nginx.pid; ...省略其他配置内容
|
deployment.yml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
| apiVersion: apps/v1 kind: Deployment metadata: name: nginx-test labels: app: nginx-test spec: replicas: 1 revisionHistoryLimit: 1 selector: matchLabels: app: nginx-test ... spec: automountServiceAccountToken: false containers: - name: nginx-test image: nginx ... volumeMounts: - name: etcvn-nginxvn-nginxvn-conf mountPath: etc/nginx/nginx.conf subPath: ./etc/nginx/nginx.conf volumes: - name: etcvn-nginxvn-nginxvn-conf configMap: name: nginx-test items: - key: etcvn-nginxvn-nginxvn-conf path: ./etc/nginx/nginx.conf
|
原gui 新建的名字即为挂载到容器中的路径,需要修改为etc/nginx/nginx.conf
kubectl edit deployment nginx-test
进入编辑模式
按Insert
进入编辑
Esc
退出编辑,进入命令模式 :wq
保存并退出 :q
不保存退出