简体   繁体   中英

How can i create mutiple nginx ingress controller in kubernetes

I have 2 namespaces in my kubernetes cluster, one called first-nginx and the other called second-nginx . I am using the chart ingress-nginx .. NOT the stable/nginx-ingress as that is now deprecated.

I am attemtping to install multiple nginx controllers, because i need them to be exposed by an already created static ip in GKE. I have successfully installed my first chart in the first-nginx namespace like this

helm install nginx-ingress ingress-nginx/ingress-nginx --namespace first-nginx --set ingress-class="nginx-devices --set controller.service.loadBalancerIP={first-IP-address}"

I am now attempting to do the same with in the second namespace like this

helm install nginx-ingress-2 ingress-nginx/ingress-nginx --namespace second-nginx --set ingress-class="nginx-devices --set controller.service.loadBalancerIP={second-IP-address}"

However i get an error as shown below.

Error: rendered manifests contain a resource that already exists. Unable to continue with install: IngressClass "nginx" in namespace "" exists and cannot be imported into the current release: invalid ownership metadata; annotation validation error: key "meta.helm.sh/release-name" must equal "nginx-ingress-2": current value is "nginx-ingress"; annotation validation error: key "meta.helm.sh/release-namespace" must equal "second-nginx": current value is "first-nginx"

How do i solve this ? This seems to work when i use the stable/nginx-ingress chart where i can do something like this helm install nginx-ingress-devices stable/nginx-ingress --namespace second-nginx --set controller.ingressClass="nginx-devices"

How do i acheive the same thing with the ingress-nginx

您应该使用controller.ingressClassResource.name为它们设置不同的入口类名称

You need to define additional controller.ingressClassResource.controllerValue for the second ingress-nginx, so that when an ingress resource refer to this class, it knows which controller to engage.

helm install nginx-ingress-devices ingress-nginx/ingress-nginx  \
  --namespace second-nginx \
  --set controller.ingressClassResource.name=second-nginx \
  --set controller.ingressClassResource.controllerValue="k8s.io/second-nginx" \
  --set controller.ingressClassResource.enabled=true \
  --set controller.ingressClassByName=true

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM