ingress-nginx pod 明明在ingress-nginx 的namespace,而 ingress 的yaml部署到 其它ns中,更改ingress 中的定义文件,为啥对应host的 ingress-nginx pod的配置文件会更改。
这两个东西明明不在一个namespace下,怎么做到的。
在k8s 的ingress 的 Multiple Ingress controllers 中,有说明:
To reiterate, setting the annotation to any value which does not match a valid ingress class will force the NGINX Ingress controller to ignore your Ingress. If you are only running a single NGINX ingress controller, this can be achieved by setting the annotation to any value except "nginx" or an empty string.
Do this if you wish to use one of the other Ingress controllers at the same time as the NGINX controller.
【重申一下,将注释设置为与有效的Ingress类不匹配的任何值都将迫使NGINX Ingress控制器忽略您的Ingress。 如果仅运行单个NGINX入口控制器,则可以通过将注释设置为除“ nginx”或空字符串以外的任何值来实现。如果您希望与NGINX控制器同时使用其他Ingress控制器之一,请执行此操作。】
This mechanism also provides users the ability to run multiple NGINX ingress controllers (e.g. one which serves public traffic, one which serves "internal" traffic). To do this, the option --ingress-class must be changed to a value unique for the cluster within the definition of the replication controller. Here is a partial example:
spec: template: spec: containers: - name: nginx-ingress-internal-controller args: - /nginx-ingress-controller - '--ingress-class=nginx-internal' - '--configmap=ingress/nginx-ingress-internal-controller'
Deploying multiple Ingress controllers, of different types (e.g., ingress-nginx & gce), and not specifying a class annotation will result in both or all controllers fighting to satisfy the Ingress, and all of them racing to update Ingress status field in confusing ways.
When running multiple ingress-nginx controllers, it will only process an unset class annotation if one of the controllers uses the default --ingress-class value (see IsValid method in internal/ingress/annotations/class/main.go), otherwise the class annotation become required.
If --ingress-class is set to the default value of nginx, the controller will monitor Ingresses with no class annotation and Ingresses with annotation class set to nginx. Use a non-default value for --ingress-class, to ensure that the controller only satisfied the specific class of Ingresses.
如果将--ingress-class设置为“nginx” 默认值,则控制器将监视没有类注释的Ingress和将注释类设置为“nginx”的Ingress。 为入口类使用非默认值,以确保控制器仅满足特定的Ingress类。
ingress-nginx 注解说明,
意思是如果kubernetes.io/ingress.class: nginx 或不加这个,ingress-nginx的控制器 会监视ingress 活动,上面问题是,只要有kubernetes.io/ingress.class: 设置为nginx或不设置,nginx控制器会监视ingress的变化。如果不是这两个值,则ingress-nginx将不起作用。
https://kubernetes.github.io/ingress-nginx/user-guide/nginx-configuration/annotations/
POD_NAMESPACE=ingress-nginxPOD_NAME=$(kubectl get pods -n $POD_NAMESPACE -l app.kubernetes.io/name=ingress-nginx --field-selector=status.phase=Running -o jsonpath='{.items[0].metadata.name}')kubectl exec -it $POD_NAME -n $POD_NAMESPACE -- /nginx-ingress-controller --version
如果觉得我的文章对您有用,请随意打赏。你的支持将鼓励我继续创作!