Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sample/ingress.yaml在k8s v1.22.4版本中配置失效 #182

Open
FlowerBirds opened this issue Dec 15, 2021 · 0 comments
Open

sample/ingress.yaml在k8s v1.22.4版本中配置失效 #182

FlowerBirds opened this issue Dec 15, 2021 · 0 comments

Comments

@FlowerBirds
Copy link

示例中yaml:

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: example-ingress
  annotations:
    ingress.kubernetes.io/rewrite-target: /
spec:
  rules:
  - http:
      paths:
        - path: /apple
          pathType: Exact
          backend:
            service:
              name: apple-service
              port:
                number: 5678
        - path: /banana
          pathType: Exact
          backend:
            service:
              name: banana-service
              port: 
                number: 5678

实际访问中全部为404,无法访问http://localhost/apple地址。 查看NGINX Ingress(https://kubernetes.github.io/ingress-nginx/user-guide/basic-usage/) 文档如下:

If cluster version >= 1.19 the Ingress resource above will not work, instead of annotations you should use the new ingressClassName: nginx property.

修改yaml,添加ingressClassName: nginx属性,如下:

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: example-ingress
  annotations:
    ingress.kubernetes.io/rewrite-target: /
spec:
  ingressClassName: nginx
  rules:
  - http:
      paths:
        - path: /apple
          pathType: Exact
          backend:
            service:
              name: apple-service
              port:
                number: 5678
        - path: /banana
          pathType: Exact
          backend:
            service:
              name: banana-service
              port: 
                number: 5678

访问成功

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant