如何在部署流水线中配置 ArgoCD 访问 Azure Repos

39次阅读
没有评论

问题描述

在部署流水线中使用 ArgoCD 时,希望能够配置 ArgoCD 访问 Azure Repos。用户目前有几个理论上的想法,但都存在问题。用户的环境如下:
– Azure DevOps Services
– Azure Cloud
– 使用强大的服务主体连接运行流水线

想法 #1
1. 流水线部署 AKS 集群、AAD Pod Identity 和 Argo CD。
2. 流水线为 Argo CD 服务配置托管标识。
3. 流水线将 ArgoCD 托管标识添加为 Azure Repos 的用户。

问题 – 找不到将托管标识添加为 Azure Repos 用户的方法。

想法 #2
1. 流水线部署 AKS 集群、Argo CD 并生成 SSH 公钥/私钥。
2. 流水线使用 Azure DevOps Services 注册公共 SSH 密钥。
3. Argo CD 将使用生成的私钥以流水线账户的身份访问 Azure DevOps。

问题 – Azure DevOps Services 没有 REST API 来注册公共 SSH 密钥。另一个问题是我们需要管理 SSH 私钥的存储(可以是 terraform 远程状态或 Azure KV 或两者兼有)。

想法 #3
1. 手动在 Azure DevOps 中注册 SSH 公钥。相应的私钥作为安全文件上传到 Pipelines Library。
2. 流水线部署 AKS 集群、Azure Key Vault 和 Argo CD。
3. 流水线将 SSH 私钥上传到 Azure Key Vault。
4. 流水线配置 ArgoCD 从 Azure Key Vault 读取 SSH 私钥,并使用它来与 Azure Repos 进行身份验证。

问题 – 如何让 ArgoCD 从 Azure Key Vault 获取密钥?似乎有多种方法:
https://learn.microsoft.com/en-us/azure/aks/csi-secrets-store-driver
https://github.com/SparebankenVest/azure-key-vault-to-kubernetes
https://github.com/external-secrets/external-secrets

问题是 – 哪种方法最成熟、最安全?

用户想知道其他人是如何解决这个问题的,你对这个问题有什么看法?

解决方案

请注意以下操作注意版本差异及修改前做好备份。

方案1

在 Azure DevOps 中,可以使用服务连接来实现 ArgoCD 访问 Azure Repos。以下是实现的步骤:
1. 在 Azure DevOps 中创建一个服务连接。
2. 在 Argo CD 中配置 Azure Repos 访问凭据。

具体步骤如下:
1. 登录到 Azure DevOps。
2. 转到项目设置。
3. 在左侧导航栏中,选择“服务连接”。
4. 点击“新建服务连接”。
5. 选择“Azure Repos”作为服务类型。
6. 根据提示提供必要的信息,如仓库 URL、访问令牌等。
7. 点击“保存”以创建服务连接。
8. 在 Argo CD 中,使用创建的服务连接配置 Azure Repos 访问凭据。

方案2

另一种方法是使用 Azure Key Vault 来存储和管理 SSH 密钥,并让 Argo CD 从 Key Vault 中获取密钥。以下是实现的步骤:
1. 在 Azure Key Vault 中创建一个密钥。
2. 在 Argo CD 中配置 Azure Key Vault 访问凭据。

具体步骤如下:
1. 登录到 Azure 门户。
2. 打开 Azure Key Vault。
3. 创建一个新的密钥,并将 SSH 私钥作为密钥的值。
4. 在 Argo CD 中,使用 Azure Key Vault 的访问凭据配置密钥的获取。

方案3

如果你使用的是 Azure Kubernetes Service (AKS),你可以考虑使用 Azure Key Vault 和 Azure Key Vault CSI 驱动程序来管理和获取密钥。以下是实现的步骤:
1. 在 Azure Key Vault 中创建一个密钥。
2. 在 AKS 中安装 Azure Key Vault CSI 驱动程序。
3. 在 Argo CD 中配置 Azure Key Vault 访问凭据。

具体步骤如下:
1. 登录到 Azure 门户。
2. 打开 Azure Key Vault。
3. 创建一个新的密钥,并将 SSH 私钥作为密钥的值。
4. 在 AKS 中安装 Azure Key Vault CSI 驱动程序。
5. 在 Argo CD 中,使用 Azure Key Vault 的访问凭据配置密钥的获取。

请注意,以上方案仅提供了一些可能的解决方案。根据你的具体需求和环境,你可能需要进一步调查和测试这些方案,以确定最适合你的情况的解决方案。

以上是我对这个问题的解决方案的建议,希望对你有帮助。如果你有其他问题或需要进一步的帮助,请随时提问。

正文完