Justin S
Justin S

Reputation: 784

Flux v2 - How to Deploy Same Helm Chart, Multiple Times, Into Different Namespaces

We are building out a small cluster for a dev team.

Ive been working through this repo: https://github.com/fluxcd/flux2-kustomize-helm-example

The infrastructure part went fine.

Now instead of apps I need to create a way for each developer, to deploy/maintain their own version of the application they are working on.

├── clusters
│   └── qa
│       ├── deploys.bak
│       ├── flux-system
│       │   ├── gotk-components.yaml
│       │   ├── gotk-sync.yaml
│       │   └── kustomization.yaml
│       └── infrastructure.yaml
├── deploys
│   ├── base
│   ├── dev1
│   ├── dev2
│   ├── dev3
│   └── staging

In deploys/base it would be great to specify a Namespace, a HelmRelease, and a Kubernetes Secret.

Then in deploys/dev1 it would be great if we could include the base but have a way of overriding the namespace everything goes into.

So you would have namespaces app-dev1, app-dev2 etc.

This would allow us to only really have to override the ingress information, and the image tag for the app.

Thanks for any information on this.

Upvotes: 1

Views: 1539

Answers (1)

yershalom
yershalom

Reputation: 838

You need to add a patch to your kustomization.

patches:
  - target:
      kind: HelmRelease
      name: .*-helm-release
      version: v2beta1
    patch: |-
      - op: add
        path: /spec/targetNamespace
        value: dev1
      - op: replace
        path: /metadata/namespace
        value: dev1

Add this to every env that you want.

Upvotes: 1

Related Questions