Version: v1.1

Kustomize Patch

kustomize-patch Specification

  1. vela show kustomize-patch
  1. # Properties
  2. +---------+---------------------------------------------------------------+-----------------------+----------+---------+
  3. | NAME | DESCRIPTION | TYPE | REQUIRED | DEFAULT |
  4. +---------+---------------------------------------------------------------+-----------------------+----------+---------+
  5. | patches | a list of StrategicMerge or JSON6902 patch to selected target | [[]patches](#patches) | true | |
  6. +---------+---------------------------------------------------------------+-----------------------+----------+---------+
  7. ## patches
  8. +--------+---------------------------------------------------+-------------------+----------+---------+
  9. | NAME | DESCRIPTION | TYPE | REQUIRED | DEFAULT |
  10. +--------+---------------------------------------------------+-------------------+----------+---------+
  11. | patch | Inline patch string, in yaml style | string | true | |
  12. | target | Specify the target the patch should be applied to | [target](#target) | true | |
  13. +--------+---------------------------------------------------+-------------------+----------+---------+
  14. ### target
  15. +--------------------+-------------+--------+----------+---------+
  16. | NAME | DESCRIPTION | TYPE | REQUIRED | DEFAULT |
  17. +--------------------+-------------+--------+----------+---------+
  18. | name | | string | false | |
  19. | group | | string | false | |
  20. | version | | string | false | |
  21. | kind | | string | false | |
  22. | namespace | | string | false | |
  23. | annotationSelector | | string | false | |
  24. | labelSelector | | string | false | |
  25. +--------------------+-------------+--------+----------+---------+

How to use

  1. apiVersion: core.oam.dev/v1beta1
  2. kind: Application
  3. metadata:
  4. name: bucket-app
  5. spec:
  6. components:
  7. - name: bucket-comp
  8. type: kustomize
  9. # ... omitted for brevity
  10. traits:
  11. - type: kustomize-patch
  12. properties:
  13. patches:
  14. - patch: |-
  15. apiVersion: v1
  16. kind: Pod
  17. metadata:
  18. name: not-used
  19. labels:
  20. app.kubernetes.io/part-of: test-app
  21. target:
  22. labelSelector: "app=podinfo"

In this example, the kustomize-patch will patch the content for all Pods with label app=podinfo.

kustomize-json-patch Specification

You could use JSON6902 format to patch the component. Get to know it first:

  1. vela show kustomize-json-patch
  1. # Properties
  2. +-------------+---------------------------+-------------------------------+----------+---------+
  3. | NAME | DESCRIPTION | TYPE | REQUIRED | DEFAULT |
  4. +-------------+---------------------------+-------------------------------+----------+---------+
  5. | patchesJson | A list of JSON6902 patch. | [[]patchesJson](#patchesJson) | true | |
  6. +-------------+---------------------------+-------------------------------+----------+---------+
  7. ## patchesJson
  8. +--------+-------------+-------------------+----------+---------+
  9. | NAME | DESCRIPTION | TYPE | REQUIRED | DEFAULT |
  10. +--------+-------------+-------------------+----------+---------+
  11. | patch | | [patch](#patch) | true | |
  12. | target | | [target](#target) | true | |
  13. +--------+-------------+-------------------+----------+---------+
  14. #### target
  15. +--------------------+-------------+--------+----------+---------+
  16. | NAME | DESCRIPTION | TYPE | REQUIRED | DEFAULT |
  17. +--------------------+-------------+--------+----------+---------+
  18. | name | | string | false | |
  19. | group | | string | false | |
  20. | version | | string | false | |
  21. | kind | | string | false | |
  22. | namespace | | string | false | |
  23. | annotationSelector | | string | false | |
  24. | labelSelector | | string | false | |
  25. +--------------------+-------------+--------+----------+---------+
  26. ### patch
  27. +-------+-------------+--------+----------+---------+
  28. | NAME | DESCRIPTION | TYPE | REQUIRED | DEFAULT |
  29. +-------+-------------+--------+----------+---------+
  30. | path | | string | true | |
  31. | op | | string | true | |
  32. | value | | string | false | |
  33. +-------+-------------+--------+----------+---------+

How to use

  1. apiVersion: core.oam.dev/v1beta1
  2. kind: Application
  3. metadata:
  4. name: bucket-app
  5. spec:
  6. components:
  7. - name: bucket-comp
  8. type: kustomize
  9. # ... omitted for brevity
  10. traits:
  11. - type: kustomize-json-patch
  12. properties:
  13. patchesJson:
  14. - target:
  15. version: v1
  16. kind: Deployment
  17. name: podinfo
  18. patch:
  19. - op: add
  20. path: /metadata/annotations/key
  21. value: value

kustomize-strategy-merge Specification

  1. vela show kustomize-json-patch
  1. # Properties
  2. +-----------------------+-----------------------------------------------------------+---------------------------------------------------+----------+---------+
  3. | NAME | DESCRIPTION | TYPE | REQUIRED | DEFAULT |
  4. +-----------------------+-----------------------------------------------------------+---------------------------------------------------+----------+---------+
  5. | patchesStrategicMerge | a list of strategicmerge, defined as inline yaml objects. | [[]patchesStrategicMerge](#patchesStrategicMerge) | true | |
  6. +-----------------------+-----------------------------------------------------------+---------------------------------------------------+----------+---------+
  7. ## patchesStrategicMerge
  8. +-----------+-------------+--------------------------------------------------------+----------+---------+
  9. | NAME | DESCRIPTION | TYPE | REQUIRED | DEFAULT |
  10. +-----------+-------------+--------------------------------------------------------+----------+---------+
  11. | undefined | | map[string](null|bool|string|bytes|{...}|[...]|number) | true | |

How to use

  1. apiVersion: core.oam.dev/v1beta1
  2. kind: Application
  3. metadata:
  4. name: bucket-app
  5. spec:
  6. components:
  7. - name: bucket-comp
  8. type: kustomize
  9. # ... omitted for brevity
  10. traits:
  11. - type: kustomize-strategy-merge
  12. properties:
  13. patchesStrategicMerge:
  14. - apiVersion: apps/v1
  15. kind: Deployment
  16. metadata:
  17. name: podinfo
  18. spec:
  19. template:
  20. spec:
  21. serviceAccount: custom-service-account