con.sh
741 Bytes
# 使用您本地的正确 nginx.conf 创建 ConfigMap
kubectl delete configmap nginx-config -n ecommerce --ignore-not-found
kubectl create configmap nginx-config --from-file=nginx.conf=./nginx.conf -n ecommerce
# 更新 Deployment 挂载 ConfigMap
kubectl patch deployment -n ecommerce frontend -p '{
"spec": {
"template": {
"spec": {
"containers": [{
"name": "frontend",
"volumeMounts": [{
"name": "nginx-config",
"mountPath": "/etc/nginx/nginx.conf",
"subPath": "nginx.conf"
}]
}],
"volumes": [{
"name": "nginx-config",
"configMap": {
"name": "nginx-config"
}
}]
}
}
}
}'