Reputation: 16287
I have this ingress object where I am trying to patch the secretName
:
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: hello-world
...
spec:
rules:
- host: my.host
http:
paths:
- backend:
serviceName: hello-world
servicePort: 8080
tls:
- hosts:
- my.host
secretName: my-secret
I would like to update the secret name using kubectl patch
I have tried:
$ kubectl patch ing hello-world -p '{"spec":{"tls":{"secretName":"updated"}}}'
Error from server: cannot restore slice from map
and:
$ kubectl patch ing hello-world -p '[{"op": "replace", "path": "/spec/tls/secretName", "value" : "updated"}]'
Error from server (BadRequest): json: cannot unmarshal array into Go value of type map[string]interface {}
Any suggestions?
Upvotes: 5
Views: 15648
Reputation: 6471
You can update above json array field with following
kubectl patch ing hello-world --type json -p '[{"op": "replace", "path": "/spec/tls/0/secretName", "value" : "updated"}]'
Here, you have to specify the index, in your case it is 0
Upvotes: 4
Reputation: 61571
tls
is an array/slice so you have to refer to it like that and include it in the original patch.
$ kubectl patch ing hello-world -p '{"spec":{"tls":[{"hosts":["my.host"], "secretName": "updated"}]}}'
A good way to get the -p
s right (that works for me) is to convert them from YAML to JSON. You can try an online tool like this.
Upvotes: 5