入口不断变化的ip



我在AKS集群中有3个入口命名空间。一个是标准入口部署文件,另外两个是原始文件的内部和外部修改版本。所以现在我有3个入口ip和3个外部ip(其中一个是内部ip,添加了服务注释,这一行是service。beta。kubernetes。io/azure-load-balancer-internal:"true"

$ kubectl get svc -A
external-ingress   ingress-nginx-controller             LoadBalancer   10.245.57.76     3.3.3.3   80:32112/TCP,443:31761/TCP   3h24m
external-ingress   ingress-nginx-controller-admission   ClusterIP      10.245.28.35     <none>    443/TCP                      3h24m
ingress-nginx      ingress-nginx-controller             LoadBalancer   10.245.12.12     1.1.1.1   80:31716/TCP,443:32023/TCP   40m
ingress-nginx      ingress-nginx-controller-admission   ClusterIP      10.245.110.233   <none>    443/TCP                      40m
internal-ingress   ingress-nginx-controller             LoadBalancer   10.245.173.35    2.2.2.2   80:32567/TCP,443:30296/TCP   3h25m
internal-ingress   ingress-nginx-controller-admission   ClusterIP      10.245.39.250    <none>    443/TCP                      3h25m

我想使用两个入口,但它不工作,因为我认为。我试着用"ingressClassName:";

$ kubectl get ing -w
NAME               CLASS              HOSTS         ADDRESS   PORTS     AGE
external-ingress   nginx              test.io       1.1.1.1   80, 443   3h4m
internal-ingress   internal-ingress   admin.test.io 1.1.1.1   80        3h4m
external-ingress   nginx              test.io       2.2.2.2   80, 443   3h5m
external-ingress   nginx              test.io       3.3.3.3   80, 443   3h5m
external-ingress   nginx              test.io       1.1.1.1   80, 443   3h5m
external-ingress   nginx              test.io       2.2.2.2   80, 443   3h6m
external-ingress   nginx              test.io       3.3.3.3   80, 443   3h6m
external-ingress   nginx              test.io       1.1.1.1   80, 443   3h6m
external-ingress   nginx              test.io       2.2.2.2   80, 443   3h7m
external-ingress   nginx              test.io       3.3.3.3   80, 443   3h7m
external-ingress   nginx              test.io       1.1.1.1   80, 443   3h7m
external-ingress   nginx              test.io       2.2.2.2   80, 443   3h8m
external-ingress   nginx              test.io       3.3.3.3   80, 443   3h8m

当我改变"ingressClassName: nginx"外部IP不断变化。当我更改了&;ingressClassName: external-ingress&;IP有时会变,有时不会变……和陈的时候不工作. .

原始部署文件

kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/controller-v1.3.0/deploy/static/provider/cloud/deploy.yaml

我创建了一个外部入口和内部入口,文件更改为"ingress-nginx"行到"internal-nginx";和"external-nginx".

为什么ip不断变化?

如果入口资源定期更改外部ip,这表明集群中有多个入口控制器,并且没有在入口资源上指定入口类。

因此,集群中的所有入口控制器(没有限制到名称空间)将尝试"战斗"。为了管理通过该入口的流量,每次获胜的控制器都会将入口的IP设置为自己的负载均衡器IP。

这就是为什么您看到入口的IP更改为1.1.1.1,2.2.2.23.3.3.3,因为这些是您在集群中安装的入口控制器,如您的代码片段所示:

$ kubectl get svc -A
external-ingress   ingress-nginx-controller             LoadBalancer   10.245.57.76     3.3.3.3   80:32112/TCP,443:31761/TCP   3h24m
external-ingress   ingress-nginx-controller-admission   ClusterIP      10.245.28.35     <none>    443/TCP                      3h24m
ingress-nginx      ingress-nginx-controller             LoadBalancer   10.245.12.12     1.1.1.1   80:31716/TCP,443:32023/TCP   40m
ingress-nginx      ingress-nginx-controller-admission   ClusterIP      10.245.110.233   <none>    443/TCP                      40m
internal-ingress   ingress-nginx-controller             LoadBalancer   10.245.173.35    2.2.2.2   80:32567/TCP,443:30296/TCP   3h25m
internal-ingress   ingress-nginx-controller-admission   ClusterIP      10.245.39.250    <none>    443/TCP                      3h25m

您可以通过确保将所有入口控制器设置为仅监视特定的入口类和/或限制控制器仅管理特定的命名空间来修复此问题,并确保您的入口资源通过入口类注释和/或ingressClass块指定入口类。

我相信我也犯过同样的错误,并在读完这篇文章后设法找到了解决方案。如果你有类似的kubernetes行为,你可能想试着看看:https://stackoverflow.com/a/76230364/7753261

我的问题是关于IngressClass和Ingress安装部分。不幸的是,我不得不在安装时使用yaml,但后来我不得不卸载和重新安装,所以有一个问题。

从这个过程中得到的教训是使用helm或使用yaml时要小心。