バッチ処理をEKSからCodeBuildを使ったGitHub Self-hosted Runn...

Sponsored · Your Podcast. Everywhere. Effortlessly. Share. Educate. Inspire. Entertain. You do you. We'll handle the rest. →
t-kikuchi
October 11, 2025

バッチ処理をEKSからCodeBuildを使ったGitHub Self-hosted Runnerに変更した話

バッチ処理をEKSからCodeBuildを使ったGitHub Self-hosted Runnerに変更した話

t-kikuchi

October 11, 2025

Annual Pro sale · Save $30

Have presentations of your own?

Share with private links, password protection, and more control over your work.

Transcript

32 slides
  1. エラー内容 Connection to 169.254.170.23 failed (110) Connection timed out 原因

    Pod Identity Agent専用エンドポイント 169.254.170.23 が HTTP_PROXY 環境変数によりプロキ シ経由でアクセスされていた NO_PROXY に 169.254.0.0/16 を追加しても解決せず デバッグの困難さ Sysdig Registry Scanner Podのログ: 上記エラー以外の情報なし Pod Identity自体のログ: もしかしたらノード上にはログがあった?当時はそこまで思い至らな かったので調査に難航 トラブル1: Pod Identity認証の失敗 9
  2. エラー内容 scan failed for image: scan execution failed for job

    'registry-scanner-worker-j9l4n-5': unable to obtain job errors: no logs found: error getting logs from pod registry-scanner-worker-j9l4n-5-v7mrk: no errors found in logs 状況 ワーカーPod: スキャン処理は成功、 Completed ステータス オーケストレーターPod: ワーカーPodからログ取得失敗、 Error ステータス 結果: 実際のスキャンは成功しているのに、全体が失敗扱いに トラブル2: オーケストレーターとワーカーPod間の通信エラー 11
  3. 詳細調査の実施 1. RBAC権限の確認: ServiceAccountの pods/log 権限を検証 → 問題なし 2. デバッグPodでの検証:

    # プロキシ経由(失敗) curl "http://10.x.x.59:10250/..." → Connection timeout(Squidプロキシ経由になっている) # プロキシバイパス(成功) curl --noproxy '*' "http://10.x.x.59:10250/..." → 正常に応答 3. CIDR記法の検証結果: NO_PROXY: "10.0.0.0/8" → 認識されない NO_PROXY: "10.x.x.0/26,10.x.x.64/26" → 認識されない 最終判断: プロキシ環境でのトラブルシューティングが極めて困難。根本原因を特定できず解決 の目処が立たない → EKS環境を廃止し、CodeBuildへ移行を決定 トラブル2: オーケストレーターとワーカーPod間の通信エラー 13
  4. name: ECR Security Scan on: workflow_dispatch: # 手動実行を有効化 schedule: -

    cron: '0 2 * * *' # 定期実行 jobs: get_images: runs-on: - codebuild-test-cs-${{ vars.ENVIRONMENT }}-github-actions-runner-${{ github.run_id }}-${{ github.run_attempt }} outputs: matrix: ${{ steps.set_matrix.outputs.matrix }} steps: - name: Get all images and set matrix id: set_matrix run: | # ECRから全イメージタグを取得してJSON配列化 for REPO in "${REPOS_ARRAY[@]}"; do TAGS=$(aws ecr describe-images --repository-name "$REPO" --query 'imageDetails[?imageTags!=null].imageTags[]' --output text) for TAG in $TAGS; do echo "${ECR_REGISTRY}/${REPO}:${TAG}" >> "$IMAGE_LIST_FILE" done done IMAGE_JSON_ARRAY=$(cat "$IMAGE_LIST_FILE" | jq -R . | jq -s .) echo "matrix={\"image\":${IMAGE_JSON_ARRAY}}" >> $GITHUB_OUTPUT 23
  5. sysdig_scan: needs: get_images runs-on: - codebuild-test-cs-${{ vars.ENVIRONMENT }}-github-actions-runner-${{ github.run_id }}-${{

    github.run_attempt }} strategy: fail-fast: false max-parallel: 3 # 3個ずつ並列実行 matrix: ${{ fromJson(needs.get_images.outputs.matrix) }} steps: - name: Pull Docker image env: ECR_IMAGE: ${{ matrix.image }} run: docker pull ${ECR_IMAGE} - name: Scan Docker image # Sysdigスキャン実行 技術的工夫 動的マトリックス生成: ECRイメージリストを動的に配列化してmatrixに展開 並列処理: matrix strategyで3個並列実行( max-parallel: 3 ) 24
  6. ワークフロー定義 Step Functions: JSON/YAMLで状態マシン定義、独自の記法 + EventBridge設定 GitHub Actions + CodeBuild:

    1つのYAMLファイルで完結 エコシステム Step Functions: AWS内のサービス統合に特化 GitHub Actions + CodeBuild: GitHubの機能統合(PR連携、Issue通知、コードレビュー 等) 、豊富なMarketplaceアクション 監視・メトリクス Step Functions: デフォルトで豊富なメトリクス、CloudWatchでアラート設定が容易 GitHub Actions + CodeBuild: メトリクス機能はあるが制約が多い(UIベースのみ、アラート 機能なし) 、CodeBuildのCloudWatch Metricsも活用可能 両者の違い 26
  7. ワークフロー定義がシンプル - 1つのYAMLファイルで完結 GitHubに慣れたチームに最適 - GitHub UIでの確認・デバッグが可能 並列処理が簡単に実装できる - matrix

    strategyで宣言的に並列度調整 IAM OIDC IDプロバイダの設定が不要 - CodeBuild側のIAMロールで各AWSサービスにアク セス GitHub Actionsの実行時間課金を気にしなくていい - CodeBuildで実行するため、GitHub Actionsの実行時間枠を消費しない GitHub Actions + CodeBuildの良いところ 27
  8. AWS公式ドキュメント EKS Pod Identity Pod Identity認証の仕組みとProxy設定 Pod Identity Agent Setup

    Pod Identity Agentの詳細とエンドポイント情報 CodeBuild Self-hosted GitHub Actions runners CodeBuildでのセルフホステッドランナー構築方法 GitHub公式ドキュメント Viewing GitHub Actions metrics GitHub Actionsのメトリクス機能と制約 参考資料・リンク 31

More Decks by t-kikuchi

Other Decks in Technology