Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Source controller support for Instance Metadata Service v2 (IMDSv2) on AWS

未关闭
#760 1 条评论 1 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
35/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
停滞
技术栈
aws, go
领域
backend, cloud

调研方向

该 issue 提到了 source-controller 和 minio-go 库,但没有提到任何仓库文件或测试。首先跟踪 S3 Bucket source 的 AWS 凭证设置和 IMDS 请求,然后验证在要求 IMDSv2 的实例上进行 reconciliation,并确认经过 token 身份验证的请求能够消除 401 错误。

由索引模型根据 Issue 内容生成。

描述

enhancement

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:

主要语言
Go
星标
285
派生
259
平均合并
2 天 8 小时
30 天内合并 PR
11

环境准备

  • 提供 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

fluxcd/source-controller 的其他 Issue

查看 fluxcd/source-controller 的全部 Issue

相似的 Issue

更多 Go Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。