我有一个秘密资源模板,安装后将为数据生成随机值。
删除该图表(没有删除秘密资源,因为它们保留下来)并稍后重新安装后,我遇到了问题。
这导致它使用新生成的数据运行以前的秘密,这在我的情况下是不希望的。
我试图找到我需要包含在模板中的 if 条件是什么,以便它不会创建或修改秘密(如果它已经存在)。我该怎么做?
我有类似的要求,但 helm 升级会删除该对象(如果存在),添加
helm.sh/resource-policy: keep
注释有所帮助,如下所示
{{- if not (lookup "networking.istio.io/v1beta1" "VirtualService" .Release.Namespace .Release.Name ) -}}
apiVersion: networking.istio.io/v1beta1
kind: VirtualService
metadata:
name: {{ .Release.Name }}
annotations:
# helm deletes the object is present due to above "if not" condition
# add annotation to keep the object
helm.sh/resource-policy: keep
spec:
hosts:
- {{ .Release.Name }}
http:
- route:
- destination:
host: {{ .Release.Name }}
subset: v1
weight: 90
- destination:
host: {{ .Release.Name }}
subset: v2
weight: 10
{{ end }}