Skip to content

feat: patching chart without forking it #650

Closed
@mumoshu

Description

@mumoshu

Use-cases

  • Injecting Istio sidecars without mutating webhook and istioctl. You don't even need to fork upstream charts or modify your chart.
  • Modify K8s resources produced by an upstream chart even if there's no configuration via values.yaml exposed.

Again this is a shameless plug: Adding helm-x integration to helmfile would allow you to apply patches(JSON Patch and Strategic-Merge Patch) before helm-installing it, and that's possible without modifying or forking it.

releases:
- name: myapp
   chart: sp/podinfo
   # version is required because it isn't provided by kustomization by its nature!
   version: 2.0.1
  patches:
  - jsonpatch.yaml
  - strategicmergepatch.yaml
  # inline json patch
  -  target:
      group: autoscaling
      version: v2beta1
      kind: HorizontalPodAutoscaler
      name: myapp-podinfo
    patch:
    - op: replace
      path: /spec/maxReplicas
      value: 1
  # inline strategic-merge patch
  - apiVersion: autoscaling/v2beta1
    kind: HorizontalPodAutoscaler
    metadata:
      name: myapp-podinfo
      labels:
        app: podinfo
        chart: podinfo-2.0.1
        release: myapp
        heritage: Tiller
    spec:
      scaleTargetRef:
        apiVersion: apps/v1beta2
        kind: Deployment
        name: myapp-podinfo
      minReplicas: 3

The patches setting results in running helm x upgrade --json-patch jsonpatch.yaml --strategic-merge-patch strategicmergepatch.yaml sp/podinfo --version 2.0.1 ...onhelmfile syncfor example, that has the same effect as running (1)helm template -o dir/to render the chart to a directory and (2) creratingkustomization.yamlwith all the rendered manifests in itsresources:section and corresponding patch definitions in it and (3) runningkustomize buildto apply patches to all the manifests in the dir and (4) finally installing it as a local chart by runninghelm upgrade temp/local/chart`.

See https://github.com/mumoshu/helm-x for more information.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions