3

In Helm, it is possible to specify a release name using

helm install my-release-name chart-path

This means, I can specify the release name and its components (using fullname) using the CLI.

In kustomize (I am new to kustomize), there is a similar concept, namePrefix and nameSuffix which can be defined in a kustomization.yaml

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

namePrefix: overlook-

resources:
- deployment.yaml

However, this approach needs a custom file, and using a "dynamic" namePrefix would mean that a kustomization.yaml has to be generated using a template and kustomize is, well, about avoiding templating.

Is there any way to specify that value dynamically?

user140547
  • 7,750
  • 3
  • 28
  • 80

1 Answers1

1

You can use kustomize edit to edit the nameprefix and namesuffix values.

For example:

Deployment.yaml

apiVersion: apps/v1
kind: Deployment
metadata:
  name: the-deployment
spec:
  replicas: 5
  template:
    containers:
      - name: the-container
        image: registry/conatiner:latest

Kustomization.yaml

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

resources:
- deployment.yaml

Then you can run kustomize edit set nameprefix dev- and kustomize build . will return following:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: dev-the-deployment
spec:
  replicas: 5
  template:
    containers:
    - image: registry/conatiner:latest
      name: the-container
kool
  • 3,214
  • 1
  • 10
  • 26
  • better then templating, however for CI it would be if it was't necessary to make changes to file, but accepting it since I guess there is no such option – user140547 Dec 23 '20 at 14:13