fix: v8.5.10-bのDeployment.spec.selector変更が既存リリースのアップグレードを壊す不具合を修正
Helm Chart Release / release-chart (push) Successful in 9s
Helm Chart Release / release-chart (push) Successful in 9s
既存のnginx/php-fpm Deploymentのspec.selector.matchLabelsにapp.kubernetes.io/component:webを追加していたが、Deployment.spec.selectorは作成後immutableのためhelm upgradeが'field is immutable'で失敗していた。既存Deploymentのselectorは元の内容(name+instanceのみ)に戻し、Selenium側はcomponentラベルではなくapp.kubernetes.io/name自体を<chart名>-seleniumという別名にする方式(新ヘルパーphpfpm.selenium.name/phpfpm.selenium.selectorLabels)に変更した。componentラベルだけを足す設計だとSeleniumのPodもnginx/php-fpm側Deploymentのselectorに一致してしまいReplicaSetの選択重複を起こすため、name自体をvariantにして構造的に防止する。v8.5.10-bは既存リリースへの適用不可のためスキップし、v8.5.10-c以降を使うこと。
This commit is contained in:
@@ -19,3 +19,25 @@ app.kubernetes.io/instance: {{ .Release.Name }}
|
||||
app.kubernetes.io/name: {{ include "phpfpm.name" . }}
|
||||
app.kubernetes.io/instance: {{ .Release.Name }}
|
||||
{{- end }}
|
||||
|
||||
{{/*
|
||||
Selenium 用の名前・セレクタラベル(v8.5.10-b)。
|
||||
|
||||
nginx/php-fpm の既存 Deployment は spec.selector が作成後 immutable なため、
|
||||
そちらの selector には手を加えられない("field is immutable" でアップグレードが
|
||||
失敗する)。そのため Selenium 側は app.kubernetes.io/name 自体を variant
|
||||
("phpfpm-selenium")にして、nginx/php-fpm の Deployment の selector
|
||||
(name=phpfpm, instance=<release>)とラベルの組が完全に一致しないようにする。
|
||||
component ラベルだけを足す設計だと、Selenium の Pod も name=phpfpm/instance=<release>
|
||||
を持つため nginx/php-fpm 側 Deployment の selector にも一致してしまい、
|
||||
2つの Deployment(ReplicaSet)が同じ Pod 集合を取り合う selector 重複を起こす。
|
||||
name を variant にすることで、この重複を構造的に防止する。
|
||||
*/}}
|
||||
{{- define "phpfpm.selenium.name" -}}
|
||||
{{- printf "%s-selenium" (include "phpfpm.name" .) | trunc 63 | trimSuffix "-" -}}
|
||||
{{- end }}
|
||||
|
||||
{{- define "phpfpm.selenium.selectorLabels" -}}
|
||||
app.kubernetes.io/name: {{ include "phpfpm.selenium.name" . }}
|
||||
app.kubernetes.io/instance: {{ .Release.Name }}
|
||||
{{- end }}
|
||||
|
||||
@@ -23,12 +23,11 @@ spec:
|
||||
replicas: {{ .Values.selenium.replicaCount | default 1 }}
|
||||
selector:
|
||||
matchLabels:
|
||||
{{- include "phpfpm.selectorLabels" . | nindent 6 }}
|
||||
app.kubernetes.io/component: selenium
|
||||
{{- include "phpfpm.selenium.selectorLabels" . | nindent 6 }}
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
{{- include "phpfpm.selectorLabels" . | nindent 8 }}
|
||||
{{- include "phpfpm.selenium.selectorLabels" . | nindent 8 }}
|
||||
app.kubernetes.io/component: selenium
|
||||
spec:
|
||||
containers:
|
||||
|
||||
@@ -7,9 +7,13 @@ metadata:
|
||||
spec:
|
||||
replicas: {{ .Values.replicaCount }}
|
||||
selector:
|
||||
# 注意: Deployment.spec.selector は作成後 immutable。既存リリースの
|
||||
# アップグレードを壊さないため、ここに app.kubernetes.io/component は
|
||||
# 追加しない(component ラベルは下の pod template と Service の
|
||||
# selector のみに付与する。template.metadata.labels は matchLabels の
|
||||
# superset であればよいため、追加ラベルを持たせても問題ない)。
|
||||
matchLabels:
|
||||
{{- include "phpfpm.selectorLabels" . | nindent 6 }}
|
||||
app.kubernetes.io/component: web
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
|
||||
@@ -14,6 +14,5 @@ spec:
|
||||
protocol: TCP
|
||||
name: selenium
|
||||
selector:
|
||||
{{- include "phpfpm.selectorLabels" . | nindent 4 }}
|
||||
app.kubernetes.io/component: selenium
|
||||
{{- include "phpfpm.selenium.selectorLabels" . | nindent 4 }}
|
||||
{{- end }}
|
||||
|
||||
Reference in New Issue
Block a user