返回顶部

记一次nginx.ingress.kubernetes.io/configuration-snippet报错

记一次nginx.ingress.kubernetes.io/configuration-snippet报错

在迁移xxl-job到k8s集群中,报错one or more objects failed to apply, reason: admission webhook "validate.nginx.ingress.kubernetes.io" denied the request: nginx.ingress.kubernetes.io/configuration-snippet annotation cannot be used. Snippet directives are disabled by the Ingress administrator

报错的配置如下

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  annotations:
    kubernetes.io/ingress.class: pro-ingress-intranet
    myname: xiaowangtech
    nginx.ingress.kubernetes.io/configuration-snippet: |
      if ($request_uri = "/") {
        return 302 /xxl-job-admin;
      }    
  labels:
    app.kubernetes.io/instance: pro-xxl-job-admin
  name: pro-xxl-job-admin-ingress
  namespace: pro
spec:
  rules:
    - host: job-pro.wei.com
      http:
        paths:
          - backend:
              service:
                name: pro-xxl-job-admin-svc
                port:
                  number: 8080
            path: /
            pathType: ImplementationSpecific
  tls:
    - hosts:
        - job-pro.wei.com
      secretName: xiaowangtech-com

分析报错

根据报错信息可知,是没开放nginx.ingress.kubernetes.io/configuration-snippet配置,则在kube-system修改ingress-nginx-controller配置为true即可

 解决报错

kubectl edit cm -n kube-system pro-ingress-intranet-ingress-nginx-controller

 

 

再次执行yaml文件发现ingress.yaml已创建成功,状态正常

 

posted @ 2023-09-18 22:45  九尾cat  阅读(1607)  评论(0编辑  收藏  举报