Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot patch new rules onto this resource #1078

Closed
Kezzsim opened this issue Apr 18, 2020 · 1 comment
Closed

Cannot patch new rules onto this resource #1078

Kezzsim opened this issue Apr 18, 2020 · 1 comment

Comments

@Kezzsim
Copy link

Kezzsim commented Apr 18, 2020

I'm trying to make this ingress more dynamic in scripting by using kubectl's patch to add more rules, every time I want to setup a new subdomain and point to a new backend service that gets created. In theory this should be easy, just write an RFC6902 patch and apply it... easy, right?

Not so much...

Every time I run:
kubectl patch ingresses.networking.k8s.io test-ingress --type='json' -p='[{"op":"add","path":"/spec/rules/","value":{"host":"boingonetworks.test.com","http":{"paths":[{"backend":{"serviceName":"server-boingonetworks","servicePort":3003}}]}}}]'
from the cli I always get:
ingress.networking.k8s.io/test-ingress patched (no change)

Then I verify with the yml within GKE's dashboard and sure enough... no new rule under the ingress...

For the time being I will resort to reading in the ingress as JSON from kubectl -> adding to the array -> running kubectl apply on the output but I know deep down that this is vulnerable to a race condition if this gets run in multiple instances, where it could become inaccurate if it's reading in the config at the same time another entity is applying it...

@Kezzsim
Copy link
Author

Kezzsim commented Apr 18, 2020

Kubectl is a little bit verbose in the way it accepts patches

I thought if I did it at position 0 it would overwrite the existing element, but instead it has the desired behavior, so the functional version of the command above is:
kubectl patch ingresses.networking.k8s.io test-ingress --type='json' -p='[{"op":"add","path":"/spec/rules/0","value":{"host":"boingonetworks.test.com","http":{"paths":[{"backend":{"serviceName":"server-boingonetworks","servicePort":3003}}]}}}]'

@Kezzsim Kezzsim closed this as completed Apr 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant