Nginx 库伯内特斯入口-AKS
我遵循了本文中提到的步骤,为了在Nginx 库伯内特斯入口-AKS,nginx,kubernetes,azure-aks,Nginx,Kubernetes,Azure Aks,我遵循了本文中提到的步骤,为了在azure中安装它,我运行了以下步骤 kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/master/deploy/static/provider/cloud/deploy.yaml 我打开了该文件,在#Source:ingres nginx/templates/controller deployment.yaml一节下,我可以看到参考资料,是否有办法覆盖此设置
azure
中安装它,我运行了以下步骤
kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/master/deploy/static/provider/cloud/deploy.yaml
我打开了该文件,在#Source:ingres nginx/templates/controller deployment.yaml
一节下,我可以看到参考资料
,是否有办法覆盖此设置,并为入口设置cpu
和内存限制,同时我想知道其中的所有内容是否都可自定义。注释建议(下载文件并手动覆盖或使用helm chart)或者使用kubectl edit deployment xxx
并设置这些限制\请求
我想知道那里的一切是否都是可定制的
几乎所有东西都是可定制的,但请记住,您必须确切地知道您正在更改什么,否则它可能会破坏您的入口
有没有办法覆盖该入口并设置该入口的cpu和内存限制
除了在部署前下载和编辑文件之外,您还可以通过以下三种方式在运行时对其进行自定义:
- edit命令允许您直接编辑任何可以通过命令行工具检索的API资源李>
- 它将打开KUBE_编辑器或编辑器环境变量定义的编辑器,或返回到Linux的“vi”或Windows的“记事本”
- 您可以编辑多个对象,但每次只应用一个更改。
例如:
这是打开文件中提到的部署的命令。如果你做了一个无效的更改,它将不会应用,并将保存到一个临时文件中,所以请记住使用它,如果它不应用,你会更改一些你不喜欢的结构
使用yaml文件:
- 使用策略合并修补程序、JSON合并修补程序或JSON修补程序更新资源的字段
- 接受JSON和YAML格式
创建一个名为patch nginx.yaml
的简单文件,其中包含最少的以下内容(您希望更改的参数及其结构):
命令结构是:kubectl patch-n--patch“$(cat)”
以下是一个完整的示例:
$ kubectl patch deployment ingress-nginx-controller -n ingress-nginx --patch "$(cat patch-nginx.yaml)"
deployment.apps/ingress-nginx-controller patched
$ kubectl describe deployment ingress-nginx-controller -n ingress-nginx | grep cpu
cpu: 111m
$ kubectl describe deployment ingress-nginx-controller -n ingress-nginx | grep memory
memory: 99Mi
Kubectl:
- 这是一个单行程序版本,它遵循与yaml版本相同的结构,但我们将在json结构中传递参数:
如果您有任何疑问,请在评论中告诉我。您可以下载该文件并手动覆盖它或使用头盔图表?从未使用过helm
,因为我对所有这些都是新手,以这种方式设置与使用单独的nginx
pod之间有很大区别吗?您可能想使用helm=>部署kube相关资源非常方便。我添加了一个更详细的答案,希望对您有所帮助!
spec:
template:
spec:
containers:
- name: controller
resources:
requests:
cpu: 111m
memory: 99Mi
$ kubectl patch deployment ingress-nginx-controller -n ingress-nginx --patch "$(cat patch-nginx.yaml)"
deployment.apps/ingress-nginx-controller patched
$ kubectl describe deployment ingress-nginx-controller -n ingress-nginx | grep cpu
cpu: 111m
$ kubectl describe deployment ingress-nginx-controller -n ingress-nginx | grep memory
memory: 99Mi
$ kubectl patch deployment ingress-nginx-controller -n ingress-nginx --patch '{"spec":{"template":{"spec":{"containers":[{"name":"controller","resources":{"requests":{"cpu":"122m","memory":"88Mi"}}}]}}}}'
deployment.apps/ingress-nginx-controller patched
$ kubectl describe deployment ingress-nginx-controller -n ingress-nginx | grep cpu
cpu: 122m
$ kubectl describe deployment ingress-nginx-controller -n ingress-nginx | grep memory
memory: 88Mi