gpt4 book ai didi

Azure 自托管代理 kubernetes 任务失败

转载 作者:行者123 更新时间:2023-12-03 06:24:04 25 4
gpt4 key购买 nike

运行 Kubernetes@1 时,我正在使用使用 VMSS 的 Azure 自托管代理代理上的任务会返回此错误 couldn't get current server API group list: Get "https://<aks>.hcp.westeurope.azmk8s.io/api?timeout=32s": dial tcp: lookup <aks>.hcp.westeurope.azmk8s.io on 127.0.0.53:53: no such host 。 AKS 不是私有(private)的,并且此设置在 Azure 提供的代理上运行时有效。我尝试运行的任务如下所示:

steps:
- task: Kubernetes@1
displayName: "Rollout <deployment-name>"
inputs:
connectionType: "Kubernetes Service Connection"
kubernetesServiceEndpoint: <serviceEndpoint>
namespace: <namespace>
command: "rollout"
arguments: "restart deployment <deployment-name>"

代理正在 Ubuntu 20.04 LTS 上运行。

使用AzureCLI@2获取凭据并执行 kubectl 的任务命令确实有效,但它不是最佳解决方案,我想使用 Kubernetes@1任务。这是工作示例AzureCLI@2任务:

steps:
- task: AzureCLI@2
inputs:
azureSubscription: $(azureSubscription)
scriptType: bash
scriptLocation: inlineScript
inlineScript: |
az aks get-credentials --resource-group <resource-group> --name <aks-name>
kubectl rollout -n <namespace> restart deployment <deployment-name>

编辑:

  • 我使用的是服务帐户,而不是 kube 配置文件。
  • 我有一个自定义镜像,附带预安装的 kubectl 命令。

最佳答案

我已按照以下步骤操作,它对我有用。

第 1 步:创建 VMSS 并通过连接到 VMSS 安装 kubectl。在 VMSS 上运行以下命令来安装 kubectl。

$curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
$sudo install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl

enter image description here

引用这个link有关安装 kubectl 的更多信息。

步骤 2:将 VMSS 添加为 ADO 组织中的自托管代理。

enter image description here

第 3 步:我已使用 kube config 文件创建了服务连接

enter image description here

第 4 步:通过选择在第 2 步中创建的池来运行管道并验证结果。 enter image description here

  - task: Kubernetes@1
displayName: "Rollout nginx-deployment"
inputs:
connectionType: 'Kubernetes Service Connection'
kubernetesServiceEndpoint: 'svc-aks'
namespace: 'default'
command: 'rollout'
arguments: 'restart deployment nginx-deployment'
secretType: 'dockerRegistry'
containerRegistryType: 'Container Registry'

enter image description here

关于Azure 自托管代理 kubernetes 任务失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/75687209/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com