Files
phpfpm/templates/deployment-selenium.yaml
claude abb5dba4a1
Helm Chart Release / release-chart (push) Successful in 9s
fix: v8.5.10-bのDeployment.spec.selector変更が既存リリースのアップグレードを壊す不具合を修正
既存の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以降を使うこと。
2026-09-26 09:46:56 +09:00

68 lines
2.9 KiB
YAML
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
{{- if .Values.selenium.enabled }}
# Selenium を nginx/php-fpm と別 Deployment にする理由(v8.5.10-b):
#
# 以前は selenium/standalone-chromium を nginx・php-fpm と同一 Pod のサイドカー
# コンテナとして起動していた。Kubernetes は Pod の Ready 条件を「全コンテナが Ready」
# の AND で判定するため、readinessProbe を持たないコンテナは「Running であれば Ready」
# として扱われる一方、CrashLoopBackOff で Waiting/Terminated を繰り返す間は Ready=false
# になる。この間 Pod 全体が Service の Endpoints から外れるため、Selenium コンテナ
# だけが不安定(起動失敗・OOM等)でも、Selenium を全く使わない静的ページの配信まで
# 巻き込まれてサービス全体が完全停止していた。
#
# Selenium を独立した Deployment/Service に分離することで、Selenium の不調が
# nginx/php-fpm Pod の Ready 状態に一切影響しなくなり、スクレイピング機能のみが
# 影響を受け、サイト自体は表示され続ける。
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "phpfpm.fullname" . }}-selenium
labels:
{{- include "phpfpm.labels" . | nindent 4 }}
app.kubernetes.io/component: selenium
spec:
replicas: {{ .Values.selenium.replicaCount | default 1 }}
selector:
matchLabels:
{{- include "phpfpm.selenium.selectorLabels" . | nindent 6 }}
template:
metadata:
labels:
{{- include "phpfpm.selenium.selectorLabels" . | nindent 8 }}
app.kubernetes.io/component: selenium
spec:
containers:
- name: selenium
image: "{{ .Values.image.selenium.registry }}/{{ .Values.image.selenium.repository }}:{{ .Values.image.selenium.tag }}"
imagePullPolicy: {{ .Values.image.selenium.pullPolicy }}
ports:
- containerPort: 4444 # Selenium用ポート
{{- with .Values.selenium.resources }}
resources:
{{- toYaml . | nindent 12 }}
{{- end }}
{{- if .Values.selenium.mountHtml }}
volumeMounts:
- name: app-storage
mountPath: /var/www/html
subPath: html
{{- end }}
dnsPolicy: ClusterFirst
dnsConfig:
options:
- name: ndots
value: "1"
{{- if .Values.selenium.mountHtml }}
volumes:
- name: app-storage
# 別 Pod から同じ PVC の html/ サブパスを読み書きするため、
# persistence.accessMode を ReadWriteMany にする必要がある
# (NFS バックエンドの StorageClass なら対応可能)。
{{- if .Values.persistence.enabled }}
persistentVolumeClaim:
claimName: {{ include "phpfpm.fullname" . }}-pvc
{{- else }}
emptyDir: {}
{{- end }}
{{- end }}
{{- end }}