fix: Seleniumを独立Deployment/Serviceに分離しresourcesの死んだ設定を修正
Helm Chart Release / release-chart (push) Successful in 6s
Helm Chart Release / release-chart (push) Successful in 6s
selenium.enabled=true構成でphp-fpmのCrashLoopBackOffとサイト完全停止が続いた件を調査し、2つの設計上の欠陥を確認した。(1) resources values キーがテンプレートで一切参照されておらず、全コンテナがQoS Class: BestEffortで動作しOOM Killされやすい状態だった。(2) nginx/php-fpm/SeleniumをすべてSelenium同一Podで起動しており、Kubernetesの Pod Ready判定(全コンテナのAND)により、Seleniumだけが不調でもPod全体がServiceのEndpointsから外れ、Seleniumを使わない静的ページ配信まで巻き込まれてサービス全体が停止していた。対応: Seleniumを独立Deployment(<release>-phpfpm-selenium)/Serviceに分離し、SELENIUM_URLを自動注入。resourcesをnginx/phpfpm/selenium個別に構造化して実際にコンテナへ反映されるよう修正。詳細はCHANGELOG-8.5.10-b.md参照。
This commit is contained in:
@@ -0,0 +1,68 @@
|
||||
{{- 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.selectorLabels" . | nindent 6 }}
|
||||
app.kubernetes.io/component: selenium
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
{{- include "phpfpm.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 }}
|
||||
+18
-11
@@ -9,10 +9,12 @@ spec:
|
||||
selector:
|
||||
matchLabels:
|
||||
{{- include "phpfpm.selectorLabels" . | nindent 6 }}
|
||||
app.kubernetes.io/component: web
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
{{- include "phpfpm.selectorLabels" . | nindent 8 }}
|
||||
app.kubernetes.io/component: web
|
||||
spec:
|
||||
containers:
|
||||
- name: nginx
|
||||
@@ -20,6 +22,10 @@ spec:
|
||||
imagePullPolicy: {{ .Values.image.nginx.pullPolicy }}
|
||||
ports:
|
||||
- containerPort: 80
|
||||
{{- with .Values.resources.nginx }}
|
||||
resources:
|
||||
{{- toYaml . | nindent 12 }}
|
||||
{{- end }}
|
||||
volumeMounts:
|
||||
- name: app-storage
|
||||
mountPath: /var/www/html
|
||||
@@ -264,6 +270,10 @@ spec:
|
||||
exec php-fpm -F
|
||||
ports:
|
||||
- containerPort: 9000 # PHP-FPMは9000ポートでリッスン
|
||||
{{- with .Values.resources.phpfpm }}
|
||||
resources:
|
||||
{{- toYaml . | nindent 12 }}
|
||||
{{- end }}
|
||||
volumeMounts:
|
||||
# PVCルートを /var/www にマウント
|
||||
# - /var/www/html のみ nginx が公開(nginx側は html サブパスだけをマウント)
|
||||
@@ -306,6 +316,14 @@ spec:
|
||||
- name: {{ $key }}
|
||||
value: {{ $value | quote }}
|
||||
{{- end }}
|
||||
{{- if .Values.selenium.enabled }}
|
||||
# Selenium は別 Deployment/Service(templates/deployment-selenium.yaml)として
|
||||
# 稼働する(v8.5.10-b 以降。selenium.enabled=true の Pod と同居させない設計に変更)。
|
||||
# phpEnv に SELENIUM_URL を書いても、この行が env リストの後方にあるため
|
||||
# 最終的にこちらが優先される(Kubernetes は同名 env の重複時、後方の値を採用する)。
|
||||
- name: SELENIUM_URL
|
||||
value: "http://{{ include "phpfpm.fullname" . }}-selenium:4444/wd/hub"
|
||||
{{- end }}
|
||||
{{- with .Values.extraEnv }}
|
||||
{{- toYaml . | nindent 12 }}
|
||||
{{- end }}
|
||||
@@ -313,17 +331,6 @@ spec:
|
||||
envFrom:
|
||||
{{- toYaml . | nindent 12 }}
|
||||
{{- end }}
|
||||
{{- if .Values.selenium.enabled }}
|
||||
- name: selenium
|
||||
image: "{{ .Values.image.selenium.registry }}/{{ .Values.image.selenium.repository }}:{{ .Values.image.selenium.tag }}"
|
||||
imagePullPolicy: {{ .Values.image.selenium.pullPolicy }}
|
||||
ports:
|
||||
- containerPort: 4444 # Selenium用ポート
|
||||
volumeMounts:
|
||||
- name: app-storage
|
||||
mountPath: /var/www/html
|
||||
subPath: html
|
||||
{{- end }}
|
||||
dnsPolicy: ClusterFirst
|
||||
dnsConfig:
|
||||
options:
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
{{- if .Values.selenium.enabled }}
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: {{ include "phpfpm.fullname" . }}-selenium
|
||||
labels:
|
||||
{{- include "phpfpm.labels" . | nindent 4 }}
|
||||
app.kubernetes.io/component: selenium
|
||||
spec:
|
||||
type: ClusterIP
|
||||
ports:
|
||||
- port: 4444
|
||||
targetPort: 4444
|
||||
protocol: TCP
|
||||
name: selenium
|
||||
selector:
|
||||
{{- include "phpfpm.selectorLabels" . | nindent 4 }}
|
||||
app.kubernetes.io/component: selenium
|
||||
{{- end }}
|
||||
@@ -13,3 +13,4 @@ spec:
|
||||
name: http
|
||||
selector:
|
||||
{{- include "phpfpm.selectorLabels" . | nindent 4 }}
|
||||
app.kubernetes.io/component: web
|
||||
|
||||
Reference in New Issue
Block a user