You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Kubernetes 1.23.11安装ingress-nginx 3.16.1失败求助

问题描述

在Kubernetes 1.23版本中安装ingress-nginx 3.16.1版本时启动失败,该操作此前在Kubernetes 1.22.x版本可正常执行。执行的Helm命令如下:

helm repo add ingress-nginx https://kubernetes.github.io/ingress-nginx
    
helm install nginx-ingress ingress-nginx/ingress-nginx  --version 3.16.1 --kube-context test-context --namespace=internal-namespace

控制器容器日志报错核心内容:

E0110 13:29:40.707682       8 reflector.go:127] k8s.io/client-go@v0.19.3/tools/cache/reflector.go:156: Failed to watch *v1beta1.Ingress: failed to list *v1beta1.Ingress: the server could not find the requested resource

完整日志:

I0110 13:29:40.707682       8 nginx.go:249] "Starting NGINX Ingress controller"
E0110 13:29:40.707682       8 reflector.go:127] k8s.io/client-go@v0.19.3/tools/cache/reflector.go:156: Failed to watch *v1beta1.Ingress: failed to list *v1beta1.Ingress: the server could not find the requested resource
E0110 13:29:41.998518       8 reflector.go:127] k8s.io/client-go@v0.19.3/tools/cache/reflector.go:156: Failed to watch *v1beta1.Ingress: failed to list *v1beta1.Ingress: the server could not find the requested resource
E0110 13:29:45.088906       8 reflector.go:127] k8s.io/client-go@v0.19.3/tools/cache/reflector.go:156: Failed to watch *v1beta1.Ingress: failed to list *v1beta1.Ingress: the server could not find the requested resource
E0110 13:29:50.400838       8 reflector.go:127] k8s.io/client-go@v0.19.3/tools/cache/reflector.go:156: Failed to watch *v1beta1.Ingress: failed to list *v1beta1.Ingress: the server could not find the requested resource
E0110 13:29:58.087390       8 reflector.go:127] k8s.io/client-go@v0.19.3/tools/cache/reflector.go:156: Failed to watch *v1beta1.Ingress: failed to list *v1beta1.Ingress: the server could not find the requested resource
E0110 13:30:11.090674       8 reflector.go:127] k8s.io/client-go@v0.19.3/tools/cache/reflector.go:156: Failed to watch *v1beta1.Ingress: failed to list *v1beta1.Ingress: the server could not find the requested resource
I0110 13:30:38.827033       8 main.go:187] "Received SIGTERM, shutting down"
I0110 13:30:38.827071       8 nginx.go:365] "Shutting down controller queues"
E0110 13:30:38.827377       8 store.go:178] timed out waiting for caches to sync
I0110 13:30:38.827413       8 nginx.go:291] "Starting NGINX process"
I0110 13:30:38.827673       8 leaderelection.go:243] attempting to acquire leader lease  ingress-namespace/ingress-controller-leader-nginx...
I0110 13:30:38.827953       8 queue.go:78] "queue has been shutdown, failed to enqueue" key="&ObjectMeta{Name:initial-sync,GenerateName:,Namespace:,SelfLink:,UID:,ResourceVersion:,Generation:0,CreationTimestamp:0001-01-01 00:00:00 +0000 UTC,DeletionTimestamp:<nil>,DeletionGracePeriodSeconds:nil,Labels:map[string]string{},Annotations:map[string]string{},OwnerReferences:[],Finalizers:[],ManagedFields:[]ManagedFieldsEntry{},}"
I0110 13:30:38.827981       8 nginx.go:311] "Starting validation webhook" address=":8443" certPath="/usr/local/certificates/cert" keyPath="/usr/local/certificates/key"
I0110 13:30:38.839596       8 status.go:84] "New leader elected" identity="nginx-ingress-ingress-nginx-controller-84bcfb76c7-q82gh"
I0110 13:30:38.848733       8 status.go:131] "removing value from ingress status" address=[20.227.15.7]
I0110 13:30:38.848778       8 nginx.go:373] "Stopping admission controller"
I0110 13:30:38.848815       8 nginx.go:381] "Stopping NGINX process"
E0110 13:30:38.848912       8 nginx.go:314] "Error listening for TLS connections" err="http: Server closed"
2023/01/10 13:30:38 [notice] 44#44: signal process started
I0110 13:30:39.853244       8 nginx.go:394] "NGINX process has stopped"
I0110 13:30:39.853269       8 main.go:195] "Handled quit, awaiting Pod deletion"
I0110 13:30:49.853602       8 main.go:198] "Exiting" code=0
问题原因与解决方案

原因

Kubernetes 1.23彻底移除了networking.k8s.io/v1beta1和extensions/v1beta1版本的Ingress API,而ingress-nginx 3.16.1依赖的client-go v0.19.3仍在尝试调用这些已废弃的API,导致集群无法识别请求的资源,最终控制器启动超时退出。

解决方法

方法一:升级ingress-nginx到兼容版本

选择与Kubernetes 1.23匹配的ingress-nginx版本,推荐使用4.0.0及以上版本,该版本已全面适配networking.k8s.io/v1 Ingress API。

安装新兼容版本:

helm repo update
helm install nginx-ingress ingress-nginx/ingress-nginx --version 4.0.0 --kube-context test-context --namespace=internal-namespace

如果已有旧版本需要迁移,先导出旧配置再升级:

# 导出现有配置
helm get values nginx-ingress --namespace=internal-namespace > ingress-values.yaml
# 升级到兼容版本
helm upgrade nginx-ingress ingress-nginx/ingress-nginx --version 4.0.0 --values ingress-values.yaml --kube-context test-context --namespace=internal-namespace

方法二:临时启用废弃API(不推荐)

如果无法立即升级ingress-nginx,可在K8s集群的kube-apiserver组件中启用IngressV1beta1特性门控,但该方案仅为临时过渡,后续K8s版本会彻底移除相关支持,存在兼容性风险。

内容的提问来源于stack exchange,提问作者user18230166

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.05 12:05:22