Skip to content

Instantly share code, notes, and snippets.

@SteveEasley
Last active February 20, 2020 16:53
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save SteveEasley/66e228e4b7159fe3c6d8522868010fff to your computer and use it in GitHub Desktop.
Save SteveEasley/66e228e4b7159fe3c6d8522868010fff to your computer and use it in GitHub Desktop.
Example of patching an existing Kubernetes Ingress with a new rule
This is an example of how to do a JSON Patch (RFC 6902) on an existing Kubernetes Ingress.
I could not get it to work with the Strategic Merge patch method using yaml. It would just
replace all the existing rules.
$ kubectl patch ingress some-ingress --type json -p "$(cat test-patch.json)"
# test-patch.json
[{
"op": "add",
"path": "/spec/rules/-",
"value": {
"host": "www.svc.domain.com",
"http": {
"paths": [
{
"backend": {
"serviceName": "svc-name",
"servicePort": 80
}
}
]
}
}
}]
@mdgreenwald
Copy link

Service port shouldn't have quotes around it:
"servicePort": 80

@SteveEasley
Copy link
Author

@mdgreenwald Thanks. Fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment