Skip to content

Extend Kustomize Patches to Multiple Targets #2383

@ghost

Description

Enhancement Description

  • One-line enhancement description (can be used as a release note):

Extend Kustomize Patches to Multiple Targets

  • Kubernetes Enhancement Proposal:

Currently, there are different types of patches supported in Kustomize:
strategic merge patch and JSON patch.

patchesStrategicMerge:
- service_port_8888.yaml
- deployment_increase_replicas.yaml
- deployment_increase_memory.yaml

patchesJson6902:
- target:
    version: v1
    kind: Deployment
    name: my-deployment
  path: add_init_container.yaml
- target:
    version: v1
    kind: Service
    name: my-service
  path: add_service_annotation.yaml

Both types need group, version, kind and name(GVKN) of a Kubernetes resource to find
the unique target to perform the patching. In strategic merge patch, GVKN is included
in the patch itself. In JSON patch, the GVKN is specified in kustomization.yaml.

There have been requests for patching multiple targets by one patch for different purposes:

- override one field for all objects of one type
- add or remove common command arguments for all containers
- inject a [sidecar proxy](https://istio.io/docs/setup/kubernetes/sidecar-injection/) as in istio to all containers


  • Discussion Link:

  • Primary contact (assignee): @Liujingfang1 @pwittrock @mengqiy

  • Responsible SIGs: sig-cli

  • Enhancement target (which target equals to which milestone):

    • Alpha release target (x.y):
    • Beta release target (x.y):
    • Stable release target (x.y):
  • Alpha

    • KEP (k/enhancements) update PR(s):
    • Code (k/k) update PR(s):
    • Docs (k/website) update PR(s):
  • Add Patch struct in Kustomization type.

  • Update the patching transformer to recognize Patch and match
    multiple resources

  • Add unit test and integration test
    Please keep this description up to date. This will help the Enhancement Team to track the evolution of the enhancement efficiently.

Metadata

Metadata

Assignees

No one assigned

    Labels

    lifecycle/rottenDenotes an issue or PR that has aged beyond stale and will be auto-closed.sig/cliCategorizes an issue or PR as relevant to SIG CLI.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions