1

I know that I can use Kustomize's configMapGenerator to create a configmap from a file that resides in the same Git repository as the "kustomization.yaml" file.

For Example:

apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
  - deployment.yaml
configMapGenerator:
- name: my-config
  files:
  - config-file.json

But is it possible to create a configMap from a file that resides in a different Git repository?

For example:

apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
  - deployment.yaml
configMapGenerator:
- name: my-config
  files:
  - git::ssh://git@bitbucket.company.com:7999/proj/repo-name.git//config-file.json

1 Answers1

0

I think the correct approach for the use case you describe is just to define a base and create a specific overlay that references the remote base and includes the file you need, merging the configs:

# base-project/base/kustomization.yaml

apiVersion: kustomize.config.k8s.io/v1beta1 kind: Kustomization resources:

  • deployment.yaml

configMapGenerator:

  • name: my-config files:
    • config-file.json

Then on your other project:

# some-other-project/kustomization.yaml

apiVersion: kustomize.config.k8s.io/v1beta1 kind: Kustomization resources:

  • https://bitbucket.company.com/base-project//base?ref=v1.0.0

configMapGenerator:

  • name: my-config behavior: merge files:
    • config-file.json

The double slashes are relevant and ref can be any branch or tag (e.g. main); I used https but you can also setup direct git references or use rewrite rules, see https://github.com/kubernetes-sigs/kustomize/blob/master/examples/remoteBuild.md.

dlouzan
  • 201