Files
phpfpm/templates/_helpers.tpl
T
claude 6cd35ce023
Helm Chart Release / release-chart (push) Successful in 5s
feat: 定期実行(CronJob)機能を追加
cron.jobs(配列)にジョブを定義すると、php-fpmと同じPHPイメージを使う
Kubernetes CronJobをジョブごとに生成する。

- templates/cronjob.yaml(新規): PVCルートを/var/wwwにマウントし、
  externalDatabase/phpEnv/extraEnv/extraEnvFrom/SELENIUM_URLをphp-fpm
  コンテナと同じ内容で注入。smtp.enabled時はmsmtpも自動導入。
- templates/_helpers.tpl: phpfpm.cron.name/selectorLabelsを追加。
  Selenium分離と同じ理由で、生成PodのラベルをDeploymentのselectorと
  衝突しないバリアント名(<chart>-cron)にする。
- values.yaml: cronセクションを追加(既定は空配列で無効)。
- README.md: パラメータ表と使用例、Composer/Pythonとの併用時の注意点
  (デフォルトの使い捨て領域はCronJobから見えないため、永続化パスへの
  変更が必要)を追加。

templates/deployment.yamlは変更していない(既存Deploymentへの影響なし)。
手動リリース 8.5.10-e。
2026-09-27 16:26:18 +09:00

64 lines
2.8 KiB
Smarty
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.
{{- define "phpfpm.name" -}}
{{- .Chart.Name | trunc 63 | trimSuffix "-" -}}
{{- end }}
{{- define "phpfpm.fullname" -}}
{{- if .Release.Name -}}
{{- printf "%s-%s" .Release.Name (include "phpfpm.name" .) | trunc 63 | trimSuffix "-" -}}
{{- else -}}
{{- include "phpfpm.name" . -}}
{{- end }}
{{- end }}
{{- define "phpfpm.labels" -}}
app.kubernetes.io/name: {{ include "phpfpm.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}
{{- define "phpfpm.selectorLabels" -}}
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 }}
{{/*
Cron(CronJob)用の名前・ラベル(v8.5.10-e)。
Selenium と同じ理由で、CronJobが生成するPodのラベルにも nginx/php-fpm の
Deployment と同じ app.kubernetes.io/name("phpfpm")+ instance を持たせては
いけない。同じ組み合わせだとDeploymentのReplicaSetコントローラーが
matchLabels(name=phpfpm, instance=<release>)に一致するPodとしてCronJob由来
のPodまで対象に含めてしまい、replicaCountとの差分調整でCronJobのPodを
意図せず削除する等の事故につながる。name自体をvariant("phpfpm-cron")に
することで構造的に衝突を防ぐ。
*/}}
{{- define "phpfpm.cron.name" -}}
{{- printf "%s-cron" (include "phpfpm.name" .) | trunc 63 | trimSuffix "-" -}}
{{- end }}
{{- define "phpfpm.cron.selectorLabels" -}}
app.kubernetes.io/name: {{ include "phpfpm.cron.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}