We are using the networking.k8s.io/v1beta1 and we trying to move to networking.k8s.io/v1 with the following changes and my ingress.YAML code looks like this now.
Version:"v1.20.15-gke.2500"
When I applied the "kubectl apply" I got to see the following error, could someone help me why I am facing this error?
error: error validating "ingress.yaml": error validating data: [ValidationError(Ingress.spec.rules[0].http.paths[0].backend.service.port): invalid type for io.k8s.api.networking.v1.ServiceBackendPort: got "integer", expected "map", ValidationError(Ingress.spec.rules[0].http.paths[1].backend.service.port): invalid type for io.k8s.api.networking.v1.ServiceBackendPort: got "integer", expected "map", ValidationError(Ingress.spec.rules[0].http.paths[2].backend.service.port): invalid type for io.k8s.api.networking.v1.ServiceBackendPort: got "integer", expected "map"; if you choose to ignore these errors, turn validation off with --validate=false
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: ***
annotations:
kubernetes.io/ingress.global-static-ip-name: ****
networking.gke.io/managed-certificates: *****
spec:
rules:
- host: ***
http:
paths:
- path: /****/*
pathType: Prefix
backend:
service:
name: *********
port: 50000
- path: /****/*
pathType: Prefix
backend:
service:
name: *********
port: 50000
- path: /****/*
pathType: Prefix
backend:
service:
name: *********
port: 50000
- path: /****/*
pathType: Prefix
backend:
service:
name: *********
port: 50000
- path: /****/*
pathType: Prefix
backend:
service:
name: *********
port: 50000
- path: /****/*
pathType: Prefix
backend:
service:
name: *********
port: 50000
- path: /****/*
pathType: Prefix
backend:
service:
name: *********
port: 50000
- path: /****/*
pathType: Prefix
backend:
service:
name: *********
port: 50000
- host: *********
http:
paths:
- path: /****/*
pathType: Prefix
backend:
service:
name: *********
port: 50000
- path: /****/*
pathType: Prefix
backend:
service:
name: *********
port: 50000
- path: /****/*
pathType: Prefix
backend:
service:
name: *********
port: 50000
CodePudding user response:
You are using incorrect syntax for networking.k8s.io/v1
Ingress. The error is saying that the backend.service.port
is no longer an integer, it expects a map.
In apiVersion: networking.k8s.io/v1beta1
, the backend
section looks like below:
backend:
serviceName: service1
servicePort: 80
Now in apiVersion: networking.k8s.io/v1
:
backend:
service:
name: test
port:
number: 80
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: minimal-ingress
annotations:
nginx.ingress.kubernetes.io/rewrite-target: /
spec:
ingressClassName: nginx-example
rules:
- http:
paths:
- path: /testpath
pathType: Prefix
backend:
service:
name: test
port:
number: 80
CodePudding user response:
You are using the Old format of YAML with API networking.k8s.io/v1 it's updated now.
You can read more here : https://kubernetes.io/docs/concepts/services-networking/ingress/#the-ingress-resource
Change in service port
backend:
service:
name: test
port:
number: 80
Ref YAML block :
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: ingress
spec:
ingressClassName: class-name
rules:
- http:
paths:
- path: /testpath
pathType: Prefix
backend:
service:
name: test
port:
number: 80