kubernetes k8s v1上入口端点,26.3

f4t66c6m  于 2023-04-29  发布在  Kubernetes
关注(0)|答案(2)|浏览(150)

尝试在k8s v1上创建入口端点时出错。26.3.我使用kops创建了一个k8s集群。
服务器出错
(BadRequest):创建“入口”时出错。yaml”:版本“v1”中的Ingress不能作为Ingress处理:严格解码错误:未知字段”规范。rules[0]. http.paths[0].backend.serviceName”,未知字段“规范。rules[0]. http.paths[0].backend.服务端口”

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  labels:
    env: prod
    app: demo-ms
    layer: frontend
  name: prod-demo-ingress
  namespace: prod
  annotations:
    nginx.ingress.kubernetes.io/rewrite-target: /
spec:
  rules:
    - host: demo.abc.in
      http:
        paths:
          - backend:
              serviceName: prod-demo-service
              servicePort: 8080
            path: /
~~~
3yhwsihp

3yhwsihp1#

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: prod-demo-ingress
  namespace: prod
  labels:
    env: prod
    app: demo-ms
    layer: frontend
  annotations:
    nginx.ingress.kubernetes.io/rewrite-target: /
spec:
  rules:
    - host: demo.abc.in
      http:
        paths:
          - pathType: Prefix
            path: "/"
            backend:
              service:
                name: prod-demo-service
                port:
                  number: 8080
ukdjmx9f

ukdjmx9f2#

您使用的是较旧的ingress YAML配置和最新的API,这是最新的stable

serviceNameservicePortnetworking.k8s.io/v1beta1的一部分

您可能更新了apiVersion,但忘记更新其他字段
最新配置

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: minimal-ingress
  annotations:
    nginx.ingress.kubernetes.io/rewrite-target: /
spec:
  ingressClassName: nginx-example
  rules:
  - host: demo.abc.in
    http:
      paths:
      - path: /testpath
        pathType: Prefix
        backend:
          service:
            name: test
            port:
              number: 80

参考文档:https://kubernetes.io/docs/concepts/services-networking/ingress/

相关问题