【问题标题】:Kubernetes (OpenShift) ???? kubectl (oc - OpenShift CLI) `patch` return the error: cannot unmarshal array into Go value of type map[string]interface {}Kubernetes (OpenShift) ???? kubectl (oc - OpenShift CLI) `patch` 返回错误:无法将数组解组为 map[string]interface {} 类型的 Go 值
【发布时间】:2021-01-05 05:23:28
【问题描述】:

我尝试patchservice(添加端口声明):

kind: Service
apiVersion: v1
metadata:
  name: istio-ingressgateway
  namespace: istio-system
  labels:
    app: istio-ingressgateway
    istio: ingressgateway
    release: istio
spec:
  ports:
    - name: status-port
      protocol: TCP
      port: 15021
      targetPort: 15021
      nodePort: 30805
    - name: http2
      protocol: TCP
      port: 80
      targetPort: 8080
      nodePort: 32130
    - name: https
      protocol: TCP
      port: 443
      targetPort: 8443
      nodePort: 30720
    - name: tls
      protocol: TCP
      port: 15443
      targetPort: 15443
      nodePort: 31202
  selector:
    app: istio-ingressgateway
    istio: ingressgateway
  clusterIP: 172.30.62.239
  type: LoadBalancer
  sessionAffinity: None
  externalTrafficPolicy: Cluster
status:
  loadBalancer: {}

使用kubectloc patch-command

kubectl patch service istio-ingressgateway -n istio-system --patch - <<EOF
spec:
  ports:
    - name: gw
      protocol: TCP
      port: 3080
      targetPort: 3080
      nodePort: 31230
EOF

,但得到一个错误

Error from server (BadRequest): json: cannot unmarshal array into Go value of type map[string]interface {}

??????????在引擎盖下,k8s/openshift 使用 GoLang 解析 yaml ????我试图在go 中找到相同的解决方案 - 失败...

怎么了?

【问题讨论】:

    标签: go kubernetes yaml openshift kubectl


    【解决方案1】:

    尝试使用jsonpatch

    oc patch service/simple-server -p \
    '{ "spec": { "ports": [ { "name": "gw", "protocol": "TCP", "port": 1234,"targetPort": 1234 } ] } }'
    

    【讨论】:

      猜你喜欢
      • 2018-08-19
      • 2022-01-24
      • 1970-01-01
      • 2021-10-15
      • 1970-01-01
      • 1970-01-01
      • 2018-05-23
      • 1970-01-01
      • 2020-04-29
      相关资源
      最近更新 更多