Nginx入口不再工作(Kubernetes)

iklwldmw  于 2023-08-03  发布在  Kubernetes
关注(0)|答案(1)|浏览(124)

我遇到了一个问题,我们的nginx入口不再正常工作。我们遇到了一个问题,其中一个工作节点出现故障,并最终驱逐了大量的ingress pod。我们创建了一个新的worker节点,并且重新创建了pod,没有出现任何错误。当我检查nginx-ingress pod的日志时,我得到的错误如下:

W0731 18:11:20.640729       1 warnings.go:70] networking.k8s.io/v1beta1 Ingress is deprecated in v1.19+, unavailable in v1.22+; use networking.k8s.io/v1 Ingress
E0731 18:11:26.533749       1 reflector.go:138] /home/runner/work/kubernetes-ingress/kubernetes-ingress/internal/k8s/controller.go:574: Failed to watch *v1.Policy: failed to list *v1.Policy: the server could not find the requested resource (get policies.k8s.nginx.org)
E0731 18:11:31.778992       1 reflector.go:138] /home/runner/work/kubernetes-ingress/kubernetes-ingress/internal/k8s/controller.go:571: Failed to watch *v1.VirtualServer: failed to list *v1.VirtualServer: the server could not find the requested resource (get virtualservers.k8s.nginx.org)
E0731 18:11:51.190680       1 reflector.go:138] /home/runner/work/kubernetes-ingress/kubernetes-ingress/internal/k8s/controller.go:572: Failed to watch *v1.VirtualServerRoute: failed to list *v1.VirtualServerRoute: the server could not find the requested resource (get virtualserverroutes.k8s.nginx.org)
E0731 18:11:59.259723       1 reflector.go:138] /home/runner/work/kubernetes-ingress/kubernetes-ingress/internal/k8s/controller.go:574: Failed to watch *v1.Policy: failed to list *v1.Policy: the server could not find the requested resource (get policies.k8s.nginx.org)
E0731 18:12:11.070691       1 reflector.go:138] /home/runner/work/kubernetes-ingress/kubernetes-ingress/internal/k8s/controller.go:573: Failed to watch *v1alpha1.TransportServer: failed to list *v1alpha1.TransportServer: the server could not find the requested resource (get transportservers.k8s.nginx.org)
E0731 18:12:26.943999       1 reflector.go:138] /home/runner/work/kubernetes-ingress/kubernetes-ingress/internal/k8s/controller.go:571: Failed to watch *v1.VirtualServer: failed to list *v1.VirtualServer: the server could not find the requested resource (get virtualservers.k8s.nginx.org)

字符串
我们当前的入口看起来像这样:

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: dev-ingress
  namespace: dev-namespace
  annotations:
    kubernetes.io/ingress.class: nginx
    nginx.ingress.kubernetes.io/affinity: "cookie"
    nginx.ingress.kubernetes.io/session-cookie-name: "route"
    nginx.ingress.kubernetes.io/session-cookie-expires: "172800"
    nginx.ingress.kubernetes.io/session-cookie-max-age: "172800"
    nginx.ingress.kubernetes.io/proxy-body-size: "0"
    nginx.ingress.kubernetes.io/proxy-read-timeout: "900"
    nginx.ingress.kubernetes.io/proxy-send-timeout: "900"
    nginx.ingress.kubernetes.io/proxy-buffer-size: "256k"
    nginx.ingress.kubernetes.io/proxy-buffers: "4 256k"
    nginx.ingress.kubernetes.io/server-snippet: client_header_buffer_size 256k
    nginx.ingress.kubernetes.io/server-snippet: large_client_header_buffers 4 256k;
    nginx.org/websocket-services: "contoso-service,sbase-service"
    nginx.ingress.kubernetes.io/configuration-snippet: |
        proxy_http_version 1.1;
        proxy_set_header Upgrade "websocket";
        proxy_set_header Connection "Upgrade";
spec:
  tls:
  - secretName: tls2023
    hosts:
      - sbasedev.net
      - contosodev.net
  rules:
  - host: sbasedev.net
    http:
      paths:
      - backend:
          serviceName: sbase-service
          servicePort: 80


对于上下文,我们正在运行的Kubernetes版本是v1.12.0。当我检查Pod中的nginx版本时,运行的版本是1.19.6。
我尝试删除和重新创建pod,但发生了同样的错误。此配置被确认有效,直到nginx pod被驱逐并重新创建。

p1iqtdky

p1iqtdky1#

在检查错误消息时,似乎您的Ingress资源正在使用v1.19中弃用的弃用API版本networking.k8s.io/v1beta1,并且Ingress Controller无法找到所需的CRD。您应该更新您的入口资源以使用networking.k8s.io/v1 API版本并安装缺少的CRD。以下是对您的用例有帮助的文档。[1][2][3]
[1][https://kubernetes.io/blog/2020/04/02/improvements-to-the-ingress-api-in-kubernetes-1.18/](https://kubernetes.io/blog/2020/04/02/improvements-to-the-ingress-api-in-kubernetes-1.18/)的
[2][https://kubernetes.io/docs/reference/kubectl/cheatsheet/](https://kubernetes.io/docs/reference/kubectl/cheatsheet/)的
[3][https://docs.nginx.com/nginx-ingress-controller/installation/installation-with-manifests/](https://docs.nginx.com/nginx-ingress-controller/installation/installation-with-manifests/)的

相关问题