微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

修补入口资源不返回任何变化

如何解决修补入口资源不返回任何变化

我有 2 个 helm 部署(node-app-blue-helm-chart node-app-green-helm-chart),我的入口资源是独立的,如下所示:

apiVersion: extensions/v1beta1
kind: Ingress
Metadata:
  name: ingress-resource
  annotations:
    kubernetes.io/ingress.class: Nginx
    Nginx.ingress.kubernetes.io/ssl-redirect: "false"
spec:
  rules:
  - http:
      paths:
      - path: /
        backend:
          serviceName: node-app-blue-helm-chart
          servicePort: 80

尝试使用以下命令修补入口资源:

kubectl patch ingress ingress-resource --type=json \
  -p='[{"op": "replace","path": "/spec/rules/0/http/paths/0/backend/serviceName","value":"node-app-green-helm-chart"}]'

不返回任何变化:

ingress.networking.k8s.io/ingress-resource patched (no change)

描述资源:

$ kubectl describe ingress ingress-resource
Name:             ingress-resource
Namespace:        default
Address:          -----
Default backend:  default-http-backend:80 (10.72.0.6:8080)
Rules:
  Host        Path  Backends
  ----        ----  --------
  *           
              /   node-app-blue-helm-chart:80 (10.72.0.46:80)
Annotations:  kubernetes.io/ingress.class: Nginx
              Nginx.ingress.kubernetes.io/ssl-redirect: false
Events:       <none>

缺少什么?

解决方法

serviceName 不是最近的表示。将其更改为服务/名称修复了问题。

$ kubectl patch ingress ingress-resource --type=json \
  -p='[{"op": "replace","path": "/spec/rules/0/http/paths/0/backend/service/name","value":"node-app-green-helm-chart"}]'
ingress.networking.k8s.io/ingress-resource patched

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。