diff --git a/CLAUDE.md b/CLAUDE.md index 5bf746d..33d4d9f 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -61,6 +61,30 @@ ## チャート改修履歴 +### renderMsmtprc を既定 true 化 + SMTP メタ項目の拡充(2026-09-08, v0.1.2) + +**症状**: phpfpm 側で `smtp.existingMsmtprcSecret: cred-<名前>` を指定したら +`MountVolume.SetUp failed ... references non-existent secret key: msmtprc`。 +配布された `cred-*` Secret に `msmtprc` キーが無かった。 + +**原因**: `mail.providers.<名前>.renderMsmtprc` が opt-in(既定で出力しない)で、 +`values.yaml` 上もコメント例にしか無かったため、指定を忘れると `msmtprc` キーが +生成されない。`mail` カテゴリは「完成済み msmtprc も含めて一元管理する」のが目的なので +opt-out にすべきだった。 + +**修正内容**(`templates/mail-secrets.yaml`): +- `renderMsmtprc` を既定 `true` に(`hasKey` で明示 `false` のときだけ抑止)。 +- `smtp.tlsVerify`(既定 `true`)を追加。`false` で `msmtprc` に `tls_certcheck off` を挿入。 + `values.schema.json` の `smtp`(`additionalProperties: false`)にも `tlsVerify` を追加。 +- 派生キーを Secret に追加: `SMTP_TLS`(starttls か)/ `SMTP_SSL`(暗黙TLSか)/ + `SMTP_TLS_VERIFY` / `SMTP_AUTH`(username 有無)。すべて `"true"`/`"false"` の文字列。 + `smtp.env` にもこれらが入る(msmtprc 生成より前に env を組み立てているため)。 +- `values.yaml` のキー一覧コメント / プロバイダ例、`examples/mail-providers.values.yaml` + (`tlsVerify: false` の社内リレー例を追加)、README を更新。 + +**対象ファイル**: `templates/mail-secrets.yaml`, `values.schema.json`, `values.yaml`, +`examples/mail-providers.values.yaml`, `Chart.yaml`, `README.md`, `CLAUDE.md` + ### helm-release.yaml のリリース判定を3系統に分離 + v0.1.0 タグ補完(2026-09-08) **症状**: Git タグ `v0.1.0` がリモートに存在しなかった(Registry には diff --git a/Chart.yaml b/Chart.yaml index c08b741..b712496 100644 --- a/Chart.yaml +++ b/Chart.yaml @@ -4,8 +4,8 @@ description: >- クラスター横断で使う認証情報(外部メールのSMTP/IMAP設定・APIキー・汎用資格情報)を 一元管理し、複数ネームスペースへ同一Secretとして配布するHelmチャート。 type: application -version: 0.1.1 -appVersion: "0.1.1" +version: 0.1.2 +appVersion: "0.1.2" keywords: - secrets - credentials diff --git a/README.md b/README.md index 624a789..1e45733 100644 --- a/README.md +++ b/README.md @@ -152,9 +152,10 @@ SMTP/IMAP/POP3 のサーバ情報も一元管理** できます。 | `smtp.fromName` | `string` | | 送信者表示名。 | | `smtp.replyTo` | `string` | | Reply-To アドレス。 | | `smtp.authMethod` | `string` | | `plain`(既定) / `login` / `cram-md5`。 | +| `smtp.tlsVerify` | `bool` | | 既定 `true`。`false` で TLS 証明書検証を無効化(社内リレー・自己署名向け。生成される `msmtprc` に `tls_certcheck off` が入る)。 | | `imap.host` ほか | | | 受信 (IMAP) 情報。`host` があれば `IMAP_*` キーを追加。`username`/`password` 省略時は SMTP の値を流用。既定ポート `993`。 | | `pop3.host` ほか | | | 受信 (POP3) 情報。同上。既定ポート `995`。 | -| `renderMsmtprc` | `bool` | | `true` で Secret に `msmtprc`(msmtp / PHP sendmail 用設定)を含める。 | +| `renderMsmtprc` | `bool` | | **既定 `true`**。Secret に完成済み `msmtprc`(msmtp / PHP sendmail 用)を含める。IMAP だけ使う等で不要なら `false`。 | | `namespacesOverride` | `[]string` | | このエントリだけ別のネームスペースへ配布する。 | | `annotations` | `map` | | このエントリの Secret だけに付ける追加アノテーション。 | @@ -192,8 +193,12 @@ SMTP/IMAP/POP3 のサーバ情報も一元管理** できます。 SMTP_HOST=smtp.gmail.com SMTP_PORT=587 SMTP_SECURITY=starttls +SMTP_TLS=true # security=starttls のとき true(派生フラグ) +SMTP_SSL=false # security=tls(暗黙TLS)のとき true +SMTP_TLS_VERIFY=true # smtp.tlsVerify の値 SMTP_USERNAME=no-reply@example.com SMTP_PASSWORD=******** +SMTP_AUTH=true # username があれば true SMTP_FROM=no-reply@example.com SMTP_FROM_NAME=Example SMTP_REPLY_TO= @@ -203,11 +208,10 @@ IMAP_PORT=993 IMAP_SECURITY=tls IMAP_USERNAME=no-reply@example.com IMAP_PASSWORD=******** -smtp.env # ↓ source して使える env ファイル +smtp.env # ↑ 全キーを `export KEY="value"` にした source 可能なファイル export SMTP_HOST="smtp.gmail.com" - export SMTP_PORT="587" ... -msmtprc # renderMsmtprc: true のとき。msmtp / PHP sendmail 用 +msmtprc # 完成済み msmtp 設定(既定で常に含む。renderMsmtprc: false で抑止) ``` ### api / generic エントリ @@ -351,6 +355,16 @@ Secret 更新時に自動でローリング再起動されます。 各リリースの詳細は `CLAUDE.md` の「チャート改修履歴」を参照。 +### v0.1.2(2026-09-08) + +- **`renderMsmtprc` の既定を `true` に変更**。`mail.providers.<名前>` を定義すれば + `msmtprc` キーが常に生成されるようになった(従来は明示 `true` が必要で、忘れると + phpfpm 等の `smtp.existingMsmtprcSecret` が `references non-existent secret key: msmtprc` + でマウント失敗した)。不要なら `renderMsmtprc: false`。 +- `smtp.tlsVerify`(既定 `true`)を追加。`false` で `msmtprc` に `tls_certcheck off` を出力。 +- 派生キー `SMTP_TLS` / `SMTP_SSL` / `SMTP_TLS_VERIFY` / `SMTP_AUTH` を Secret に追加 + (フレームワーク側が 3 値 enum を解釈しなくて済むよう真偽値文字列で提供)。 + ### v0.1.1(2026-09-08) - `values.schema.json` の `$schema` 行を削除。新しめの JSON Schema バリデータを内蔵する diff --git a/examples/mail-providers.values.yaml b/examples/mail-providers.values.yaml index c267e3a..3a8bb53 100644 --- a/examples/mail-providers.values.yaml +++ b/examples/mail-providers.values.yaml @@ -41,7 +41,7 @@ mail: host: "imap.gmail.com" port: 993 security: "tls" - renderMsmtprc: true + renderMsmtprc: true # 既定値なので本来は省略可 # ---- Microsoft 365 / Exchange Online --------------------------------- m365: @@ -58,7 +58,7 @@ mail: host: "outlook.office365.com" port: 993 security: "tls" - renderMsmtprc: true + renderMsmtprc: true # 既定値なので本来は省略可 # ---- SendGrid ------------------------------------------------------- # username は固定文字列 "apikey"、password が API キー本体。 @@ -73,7 +73,7 @@ mail: from: "no-reply@your-domain.com" fromName: "Your Service" authMethod: "plain" - renderMsmtprc: true + renderMsmtprc: true # 既定値なので本来は省略可 # ---- Amazon SES --------------------------------------------------- # SES SMTP 認証情報(IAM のアクセスキーとは別物)を使う。リージョンをホスト名に反映。 @@ -87,7 +87,7 @@ mail: password: "REPLACE_VIA_--set" from: "no-reply@your-domain.com" authMethod: "login" - renderMsmtprc: true + renderMsmtprc: true # 既定値なので本来は省略可 # ---- Mailgun ----------------------------------------------------- mailgun: @@ -100,7 +100,7 @@ mail: password: "REPLACE_VIA_--set" from: "no-reply@your-domain.com" authMethod: "plain" - renderMsmtprc: true + renderMsmtprc: true # 既定値なので本来は省略可 # ---- 汎用 / 社内 SMTP リレー(認証なし・TLSなし)-------------------- internal-relay: @@ -110,4 +110,15 @@ mail: port: 25 security: "none" from: "no-reply@your-domain.com" - renderMsmtprc: true + + # ---- 社内 SMTP(自己署名証明書。STARTTLS だが証明書検証はしない)------ + internal-tls-relay: + enabled: false + smtp: + host: "mail.internal.example" + port: 587 + security: "starttls" + username: "app" + password: "REPLACE_VIA_--set" + from: "no-reply@your-domain.com" + tlsVerify: false # 自己署名のため証明書検証を無効化(msmtprc に tls_certcheck off) diff --git a/templates/mail-secrets.yaml b/templates/mail-secrets.yaml index 1db34d2..0df865f 100644 --- a/templates/mail-secrets.yaml +++ b/templates/mail-secrets.yaml @@ -13,12 +13,22 @@ mail.providers. ごとに 1 つの Secret を生成し、配布先ネー {{- $username := $smtp.username | default "" }} {{- $password := $smtp.password | default "" }} {{- $from := $smtp.from | default $username }} +{{- /* tlsVerify は既定 true。明示 false で証明書検証を無効化(社内リレー等) */ -}} +{{- $tlsVerify := true }} +{{- if hasKey $smtp "tlsVerify" }}{{- $tlsVerify = $smtp.tlsVerify }}{{- end }} +{{- /* renderMsmtprc は既定 true。明示 false で msmtprc キーを出力しない */ -}} +{{- $renderMsmtprc := true }} +{{- if hasKey $p "renderMsmtprc" }}{{- $renderMsmtprc = $p.renderMsmtprc }}{{- end }} {{- $sd := dict }} {{- $_ := set $sd "SMTP_HOST" (printf "%v" $smtp.host) }} {{- $_ := set $sd "SMTP_PORT" (printf "%v" ($smtp.port | default 587)) }} {{- $_ := set $sd "SMTP_SECURITY" (printf "%v" $security) }} +{{- $_ := set $sd "SMTP_TLS" (ternary "true" "false" (eq $security "starttls")) }} +{{- $_ := set $sd "SMTP_SSL" (ternary "true" "false" (eq $security "tls")) }} +{{- $_ := set $sd "SMTP_TLS_VERIFY" (ternary "true" "false" $tlsVerify) }} {{- $_ := set $sd "SMTP_USERNAME" (printf "%v" $username) }} {{- $_ := set $sd "SMTP_PASSWORD" (printf "%v" $password) }} +{{- $_ := set $sd "SMTP_AUTH" (ternary "true" "false" (ne $username "")) }} {{- $_ := set $sd "SMTP_FROM" (printf "%v" $from) }} {{- $_ := set $sd "SMTP_FROM_NAME" (printf "%v" ($smtp.fromName | default "")) }} {{- $_ := set $sd "SMTP_REPLY_TO" (printf "%v" ($smtp.replyTo | default "")) }} @@ -41,21 +51,25 @@ mail.providers. ごとに 1 つの Secret を生成し、配布先ネー {{- $_ := set $sd "POP3_USERNAME" (printf "%v" ($pop3.username | default $username)) }} {{- $_ := set $sd "POP3_PASSWORD" (printf "%v" ($pop3.password | default $password)) }} {{- end }} -{{- /* source 可能な env ファイル */ -}} +{{- /* source 可能な env ファイル(msmtprc 追加より前に生成する) */ -}} {{- $lines := list }} {{- range $k, $v := $sd }} {{- $lines = append $lines (printf "export %s=%s" $k (quote $v)) }} {{- end }} {{- $_ := set $sd "smtp.env" (printf "%s\n" (join "\n" (sortAlpha $lines))) }} -{{- /* msmtprc スニペット(任意) */ -}} -{{- if $p.renderMsmtprc }} +{{- /* msmtprc スニペット(既定で含む。renderMsmtprc: false で抑止) */ -}} +{{- if $renderMsmtprc }} {{- $tls := "tls on" }} {{- $starttls := "tls_starttls on" }} {{- if eq $security "tls" }}{{- $starttls = "tls_starttls off" }}{{- end }} {{- if eq $security "none" }}{{- $tls = "tls off" }}{{- $starttls = "tls_starttls off" }}{{- end }} +{{- $certcheck := "" }} +{{- if not $tlsVerify }}{{- $certcheck = "tls_certcheck off\n" }}{{- end }} {{- $auth := "auth off" }} {{- if $username }}{{- $auth = printf "auth on\nuser %s\npassword %s" $username $password }}{{- end }} -{{- $msmtprc := printf "# secret-manager が生成 (%s)\ndefaults\n%s\n%s\ntls_trust_file /etc/ssl/certs/ca-certificates.crt\nlogfile -\naccount default\nhost %s\nport %v\nfrom %s\n%s\n" $name $tls $starttls $smtp.host ($smtp.port | default 587) $from $auth }} +{{- $fromLine := "" }} +{{- if $from }}{{- $fromLine = printf "from %s\n" $from }}{{- end }} +{{- $msmtprc := printf "# secret-manager が生成 (%s)\ndefaults\n%s\n%s\n%stls_trust_file /etc/ssl/certs/ca-certificates.crt\nlogfile -\naccount default\nhost %s\nport %v\n%s%s\n" $name $tls $starttls $certcheck $smtp.host ($smtp.port | default 587) $fromLine $auth }} {{- $_ := set $sd "msmtprc" $msmtprc }} {{- end }} {{- include "secret-manager.secret" (dict "ctx" $ "name" $name "stringData" $sd "type" "Opaque" "annotations" ($p.annotations | default dict) "namespacesOverride" ($p.namespacesOverride | default list)) }} diff --git a/values.schema.json b/values.schema.json index a7d0f3c..bb80e2d 100644 --- a/values.schema.json +++ b/values.schema.json @@ -74,7 +74,8 @@ "from": { "type": "string" }, "fromName": { "type": "string" }, "replyTo": { "type": "string" }, - "authMethod": { "type": "string", "enum": ["plain", "login", "cram-md5"] } + "authMethod": { "type": "string", "enum": ["plain", "login", "cram-md5"] }, + "tlsVerify": { "type": "boolean" } } }, "imap": { diff --git a/values.yaml b/values.yaml index 323d29f..39ce09a 100644 --- a/values.yaml +++ b/values.yaml @@ -65,20 +65,28 @@ common: # mail: 外部メールの接続情報(パスワード + サーバ情報) # -------------------------------------------------------------------------- # providers.<キー> ごとに 1 つの Secret を生成する。Secret には以下が入る: -# 個別キー: -# SMTP_HOST / SMTP_PORT / SMTP_SECURITY / SMTP_USERNAME / SMTP_PASSWORD +# 個別キー(送信 SMTP): +# SMTP_HOST / SMTP_PORT / SMTP_SECURITY (none|starttls|tls) +# SMTP_TLS ... "true" if starttls (フレームワーク互換の派生フラグ) +# SMTP_SSL ... "true" if 暗黙TLS(tls) (同上) +# SMTP_TLS_VERIFY ... 証明書検証 "true"/"false" +# SMTP_USERNAME / SMTP_PASSWORD / SMTP_AUTH ("true" if username あり) # SMTP_FROM / SMTP_FROM_NAME / SMTP_REPLY_TO / SMTP_AUTH_METHOD +# 個別キー(受信・任意): # IMAP_HOST / IMAP_PORT / IMAP_SECURITY / IMAP_USERNAME / IMAP_PASSWORD (imap 定義時) # POP3_HOST / POP3_PORT / POP3_SECURITY / POP3_USERNAME / POP3_PASSWORD (pop3 定義時) # まとめ: # smtp.env ... `export KEY=VALUE` 形式。コンテナ内で `source` して利用可能 -# msmtprc ... msmtp / PHP sendmail 用設定(renderMsmtprc: true のとき) +# msmtprc ... msmtp / PHP sendmail 用の完成済み設定ファイル +# ★ 既定で常に含まれる。抑止したい場合のみ renderMsmtprc: false # # 代表的なプロバイダの設定値は examples/ および README.md の一覧表を参照。 mail: providers: {} # gmail: # enabled: true + # # msmtprc キーを出力するか(既定 true)。IMAP だけ使いたい等で不要なら false + # renderMsmtprc: true # smtp: # host: "smtp.gmail.com" # port: 587 @@ -89,6 +97,7 @@ mail: # fromName: "Example" # replyTo: "" # authMethod: "plain" # plain | login | cram-md5 + # tlsVerify: true # false で証明書検証を無効化(社内リレー等) # imap: # host: "imap.gmail.com" # port: 993 @@ -99,7 +108,6 @@ mail: # # host: "pop.gmail.com" # # port: 995 # # security: "tls" - # renderMsmtprc: true # # このプロバイダだけ別ネームスペースへ配る場合(省略時は distribution 準拠) # namespacesOverride: [] # # このプロバイダ Secret だけに付ける追加アノテーション