I've upgraded helm templates (by hand)
Fragment of previous 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 }}
New one:
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 }}
new 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 }}
Then after running: helm upgrade -i measurement-collector chart/measurement-collector --namespace prod --wait
I get:
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
If you change the selector label, then you will need to purge the release first before deploying.