gpt4 book ai didi

kubernetes - 升级 helm 模板后无效的规范选择器

转载 作者:行者123 更新时间:2023-12-04 14:22:23 40 4
gpt4 key购买 nike

我已经升级了掌 Helm 模板(手动)

以前的片段depoloyment.yaml :

apiVersion: apps/v1beta2 kind: Deployment metadata:   name: {{ template "measurement-collector.fullname" . }}   labels:
app: {{ template "measurement-collector.name" . }}
chart: {{ template "measurement-collector.chart" . }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }} spec: replicas: {{ .Values.replicaCount }} selector:
matchLabels:
app: {{ template "measurement-collector.name" . }}
release: {{ .Release.Name }}

新的一个:
apiVersion: apps/v1beta2
kind: Deployment
metadata:
name: {{ include "measurement-collector.fullname" . }}
labels:
app.kubernetes.io/name: {{ include "measurement-collector.name" . }}
helm.sh/chart: {{ include "measurement-collector.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
spec:
replicas: {{ .Values.replicaCount }}
selector:
matchLabels:
app.kubernetes.io/name: {{ include "measurement-collector.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}

新品 service.yaml :
  name: {{ include "measurement-collector.fullname" . }}
labels:
app.kubernetes.io/name: {{ include "measurement-collector.name" . }}
helm.sh/chart: {{ include "measurement-collector.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
spec:
type: {{ .Values.service.type }}
ports:
protocol: TCP
name: http
selector:
app.kubernetes.io/name: {{ include "measurement-collector.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}

然后运行后: helm upgrade -i measurement-collector chart/measurement-collector --namespace prod --wait
我得到:
Error: UPGRADE FAILED: Deployment.apps "measurement-collector" is invalid: spec.selector: Invalid value: 
v1.LabelSelector{MatchLabels:map[string]string{"app.kubernetes.io/name":"measurement-collector", "app.kubernetes.io/instance":"measurement-collector"},
MatchExpressions:[]v1.LabelSelectorRequirement(nil)}: field is immutable

最佳答案

如果更改选择器标签,则需要在部署之前先清除版本。

关于kubernetes - 升级 helm 模板后无效的规范选择器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53998259/

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