diff --git a/README-ja.md b/README-ja.md index 6257adf7..f5e7866b 100644 --- a/README-ja.md +++ b/README-ja.md @@ -24,7 +24,7 @@ │ ├── components/ # environment ごとの Helmfile source │ └── manifests/ # Flux が適用するレンダリング済みマニフェスト ├── docs/ # runbook と設計ノート -├── scripts/ # EKS lifecycle / hydration / post-flight 用 helper +├── scripts/ # EKS lifecycle / hydration 用 helper ├── Makefile # EKS teardown entry point └── workflow-config.yaml # environment と stack convention の source of truth ``` diff --git a/README.md b/README.md index a7d2ee81..5e2f37d9 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,7 @@ A PR labeled by `panicboat/deploy-actions` is resolved against `workflow-config. │ ├── components/ # Helmfile sources (per environment) │ └── manifests/ # Rendered output that Flux applies ├── docs/ # Runbooks and design notes -├── scripts/ # EKS lifecycle / hydration / post-flight helpers +├── scripts/ # EKS lifecycle / hydration helpers ├── Makefile # EKS teardown entry points └── workflow-config.yaml # Environments and stack conventions (source of truth) ``` diff --git a/scripts/post-flight/README.md b/scripts/post-flight/README.md deleted file mode 100644 index c7b43a7c..00000000 --- a/scripts/post-flight/README.md +++ /dev/null @@ -1,33 +0,0 @@ -# Post-flight checks - -Cluster deploy / reconcile 後の自動 verify script 群。 - -## Scripts - -| script | purpose | -|---|---| -| `check-pod-identity-injection.sh` | AWS EKS Pod Identity webhook が target Pod に `AWS_CONTAINER_CREDENTIALS_FULL_URI` env を inject しているか probe (= 引き継ぎ事項 #15) | - -## Usage - -```bash -# 認証 (eks-admin role assume) -eks-login - -# probe 実行 (default cluster: eks-production、 region: ap-northeast-1) -bash scripts/post-flight/check-pod-identity-injection.sh - -# exit code 0 = all OK、 1 = injection 不在 Pod あり、 2 = tool / AWS API error -``` - -## Convention - -- 各 script は **single purpose** (= 1 probe / 1 verify) -- stdout に OK / FAIL / INFO line、 stderr に error / summary -- exit code: 0 (= success)、 1 (= fail)、 2 (= prerequisite error) -- ad-hoc manual run + CI / cron 統合の両方で再利用可 - -## Related - -- spec: `docs/superpowers/specs/2026-05-17-pod-identity-injection-detection-design.md` -- backlog: 引き継ぎ事項 #5 (= post-flight check framework 全般) と統合検討 diff --git a/scripts/post-flight/check-pod-identity-injection.sh b/scripts/post-flight/check-pod-identity-injection.sh deleted file mode 100755 index 521d5991..00000000 --- a/scripts/post-flight/check-pod-identity-injection.sh +++ /dev/null @@ -1,79 +0,0 @@ -#!/usr/bin/env bash - -# Probes whether Pod Identity webhook injected AWS_CONTAINER_CREDENTIALS_FULL_URI into matching pods. - -set -euo pipefail - -cluster_name="${1:-eks-production}" -region="${AWS_REGION:-ap-northeast-1}" - -for cmd in aws kubectl jq; do - if ! command -v "$cmd" >/dev/null 2>&1; then - echo "ERROR: $cmd not found in PATH" >&2 - exit 2 - fi -done - -echo "Probing Pod Identity injection on cluster=$cluster_name region=$region" -echo "" - -# Saved credentials allow restoring eks-admin context after unsetting AWS env vars. -saved_key="${AWS_ACCESS_KEY_ID:-}" -saved_secret="${AWS_SECRET_ACCESS_KEY:-}" -saved_token="${AWS_SESSION_TOKEN:-}" - -# Unset role credentials to query EKS associations using caller IAM credentials. -assocs=$( - unset AWS_ACCESS_KEY_ID AWS_SECRET_ACCESS_KEY AWS_SESSION_TOKEN - aws eks list-pod-identity-associations \ - --cluster-name "$cluster_name" \ - --region "$region" \ - --query 'associations[].{ns:namespace,sa:serviceAccount}' \ - --output json -) || { - echo "ERROR: aws eks list-pod-identity-associations failed" >&2 - exit 2 -} - -assoc_count=$(echo "$assocs" | jq 'length') -echo "Found $assoc_count Pod Identity Association(s)" -echo "" - -# Accumulate failures across subshell loop in temp file. -fail_list=$(mktemp) -trap 'rm -f "$fail_list"' EXIT - -echo "$assocs" | jq -c '.[]' | while read -r assoc; do - ns=$(echo "$assoc" | jq -r '.ns') - sa=$(echo "$assoc" | jq -r '.sa') - - pods=$(kubectl get pods -n "$ns" -o json 2>/dev/null | \ - jq -r --arg sa "$sa" '.items[] | select(.spec.serviceAccountName == $sa) | .metadata.name') || pods="" - - if [ -z "$pods" ]; then - echo "INFO: ns=$ns sa=$sa: no Pods using this SA" - continue - fi - - for pod in $pods; do - has_creds=$(kubectl get pod -n "$ns" "$pod" -o json | \ - jq '[.spec.containers[].env? // [] | .[] | select(.name == "AWS_CONTAINER_CREDENTIALS_FULL_URI")] | length') - - if [ "$has_creds" = "0" ]; then - echo "FAIL: ns=$ns sa=$sa pod=$pod: AWS_CONTAINER_CREDENTIALS_FULL_URI not injected" - echo "$ns/$pod" >> "$fail_list" - else - echo "OK: ns=$ns sa=$sa pod=$pod" - fi - done -done - -echo "" - -fail_count=$(wc -l < "$fail_list" | tr -d ' ') -if [ "$fail_count" != "0" ]; then - echo "Detected $fail_count Pod(s) without Pod Identity env injection" >&2 - exit 1 -fi - -echo "All Pod Identity associated Pods have AWS_CONTAINER_CREDENTIALS_FULL_URI injected"