2

在 Helm 中,可以使用指定发布名称

helm install my-release-name chart-path

这意味着,我可以使用 CLI 指定发布名称及其组件(使用全名)。

在 kustomize(我是 kustomize 的新手)中,有一个类似的概念,namePrefix可以nameSuffixkustomization.yaml

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

namePrefix: overlook-

resources:
- deployment.yaml

但是,这种方法需要一个自定义文件,并且使用“动态”namePrefix 意味着kustomization.yaml必须使用模板生成 a,而 kustomize 是关于避免模板化的。

有没有办法动态指定该值?

4

1 回答 1

1

您可以使用kustomize edit来编辑nameprefixnamesuffix值。

例如:

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

然后您可以运行kustomize edit set nameprefix dev-并将kustomize build .返回以下内容:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: dev-the-deployment
spec:
  replicas: 5
  template:
    containers:
    - image: registry/conatiner:latest
      name: the-container
于 2020-12-23T13:55:12.687 回答