amazon-web-services - 如何从 Azure Devops 管道连接 AWS EKS 集群 - 在 KubeConfig 内容中找不到集群的用户凭据

标签 amazon-web-services azure-devops amazon-eks azure-devops-server-2019

我必须在 Microsoft Azure Devops 中设置 CI 才能部署和管理 AWS EKS 集群资源。作为第一步,发现很少有 kubernetes 任务可以连接到 kubernetes 集群(在我的情况下,它是 AWS EKS)但是在 Azure devops 中的任务“kubectlapply”任务中,我只能将 kube 配置文件或 Azure 订阅传递给到达集群。

就我而言,我有 kube 配置文件,但我还需要传递有权访问 AWS EKS 集群的 AWS 用户凭证。但是在添加新的“k8s 端点”以提供可用于访问 EKS 集群的 AWS 凭证时,任务中没有此类选项。因此,我在验证与 EKS 集群的连接时看到以下错误。

在运行时,我可以通过管道中的环境变量传递 AWS 凭证,但不能在任务中添加 kubeconfig 文件并保存它。

Azure 和 AWS 是云领域的重要参与者,应该有办法连接到来自任何 CI 平台的 AWS 资源。有没有人遇到过这种问题?首先连接到 AWS 和 EKS 集群以在 Azure Devops CI 中进行部署的最佳方法是什么。

在 KubeConfig 内容中找不到集群的用户凭据。确保凭据存在,然后重试。

enter image description here

最佳答案

Amazon EKS 使用 IAM 通过 AWS IAM Authenticator for Kubernetes 向您的 Kubernetes 集群提供身份验证。您可以引用以下格式更新配置文件:

apiVersion: v1
clusters:
- cluster:
    server: ${server}
    certificate-authority-data: ${cert}
  name: kubernetes
contexts:
- context:
    cluster: kubernetes
    user: aws
  name: aws
current-context: aws
kind: Config
preferences: {}
users:
- name: aws
  user:
    exec:
      apiVersion: client.authentication.k8s.io/v1alpha1
      command: aws-iam-authenticator
      env:
      - name: "AWS_PROFILE"
        value: "dev"
      args:
        - "token"
        - "-i"
        - "mycluster"

有用的链接:
  • https://docs.aws.amazon.com/eks/latest/userguide/create-kubeconfig.html
  • https://github.com/kubernetes-sigs/aws-iam-authenticator#specifying-credentials--using-aws-profiles
  • 关于amazon-web-services - 如何从 Azure Devops 管道连接 AWS EKS 集群 - 在 KubeConfig 内容中找不到集群的用户凭据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61070545/

    相关文章:

    powershell - Azure DevOps-在PowerShell脚本中设置和使用变量

    kubernetes - Kubernetes中基于URL和Path的限速

    amazon-web-services - EKS 1.11 + Istio 1.0.6 + Cilium 1.4.1,发布 https ://istio-sidecar-injector. istio-system.svc :443/inject? timeout=30s:地址不允许

    post - 如何通过 SSL 将文件直接上传到 S3?

    amazon-web-services - 到外部 REST API 的 AWS API 网关

    amazon-web-services - 将 ASP.NET Core Web API 发布到 AWS Serverless Lambda : 'AWSLambdaFullAccess' at 'policyArn' . 时出错.. 成员的长度必须大于

    azure-devops - 是否可以使 VSO (Visual Studio Online) 存储库公开可见?

    php - 如何避免在运行到Docker Container的PHP应用程序中的配置上进行硬编码的数据库凭据

    azure - 是否可以自定义 Backlogs View

    amazon-web-services - 如何确保AWS EKS上的节点均匀分布在一个区域的可用区中?