在Ingress资源文件中为pathType字段指定值,例如:
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: example-ingress
annotations:
nginx.ingress.kubernetes.io/rewrite-target: /
spec:
rules:
- http:
paths:
- path: /example
pathType: Prefix
backend:
service:
name: example-service
port:
name: http
在上面的yaml示例中,为了指定pathType,需要在paths字段下为每个路径定义一个类型,这里采用的是Prefix类型。这样就可以解决该错误。