在 Helm 中,可以使用指定发布名称
helm install my-release-name 图表路径
这意味着,我可以使用 CLI 指定版本名称及其组件(使用全名)。
在kustomize中(我是kustomize新手),也有类似的概念,namePrefix
和 nameSuffix
可以在 kustomization.yaml
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
namePrefix: overlook-
resources:
- deployment.yaml
但是,这种方法需要一个自定义文件,使用“动态”namePrefix 意味着必须使用模板生成 kustomization.yaml
,而 kustomize 就是避免模板化。
有什么方法可以动态指定该值吗?
最佳答案
您可以使用 kustomize edit
编辑 nameprefix
和 namesuffix
值。
例如:
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
关于kubernetes - 是否可以在 kustomize 中使用动态名称前缀/名称后缀?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65415295/