[英]unable to edit nginx.conf file from K8 cluster
我想編輯我的Nginx.conf
文件存在於 AKS 中的 Nginx controller pod 中,但是使用 exec 命令編輯命令不起作用,還有什么其他方法可以編輯我的nginx.conf
。
我試過的命令:
kubectl exec -it nginx-nginx-ingress-controller -n nginx -- cat /etc/nginx/nginx.conf
通常,執行到 pod 中進行更改是一個壞主意。 它違反了基礎設施即代碼的原則。 您應該將 nginx.conf 文件提取到 ConfigMap,然后將其掛載到 pod 中。
一個例子可以在這里找到。
然后,您可以在需要更新 nginx 配置時編輯 ConfigMap。 請記住重新部署 Pod 以使配置生效。
是的,似乎這也有效。 嘗試了另一種方法:
在 ingress.yaml 中編輯/添加要更改的屬性並重新部署它。 然后更改將反映在 nginx.conf
正如 CrowDev 所提到的,像這樣更新 Nginx controller 的配置並不是一個好習慣。
Nginx controller is the backend of the ingress you can use the config map to update the configuration of the Nginx controller and redeploy the pod of the controller.
一些Nginx controller配置也可以使用入口配置和其中的注釋覆蓋。
您可以在此處閱讀有關注釋的更多信息: https://docs.nginx.com/nginx-ingress-controller/configuration/ingress-resources/advanced-configuration-with-annotations/
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.