I'm trying to use patching in Kustomize to modify Kubernetes resources and I'm wondering if there is a neat way to update every item of a list.
Here is the yaml that I'd like to customize:
apiVersion: admissionregistration.k8s.io/v1
kind: ValidatingWebhookConfiguration
metadata:
annotations:
name: validating-webhook-configuration
webhooks:
- admissionReviewVersions:
- v1
clientConfig:
service:
name: webhook-service
namespace: rabbitmq-system
path: /validate-rabbitmq-com-v1beta1-binding
- admissionReviewVersions:
- v1
clientConfig:
service:
name: webhook-service
namespace: rabbitmq-system
path: /validate-rabbitmq-com-v1beta1-exchange
- admissionReviewVersions:
- v1
clientConfig:
service:
name: webhook-service
namespace: rabbitmq-system
path: /validate-rabbitmq-com-v1beta1-federation
And here is the end effect that I want to achieve (see NEWVALUE
):
apiVersion: admissionregistration.k8s.io/v1
kind: ValidatingWebhookConfiguration
metadata:
annotations:
name: validating-webhook-configuration
webhooks:
- admissionReviewVersions:
- v1
clientConfig:
NEWVALUE: value
service:
name: webhook-service
namespace: rabbitmq-system
path: /validate-rabbitmq-com-v1beta1-binding
- admissionReviewVersions:
- v1
clientConfig:
NEWVALUE: value
service:
name: webhook-service
namespace: rabbitmq-system
path: /validate-rabbitmq-com-v1beta1-exchange
- admissionReviewVersions:
- v1
clientConfig:
NEWVALUE: value
service:
name: webhook-service
namespace: rabbitmq-system
path: /validate-rabbitmq-com-v1beta1-federation
I'm fully aware of a Json6902 patch but it only allows me to modify one index at a time:
- op: add
path: /webhooks/0/clientConfig/NEWVALUe
value: value
Is there a way to modify every element in a fashion similar to a for loop or do I have to specify each index manually?