<p>I try to <code>patch</code> a <code>service</code> (add port declaration):</p>
<pre><code>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: {}
</code></pre>
<p>using <code>kubectl</code> or <code>oc</code> <code>patch</code>-command</p>
<pre><code>kubectl patch service istio-ingressgateway -n istio-system --patch - &lt;&lt;EOF
spec:
  ports:
    - name: gw
      protocol: TCP
      port: 3080
      targetPort: 3080
      nodePort: 31230
EOF
</code></pre>
<p>, but get an error</p>
<pre><code>Error from server (BadRequest): json: cannot unmarshal array into Go value of type map[string]interface {}
</code></pre>
<p>👉🏻 under the hood, <code>k8s/openshift</code> use <code>GoLang</code> to parse <code>yaml</code> 👉 I tried to find same solutions in <code>go</code> - failed...</p>
<p>What's wrong?</p>

kozmo
<p>try to use <code>json</code> to <code>patch</code></p>
<pre><code>oc patch service/simple-server -p \
'{ &quot;spec&quot;: { &quot;ports&quot;: [ { &quot;name&quot;: &quot;gw&quot;, &quot;protocol&quot;: &quot;TCP&quot;, &quot;port&quot;: 1234,&quot;targetPort&quot;: 1234 } ] } }'
</code></pre>
