devspace-sh / devspace

DevSpace - The Fastest Developer Tool for Kubernetes ⚡ Automate your deployment workflow with DevSpace and develop software directly inside Kubernetes.
https://devspace.sh
Apache License 2.0
4.29k stars 359 forks source link

Add patches/resources via kustomize deployment #1678

Closed lukasmrtvy closed 1 year ago

lukasmrtvy commented 2 years ago

Is your feature request related to a problem? Would be nice to support patches and referencing additional resources directly in kustomize deployment spec.

Which solution do you suggest? Temporary kustomization.yaml file can be created as an overlay, this file can absorb orginal kustomize settings plus additional patches and resources from devspace.yaml to prevent inconsistency of original kustomization.

deployments:
- name: my-deployment
  kubectl:
    kustomize: true
    manifests:
    - .
    patches:
    - path: ingress_patch.json
      target:
        group: networking.k8s.io
        version: v1beta1
        kind: Ingress
        name: my-ingress
    - target:
        kind: Deployment
        name: deploy
      patch: |-
      - op: replace
        path: /spec/template/spec/containers/0/image
        value: nginx:latest
    resources:
    - https://github.com/lukasmrtvy/kustomize//raw.yaml?ref=master

Which alternative solutions exist?

hooks:
- command: kustomize
  args:
    - edit
    - add
    - patch
    - --group=networking.k8s.io
    - --version=v1
    - --kind=Ingress
    - --name=${INGRESS_OBJECT_NAME}
    - --patch=[{...}]
  when:
    before:
      deployments: all

There is a chance that users can commit modified version of kustomization.yaml ( even with hook which will remove patch ), beacuse kustomize edit add patch command actualy modifies kustomization.yaml file itself.

Additional context

Thanks

/kind feature

FabianKramm commented 2 years ago

@lukasmrtvy thanks for creating this issue! Yes thats a good idea, we should add support for patches with kustomize

stevejr commented 1 year ago

@FabianKramm - any update on this issue? We are currently moving some of our apps from Helm to Kustomize and utilise the features in Devspace to interpolate the values/variables to amend the Image Repository value but we cannot do this at present in Kustomize unless we use the Hooks suggestion above.