io.k8s.api.networking.v1 中的 Kubernetes ingres.yml 未知字段 "service.port.number"

Kubernetes ingres.yml unknown field "service.port.number" in io.k8s.api.networking.v1

我 运行 遇到了 ingress.yml 的问题。收到此错误:

error: error validating "ingress.yml": error validating data: [ValidationError(Ingress.spec.rules[0].http.paths[0].backend): unknown field "service.name" in io.k8s.api.networking.v1.IngressBackend, ValidationError(Ingress.spec.rules[0].http.paths[0].backend): unknown field "service.port.number" in io.k8s.api.networking.v1.IngressBackend, ValidationError(Ingress.spec.rules[0].http.paths[1].backend): unknown field "service.name" in io.k8s.api.networking.v1.IngressBackend, ValidationError(Ingress.spec.rules[0].http.paths[1].backend): unknown field "service.port.number" in io.k8s.api.networking.v1.IngressBackend];

在此基础上 documentation serviceName 改为 service.name servicePort 改为 service.port 等等。这是入口文件:

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: bitwarden
  namespace: bitwarden
  labels:
    app: bitwarden
  annotations:
    # the name of the nginx-ingress-controller class
    kubernetes.io/ingress.class: nginx
    nginx.ingress.kubernetes.io/configuration-snippet: |
      more_set_headers "Request-Id: $req_id";
    nginx.ingress.kubernetes.io/connection-proxy-header: "keep-alive"
    nginx.ingress.kubernetes.io/enable-cors: "true"
    nginx.ingress.kubernetes.io/force-ssl-redirect: "true"
    nginx.ingress.kubernetes.io/limit-connections: "25"
    nginx.ingress.kubernetes.io/limit-rps: "15"
    nginx.ingress.kubernetes.io/proxy-body-size: 1024m
    nginx.ingress.kubernetes.io/proxy-connect-timeout: "10"
    nginx.ingress.kubernetes.io/proxy-send-timeout: "1800"
    nginx.ingress.kubernetes.io/proxy-read-timeout: "1800"
    nginx.ingress.kubernetes.io/ssl-redirect: "true"
    cert-manager.io/cluster-issuer: "letsencrypt-prod"
spec:
  tls:
  - hosts:
    - kryskanbit.ddns.net
    secretName: bitwarden-tls
  rules:
  - host: kryskanbit.ddns.net
    http:
      paths:
      - path: /
        pathType: Prefix
        backend:
          service.name: bitwarden
          service.port.number: 80
      - path: /notifications/hub
        pathType: Exact
        backend:
          service.name: bitwarden
          service.port.number: 3012

Kubernetes 对 YAML 格式有特殊处理,所以基本上,您只需要单独扩展属性 service.nameservice.port.number:

...
        paths:
          - path: /
            pathType: Prefix
            backend:
              service:
                name: bitwarden
                port:
                  number: 80
          - path: /notifications/hub
            pathType: Exact
            backend:
              service:
                name: bitwarden
                port:
                  number: 3012

应该如下所示:

backend:
    serviceName: bitwarden
    servicePort: 80