Source controller support for Instance Metadata Service v2 (IMDSv2) on AWS
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 35/100
調査の方向性
この issue では source-controller と minio-go ライブラリが挙げられていますが、リポジトリのファイルやテストはありません。まず、S3 Bucket source の AWS 認証情報の設定と IMDS リクエストを追跡し、次に IMDSv2 を必須とするインスタンスで reconciliation を検証し、トークン認証されたリクエストによって 401 エラーが解消されることを確認してください。
索引モデルが issue の本文から書いたものです。
説明
I get the following error message in source-controller when Flux is configured to use S3 bucket source,:
{
"level": "error",
"ts": "2022-06-03T13:29:32.250Z",
"logger": "controller.bucket",
"msg": "Reconciler error",
"reconciler group": "source.toolkit.fluxcd.io",
"reconciler kind": "Bucket",
"name": "deploy-bucket",
"namespace": "flux-system",
"error": "failed to confirm existence of 'retracted-flux-1ejashffo6o0p' bucket: 401 Unauthorized"
}
I have created the bucket source with the following command:
flux create source bucket deploy-bucket \
--bucket-name=retracted-flux-1ejashffo6o0p \
--provider=aws \
--endpoint=s3.amazonaws.com \
--region=eu-central-1 \
--interval=5m
.. and receive the following error message:
✚ generating Bucket source
► applying Bucket source
✔ Bucket source created
◎ waiting for Bucket source reconciliation
✗ failed to confirm existence of 'retracted-flux-1ejashffo6o0p' bucket: 401 Unauthorized
It appears that minio-go library uses Instance Metadata Service (IMDS) at 169.254.169.254 to create temporary credentials to access the S3 bucket (from captured traffic):
GET /latest/meta-data/iam/security-credentials/ HTTP/1.1
Host: 169.254.169.254
User-Agent: Go-http-client/1.1
Accept-Encoding: gzip
This is not permitted, because my configuration requires Instance Metadata Service v2 (IMDSv2) since doing so avoids some vulnerabilities:
HTTP/1.1 401 Unauthorized
Content-Length: 0
Date: Fri, 03 Jun 2022 13:29:32 GMT
Server: EC2ws
Connection: close
Content-Type: text/plain
The fix would be to use Instance Metadata Service v2 (IMDSv2) compatible client with the minio-go library. This adds a session token to the requests.
I was able to workaround by creating an IAM user with an access key, then creating the source with--access-key and --secret-key args.
I am running Flux v0.30.2 on EKS with the Kubernetes version v1.21. I have created the IAM policy to access the bucket as instructed by documentation. Instances receive this policy from the instance profile. The access works when tested with AWS CLI aws s3 ls command.
Resources:
- AWS: Use IMDSv2
- aws/containers-roadmap issue EKS: Support for IMDSv2 #930
- 主要言語
- Go
- スター
- 283
- フォーク
- 252
- 平均マージ
- 1時間 6分
- マージ済み PR(30日)
- 12
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
fluxcd/source-controller のほかの issue
-
area/docs good first issue help wanted
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
fluxcd/source-controller#666 · コメント 2 件 ·
-
area/git bug
難易度 4/5 3〜5日 初心者へのやさしさ 55/100
fluxcd/source-controller#2165 · コメント 3 件 ·
-
難易度 4/5 3〜5日 初心者へのやさしさ 45/100
fluxcd/source-controller#2150 ·
-
GitRepository `.spec.ref.commit` + `.spec.ref.branch` does not shallow clone, contrary to the docs オープン
難易度 5/5 1週間以上 初心者へのやさしさ 42/100
fluxcd/source-controller#2146 · コメント 2 件 ·
-
難易度 4/5 3〜5日 初心者へのやさしさ 55/100
fluxcd/source-controller#2136 · コメント 1 件 ·
fluxcd/source-controller の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
-
acceptance-tests phase-coding schema-coverage testing triaged
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100