feat: 外部Secret連携(extraEnvFrom / extraEnv / SMTP existingSecret)を追加
Helm Chart Release / release-chart (push) Successful in 6s

helmchart/secret-manager が各ネームスペースへ配布する cred-* Secret を
WordPress 側から参照できるようにする(phpfpm と同一方針)。
- extraEnvFrom / extraEnv: 既存 Secret/ConfigMap を wordpress コンテナへ env 注入
- smtp.auth.existingSecret / existingSecretKey: パスワードファイルだけ既存 Secret から取得
- smtp.existingMsmtprcSecret / existingMsmtprcSecretKey: 完成済み msmtprc を
  そのままマウント(指定時は configmap-smtp を生成せず host/port/auth.* は無視)
既定値は全て空のため既存挙動は不変。手動リリース 7.1.0-b。
This commit is contained in:
2026-09-08 14:16:14 +09:00
parent f16184f98d
commit 6d1b7bc8d6
7 changed files with 142 additions and 7 deletions
+21
View File
@@ -21,6 +21,27 @@ WordPress本体はイメージ内蔵のもの(`docker.io/wordpress:<tag>-fpm-a
## チャート改修履歴 ## チャート改修履歴
### 外部Secret連携(extraEnvFrom / extraEnv / SMTP existingSecret)を追加(2026-09-08, v7.1.0-b)
**背景**: 別リポジトリの `helmchart/secret-manager` チャートが各ネームスペースへ配布する
`cred-<名前>` Secret(メールの msmtprc / API キー)を WordPress 側から参照する口が無かった。
phpfpm チャートと同一方針で受け口を追加(ユーザー指定によりパターンを踏襲)。
**修正内容**:
- `values.yaml` に `extraEnvFrom`(`envFrom` 配列)と `extraEnv`(生の env エントリ配列)を追加。
稼働中の `wordpress` コンテナにのみ注入(`wordpress-init` initContainer には入れない)。
- `smtp.auth.existingSecret` / `existingSecretKey`: msmtprc はチャート生成のまま、パスワード
ファイルだけ既存 Secret から取得。
- `smtp.existingMsmtprcSecret` / `existingMsmtprcSecretKey`: 完成済み msmtprc を持つ既存 Secret を
そのまま `/etc/smtp-config/msmtprc` にマウント。指定時は `configmap-smtp` を生成せず
host/port/auth.* は無視、`smtp-secrets` ボリュームも張らない。起動ログの echo も出し分け。
- `templates/secret-smtp.yaml` / `templates/configmap-smtp.yaml` を上記フラグで出し分け。
- 既定値は全て空 → 既存挙動は不変(`helm template` の全シナリオで確認済み)。
- 主アプリ(WordPress 7.1.0)は変わらないため手動リリース `7.1.0-b`。
**対象ファイル**: `values.yaml`, `templates/deployment.yaml`, `templates/configmap-smtp.yaml`,
`templates/secret-smtp.yaml`, `Chart.yaml`, `README.md`, `CLAUDE.md`
### Hello Dolly等のデフォルトプラグインが削除しても復活する不具合の修正(2026-08-08, v7.1.0-a) ### Hello Dolly等のデフォルトプラグインが削除しても復活する不具合の修正(2026-08-08, v7.1.0-a)
※自動更新ワークフローがこの作業と並行してWordPress 7.1.0への正式リリース(v7.1.0)を実行したため、本修正はそのタグの上に手動リリース `7.1.0-a` として適用した。 ※自動更新ワークフローがこの作業と並行してWordPress 7.1.0への正式リリース(v7.1.0)を実行したため、本修正はそのタグの上に手動リリース `7.1.0-a` として適用した。
+1 -1
View File
@@ -2,7 +2,7 @@ apiVersion: v2
name: wordpress-nginx name: wordpress-nginx
description: WordPress with Nginx and PHP-FPM on Kubernetes description: WordPress with Nginx and PHP-FPM on Kubernetes
type: application type: application
version: 7.1.0-a version: 7.1.0-b
appVersion: "7.1.0" appVersion: "7.1.0"
keywords: keywords:
- wordpress - wordpress
+56
View File
@@ -139,12 +139,42 @@ WordPressコンテナ内にはメール送信を行うMTA(sendmail相当のプ
| `smtp.auth.enabled` | 認証有効化 | `true` | | `smtp.auth.enabled` | 認証有効化 | `true` |
| `smtp.auth.username` | SMTPユーザー名 | `smtp-user@example.com` | | `smtp.auth.username` | SMTPユーザー名 | `smtp-user@example.com` |
| `smtp.auth.password` | SMTPパスワード | `""`(Secretで指定) | | `smtp.auth.password` | SMTPパスワード | `""`(Secretで指定) |
| `smtp.auth.existingSecret` | パスワードを取得する既存 Secret 名(`smtp.auth.password` と自作 Secret の代わり) | `""` |
| `smtp.auth.existingSecretKey` | 上記 Secret 内のキー名 | `password` |
| `smtp.existingMsmtprcSecret` | 完成済み `msmtprc` を持つ既存 Secret 名。指定時はチャートの msmtprc 生成を行わず host/port/auth.* は無視(`from` のみ使用) | `""` |
| `smtp.existingMsmtprcSecretKey` | 上記 Secret 内の `msmtprc` キー名 | `msmtprc` |
| `smtp.from` | 送信元メールアドレス(固定) | `noreply@example.com` | | `smtp.from` | 送信元メールアドレス(固定) | `noreply@example.com` |
| `smtp.tls.verify` | TLS証明書検証 | `true` | | `smtp.tls.verify` | TLS証明書検証 | `true` |
| `smtp.tls.allowSelfSigned` | 自己署名証明書を許可 | `false` | | `smtp.tls.allowSelfSigned` | 自己署名証明書を許可 | `false` |
有効化すると、WordPressコンテナ起動時に `msmtp` を導入し、PHPの `sendmail_path` を `msmtp` 経由に設定します。`wp_mail()` はコード変更なしにそのままSMTP経由で送信されるようになります。 有効化すると、WordPressコンテナ起動時に `msmtp` を導入し、PHPの `sendmail_path` を `msmtp` 経由に設定します。`wp_mail()` はコード変更なしにそのままSMTP経由で送信されるようになります。
#### secret-manager チャートとの連携(メール設定の一元管理)
別リポジトリの **secret-manager** チャートが `cred-gmail` などに生成する完成済み `msmtprc` を
そのまま使う場合(メール設定の変更は secret-manager 側だけで済みます):
```yaml
smtp:
enabled: true
from: "no-reply@your-domain.com" # PHP の sendmail_from 用に必要
existingMsmtprcSecret: "cred-gmail" # このSecretの msmtprc キーをそのまま利用
```
サーバ設定は values に残し、パスワードだけ一元管理したい場合:
```yaml
smtp:
enabled: true
host: "smtp.gmail.com"
port: 587
auth:
enabled: true
username: "no-reply@your-domain.com"
existingSecret: "cred-gmail"
existingSecretKey: "SMTP_PASSWORD"
```
**設定例**: **設定例**:
```yaml ```yaml
@@ -177,6 +207,32 @@ helm upgrade --install my-wordpress . \
**注意**: `smtp.enabled: true` の場合、msmtpのインストール(`apk add`)のためWordPressコンテナはrootとして起動し、セットアップ完了後に `php-fpm` へexecします。PHP-FPMのワーカープロセス自体はイメージ標準の設定により引き続き `www-data`(非root)で動作するため、実際のPHPコード実行権限は変わりません。`smtp.enabled: false`(デフォルト)の場合は従来どおり非rootユーザー(uid82)でコンテナが起動します。 **注意**: `smtp.enabled: true` の場合、msmtpのインストール(`apk add`)のためWordPressコンテナはrootとして起動し、セットアップ完了後に `php-fpm` へexecします。PHP-FPMのワーカープロセス自体はイメージ標準の設定により引き続き `www-data`(非root)で動作するため、実際のPHPコード実行権限は変わりません。`smtp.enabled: false`(デフォルト)の場合は従来どおり非rootユーザー(uid82)でコンテナが起動します。
### 追加の環境変数(extraEnvFrom / extraEnv)
WordPress(php-fpm)コンテナに任意の環境変数を渡します。プラグインが読む API キー等を、
別リポジトリの **secret-manager** チャートが配布する `cred-<名前>` Secret から注入する用途を
想定しています。認証情報の変更は secret-manager 側を更新するだけで反映できます。
| パラメータ | 説明 | デフォルト値 |
|-----------|------|-------------|
| `extraEnvFrom` | 既存の Secret / ConfigMap をまるごと環境変数として注入(`envFrom` 配列) | `[]` |
| `extraEnv` | 個別の環境変数を追加(生の `env` エントリ配列。`valueFrom`/`secretKeyRef` 可) | `[]` |
```yaml
extraEnvFrom:
- secretRef:
name: cred-gemini # GEMINI_API_KEY 等が丸ごと環境変数になる
extraEnv:
- name: ANTHROPIC_API_KEY
valueFrom:
secretKeyRef:
name: cred-claude
key: ANTHROPIC_API_KEY
```
PHP 側では `getenv('GEMINI_API_KEY')` で取得できます(初期化用の initContainer には注入されず、
稼働中の WordPress コンテナにのみ渡ります)。
### Service設定 ### Service設定
| パラメータ | 説明 | デフォルト値 | | パラメータ | 説明 | デフォルト値 |
+1 -1
View File
@@ -1,4 +1,4 @@
{{- if .Values.smtp.enabled }} {{- if and .Values.smtp.enabled (not .Values.smtp.existingMsmtprcSecret) }}
apiVersion: v1 apiVersion: v1
kind: ConfigMap kind: ConfigMap
metadata: metadata:
+24 -4
View File
@@ -321,7 +321,11 @@ spec:
sendmail_from = "{{ .Values.smtp.from }}" sendmail_from = "{{ .Values.smtp.from }}"
PHP_SMTP_EOF PHP_SMTP_EOF
{{- if .Values.smtp.existingMsmtprcSecret }}
echo "SMTP configured from existing secret: {{ .Values.smtp.existingMsmtprcSecret }}"
{{- else }}
echo "SMTP configured: {{ .Values.smtp.host }}:{{ .Values.smtp.port }}" echo "SMTP configured: {{ .Values.smtp.host }}:{{ .Values.smtp.port }}"
{{- end }}
exec php-fpm exec php-fpm
{{- else }} {{- else }}
command: ["php-fpm"] command: ["php-fpm"]
@@ -343,6 +347,13 @@ spec:
key: db-password key: db-password
- name: WORDPRESS_TABLE_PREFIX - name: WORDPRESS_TABLE_PREFIX
value: {{ .Values.wordpress.tablePrefix | quote }} value: {{ .Values.wordpress.tablePrefix | quote }}
{{- with .Values.extraEnv }}
{{- toYaml . | nindent 12 }}
{{- end }}
{{- with .Values.extraEnvFrom }}
envFrom:
{{- toYaml . | nindent 12 }}
{{- end }}
volumeMounts: volumeMounts:
- name: wordpress-data - name: wordpress-data
mountPath: /var/www/html mountPath: /var/www/html
@@ -352,7 +363,7 @@ spec:
- name: smtp-config - name: smtp-config
mountPath: /etc/smtp-config mountPath: /etc/smtp-config
readOnly: true readOnly: true
{{- if .Values.smtp.auth.enabled }} {{- if and .Values.smtp.auth.enabled (not .Values.smtp.existingMsmtprcSecret) }}
- name: smtp-secrets - name: smtp-secrets
mountPath: /etc/smtp-secrets mountPath: /etc/smtp-secrets
readOnly: true readOnly: true
@@ -380,17 +391,26 @@ spec:
{{- end }} {{- end }}
{{- if .Values.smtp.enabled }} {{- if .Values.smtp.enabled }}
- name: smtp-config - name: smtp-config
{{- if .Values.smtp.existingMsmtprcSecret }}
# 完成済み msmtprc を持つ既存 Secret(secret-manager の cred-* 等)を利用
secret:
secretName: {{ .Values.smtp.existingMsmtprcSecret }}
items:
- key: {{ .Values.smtp.existingMsmtprcSecretKey | default "msmtprc" }}
path: msmtprc
{{- else }}
configMap: configMap:
name: {{ include "wordpress-nginx.fullname" . }}-smtp-config name: {{ include "wordpress-nginx.fullname" . }}-smtp-config
items: items:
- key: msmtprc - key: msmtprc
path: msmtprc path: msmtprc
{{- if .Values.smtp.auth.enabled }} {{- end }}
{{- if and .Values.smtp.auth.enabled (not .Values.smtp.existingMsmtprcSecret) }}
- name: smtp-secrets - name: smtp-secrets
secret: secret:
secretName: {{ include "wordpress-nginx.fullname" . }}-smtp secretName: {{ .Values.smtp.auth.existingSecret | default (printf "%s-smtp" (include "wordpress-nginx.fullname" .)) }}
items: items:
- key: password - key: {{ .Values.smtp.auth.existingSecretKey | default "password" }}
path: password path: password
# 0600だとSecretボリュームの所有者はroot、 # 0600だとSecretボリュームの所有者はroot、
# msmtpはPHP-FPMワーカー(www-data等の非root)から実行されるため読めない # msmtpはPHP-FPMワーカー(www-data等の非root)から実行されるため読めない
+1 -1
View File
@@ -1,4 +1,4 @@
{{- if .Values.smtp.enabled }} {{- if and .Values.smtp.enabled (not .Values.smtp.existingMsmtprcSecret) (not .Values.smtp.auth.existingSecret) }}
apiVersion: v1 apiVersion: v1
kind: Secret kind: Secret
metadata: metadata:
+38
View File
@@ -69,6 +69,15 @@ smtp:
# helm install ... --set smtp.auth.password='your-password' 等で指定 # helm install ... --set smtp.auth.password='your-password' 等で指定
password: "" password: ""
# 【外部Secret連携】チャートで msmtprc を生成しつつ、パスワードファイルだけ
# 既存 Secret から取りたい場合に指定する。
# 例: secret-manager チャートが配布する cred-<プロバイダ> の SMTP_PASSWORD キー
# existingSecret: "cred-gmail"
# existingSecretKey: "SMTP_PASSWORD"
# 指定時は smtp.auth.password と自作の -smtp Secret は使われない。
existingSecret: ""
existingSecretKey: "password"
# 送信元アドレス(固定値。wp-config.phpやプラグイン側の指定より優先されます) # 送信元アドレス(固定値。wp-config.phpやプラグイン側の指定より優先されます)
from: "noreply@example.com" from: "noreply@example.com"
@@ -79,6 +88,35 @@ smtp:
# 自己署名証明書を許可する場合(テスト環境のみ) # 自己署名証明書を許可する場合(テスト環境のみ)
allowSelfSigned: false allowSelfSigned: false
# 【外部Secret連携】完成済みの msmtprc がまるごと入っている既存 Secret を使う。
# 指定するとチャート内の msmtprc 生成(configmap-smtp)は行わず、
# host / port / protocol / auth.* / tls.* は無視される(from だけ PHP の
# sendmail_from 用に使用)。
# secret-manager チャートが cred-<プロバイダ> に生成する msmtprc キーを
# そのまま利用できる:
# existingMsmtprcSecret: "cred-gmail"
# existingMsmtprcSecretKey: "msmtprc"
existingMsmtprcSecret: ""
existingMsmtprcSecretKey: "msmtprc"
# 既存の Secret / ConfigMap をまるごと環境変数として wordpress コンテナへ注入する(envFrom)。
# 別リポジトリの secret-manager チャートが各ネームスペースへ配布する
# cred-<名前> Secret(API キー等)をそのまま読み込む用途を想定。
# 変更は secret-manager 側を更新するだけで全プロジェクトに反映できる。
extraEnvFrom: []
# - secretRef:
# name: cred-gemini
# - secretRef:
# name: cred-openai
# 個別の環境変数を追加する(生の env エントリ配列。value / valueFrom(secretKeyRef 等) 使用可)。
extraEnv: []
# - name: OPENAI_API_KEY
# valueFrom:
# secretKeyRef:
# name: cred-openai
# key: OPENAI_API_KEY
nginx: nginx:
# Ingress ControllerやCDN(Cloudflare等)、外部LB等、X-Forwarded-Forヘッダーを # Ingress ControllerやCDN(Cloudflare等)、外部LB等、X-Forwarded-Forヘッダーを
# 付与するリバースプロキシを前段に置く場合にのみ有効にしてください。 # 付与するリバースプロキシを前段に置く場合にのみ有効にしてください。