{{- 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 }}