gpt4 book ai didi

Using kustomize on a templated manifest(在模板化清单上使用kustomize)

转载 作者:bug小助手 更新时间:2023-10-24 22:08:19 25 4
gpt4 key购买 nike



I have a use case where, my deployment manifest is heavily templated.

我有一个用例,我的部署清单高度模板化。


apiVersion: apps/v1
kind: Deployment
spec:
replicas: .{{.Replicas}}
template:
spec:
{{- if .optionA}}
somethingA
{{- end }}
{{- if .optionB}}
somethingB
{{- end }}

Now if I have to use kustomize, is duplication as shown below the only way to do it?

现在,如果我必须使用kustomize,如下所示的复制是唯一的方法吗?


└── release
├── base
│ ├── kustomization.yaml
│ └── deployment.yaml
| └── configmap.yaml
└── overlays
├── withA_withB
└── withA_withoutB
└── withoutA_withB
└── withoutA_withoutB

Is there a better way to do this, if there are multiple options?

如果有多个选择,有没有更好的方法来做到这一点?


更多回答

This is a bit of an XY problem: what are somethingA and somethingB; are they similar or completely different? If the latter, why aren't they simply spearate Deployments? Do you need the ability to deploy all four variants? Can you implement your template as a helm chart and then inflate that wit Kustomize?

这是一个有点XY的问题:什么是A和B;它们是相似的还是完全不同的?如果是后者,为什么他们不直接带头部署呢?您是否需要部署所有四种变体的能力?您是否可以将模板实现为舵图,然后对其进行膨胀?

these options are like Workload Identity, pod security policy, etc. depending upon things like kubernetes version, etc. I am trying to dynamically create the manifest.

这些选项包括工作负载标识、Pod安全策略等,具体取决于Kubernetes版本等。我正在尝试动态创建清单。

优秀答案推荐
更多回答

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com