Japan Server Error Fix Lab

ホーム / Kubernetes / Kubernetes

Kubernetes Service 503 プロキシとオリジン差分

Kubernetes で Service 503 が発生した時に、プロキシとオリジン差分 の観点で原因、出力例、分岐対応、避ける操作を整理します。

mediumService 5036 分で読む
最初の確認コマンド
grep -R "Service 503" ./logs
最初に見る証拠

Service 503 は「プロキシとオリジン差分」として確認します。最初に見る証拠は whether the edge/proxy or the origin server creates the failure です。

検索クエリ
Kubernetes Service 503Kubernetes error Service 503Kubernetes Service 503 プロキシとオリジン差分

この状況で発生します

A CDN, load balancer, reverse proxy, or WAF sits in front of the service. 画面上の文言だけで判断せず、まず whether the edge/proxy or the origin server creates the failure を確認し、正常出力と失敗出力を比較します。

症状チェック

  • Service 503 が Kubernetes の画面またはログで繰り返されます。
  • events, describe, probes, requests, image pull が正常ケースと失敗ケースで異なります。
  • pod internal error from cluster scheduling issue を分けた時だけ問題が見えます。
  • リリース、権限、設定、データ更新の直後に起きやすいです。

可能性が高い原因

  • upstream failure caused by unhealthy target, wrong backend port, proxy timeout, FastCGI handoff, or load balancer health check mismatch.
  • プロキシとオリジン差分 では whether the edge/proxy or the origin server creates the failure が最初の手掛かりです。
  • 正常ケースと失敗ケースを比較しないと原因候補が広がりすぎます。
  • キャッシュ、権限、ネットワーク、プロキシ状態が一部ユーザーだけ違って見えることがあります。

1分で先に確認

  1. 初回発生時刻、直近変更、影響ユーザー、URL、オブジェクトIDを記録します。
  2. 正常/失敗ケースで events, describe, probes, requests, image pull を同じ時間帯に比較します。
  3. 仮説を確認します: upstream failure caused by unhealthy target, wrong backend port, proxy timeout, FastCGI handoff, or load balancer health check mismatch.
  4. プロキシとオリジン差分 かを判断します: whether the edge/proxy or the origin server creates the failure.
  5. 設定変更前に現在値を保存します。

最初に見る証拠

Service 503 は「プロキシとオリジン差分」として確認します。最初に見る証拠は whether the edge/proxy or the origin server creates the failure です。

出力例

正常出力

Direct origin and routed proxy return equivalent status and headers.

失敗出力

Origin succeeds but proxy fails, or proxy succeeds while direct origin exposes the real backend error.

出力別の判断

  • A CDN, load balancer, reverse proxy, or WAF sits in front of the service.
    Test direct origin and routed traffic separately, then change only the layer that differs.
  • 正常ケースと失敗ケースの出力が違います。
    差分が出たレイヤーで先に対応します: For Service 503, apply the fix only after reproducing the same condition and saving the before/after evidence for this exact code.
  • コマンドは正常でもユーザー画面だけ失敗します。
    キャッシュ、Cookie、権限、ネットワーク位置を分けて確認します。

避ける操作

  • Do not assume the CDN error code is the application root cause.
  • 原因レイヤーを確認する前に複数設定を同時変更しないでください。
  • データ削除、広い権限付与、全面的なセキュリティ無効化を初動対応にしないでください。

検証状態

自動生成ドラフト: コード別の原因、コマンド、出力分岐、避ける操作を含みます。公式ドキュメントと実運用検証は継続して補強します。

先に実行するコマンド

grep -R "Service 503" ./logs
kubectl describe pod POD
kubectl get events --sort-by=.lastTimestamp
kubectl logs POD --previous
kubectl describe ingress INGRESS
curl -Iv http://127.0.0.1:3000/health
grep -R "upstream\|502\|503\|504\|proxy_fcgi" ./logs /var/log/nginx
systemctl status nginx php-fpm
curl -Iv https://example.com --resolve example.com:443:ORIGIN_IP

解決順序

  1. Service 503 の全文、失敗URL、ユーザー、オブジェクトID、直近変更を記録します。
  2. upstream failure caused by unhealthy target, wrong backend port, proxy timeout, FastCGI handoff, or load balancer health check mismatch に合う証拠を先に集めます。
  3. 失敗ケースと正常ケースを同じコマンドで比較します。
  4. プロキシとオリジン差分 の分岐なら Test direct origin and routed traffic separately, then change only the layer that differs.
  5. 同じURLと同じコマンドで再検証し、正常出力を記録します。

原因別の対応

  • For Service 503, apply the fix only after reproducing the same condition and saving the before/after evidence for this exact code.
  • Test the backend directly before changing the public proxy.
  • Align health check path, host header, port, and expected status.
  • Restart or scale the failing worker pool after checking logs.
  • Tune proxy and app timeouts together.
  • Record the working direct-backend command in the runbook.
  • プロキシとオリジン差分 の分岐では Test direct origin and routed traffic separately, then change only the layer that differs.

検証メタ

  • operator-draft
  • official-reference-linked
  • 2026-07-23

更新キュー

  • 更新周期
    weekly-source-review
  • 次の補強
    Add one official-source check and one real output example for Kubernetes Service 503.

環境別の確認ポイント

  • 共有ホスティング、プロキシ、VPN、CDN は pod internal error from cluster scheduling issue の結果を変えることがあります。
  • Kubernetes の管理画面だけでなくコマンド出力と比較します。
  • 日本のホスティング管理画面は完了表示でも DNS/SSL 反映が遅れることがあります。
  • 社内ネットワークと外部ネットワークの両方で確認します。

再発させないために

  • events, describe, probes, requests, image pull の正常出力例を保存します。
  • probes, resource limits, secrets, service selectors, ingress をリリースチェックリストに追加します。
  • 繰り返されるエラーは同じ形式の対応ノートに残します。
  • エラー率、遅延、証明書、ディスク、権限変更のアラートを分けます。