【问题标题】:How to pull Helm chart from AWS ecr locally如何在本地从 AWS ecr 提取 Helm 图表
【发布时间】:2021-02-17 16:52:27
【问题描述】:

我们在 AWS 上有一个 ecr 存储库。这包含所有掌舵图。 此 ecr 受到保护,有人为我分配了一个角色。 这个角色允许我访问 aws cli 控制台中的所有图像。

现在我正在使用 helm 来部署图表。所以对于我使用的以下代码。 当我运行 helm dep update 命令时,这只会拉取 postgres 图像,并且测试图表请求失败并出现错误 401。

我知道在某处我需要提及 aws 凭据,但不知道应该在哪里使用它。 如果有人知道如何使用 AWS 访问令牌访问它,那将是一件好事。

dependencies:
  - name: postgresql
    version: 9.2.1
    repository: https://charts.bitnami.com/bitnami
    condition: postgresql.enabled
  - name: createdb
    version: latest
    repository: https://111.ecr.eu-central-1.amazonaws.com/test-chart

【问题讨论】:

  • ECR 不托管 helm 图表,它托管 docker 图像。您需要创建一个 k8s 或 helm 图表模板,该模板引用该 ecr 存储库作为其图像设置。

标签: kubernetes-helm amazon-ecr


【解决方案1】:

Helm 客户端版本 3 现在支持 ECR 作为 Helms 图表存储库。虽然,目前任何基于 OCI 的注册表支持在 Helms 官方 documentation 上都被认为是实验性的。

假设您拥有所需的权限并且已经将 helm chart 推送到 ECR(如果您还没有,请遵循文档 here),您可以(可选)快速执行 aws ecr describe-images 以获取可用标签列表您在 ECR 存储库中的 helm-chart。

aws ecr describe-images --repository-name <your-repo-name> --region <region> --profile <profile>
{
    "imageDetails": [
        {
            "registryId": "************",
            "repositoryName": "<your-repo-name>",
            "imageDigest": "sha256:******************************************",
            "imageTags": [
                "0.1.6"
            ],
            "imageSizeInBytes": 3461,
            "imagePushedAt": "2021-04-07T00:16:31+01:00",
            "imageManifestMediaType": "application/vnd.oci.image.manifest.v1+json",
            "artifactMediaType": "application/vnd.cncf.helm.config.v1+json"
        }
    ]
}

获取 ECR 令牌并登录到 helm repo:

aws ecr get-login-password --region <region> | helm registry login --username AWS --password-stdin <aws_account_id>.dkr.ecr.<region>.amazonaws.com

获得所需的详细信息后,您可以运行 helm chart pull 命令从 ECR 中提取图表。

helm chart pull <aws_account_id>.dkr.ecr.<region>.amazonaws.com/<your-repo-name>:0.1.6
0.1.6: Pulling from <aws_account_id>.dkr.ecr.<region>.amazonaws.com/<your-repo-name>
ref:     <aws_account_id>.dkr.ecr.<region>.amazonaws.com/<your-repo-name>:0.1.6
digest:  d16af8672604ebe54********************************************
size:    3.2 KiB
name:    <your-chart-name>
version: 0.1.6
Status: Chart is up to date for <aws_account_id>.dkr.ecr.<region>.amazonaws.com/<your-repo-name>:0.1.6

验证:

helm chart list
REF                                                                       NAME              VERSION DIGEST  SIZE    CREATED
<aws_account_id>.dkr.ecr.<region>.amazonaws.com/<your-repo-name>... <your-chart-name>       0.1.6   50f03e4 3.2 KiB 22 second

【讨论】:

    猜你喜欢
    • 2022-07-07
    • 2022-10-17
    • 1970-01-01
    • 2023-04-05
    • 2018-04-02
    • 2020-03-27
    • 2020-07-08
    • 2020-10-06
    • 2020-09-09
    相关资源
    最近更新 更多