dyw*_*666 6 kubernetes kustomize
我正在尝试在 Kustomize 中使用修补来修改 Kubernetes 资源,我想知道是否有一种巧妙的方法来更新列表中的每个项目。
这是我想要自定义的 yaml:
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
Run Code Online (Sandbox Code Playgroud)
这是我想要实现的最终效果(请参阅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
Run Code Online (Sandbox Code Playgroud)
我完全了解 Json6902 补丁,但它只允许我一次修改一个索引:
- op: add
path: /webhooks/0/clientConfig/NEWVALUe
value: value
Run Code Online (Sandbox Code Playgroud)
有没有办法以类似于 for 循环的方式修改每个元素,或者我是否必须手动指定每个索引?
小智 3
根据这里讨论的内容,他们还没有支持这种情况。当他们添加它时,你可以这样做:
kind: Kustomization
apiVersion: kustomize.config.k8s.io/v1beta1
resources:
- validating-webhook.yaml
- configmap.yaml
replacements:
- source:
kind: ConfigMap
name: cofignmap
fieldPath: data.NEWVALUE
targets:
- select:
name: validating-webhook-configuration
kind: ValidatingWebhookConfiguration
fieldPaths:
- webhooks.*.clientConfig.NEWVALUE
options:
create: true
Run Code Online (Sandbox Code Playgroud)
配置映射:
apiVersion: v1
kind: ConfigMap
metadata:
name: cofignmap
data:
NEWVALUE: value
Run Code Online (Sandbox Code Playgroud)
您可以在文档中阅读有关替换的信息
| 归档时间: |
|
| 查看次数: |
4879 次 |
| 最近记录: |