gpt4 book ai didi

Azure 容器服务 (AKS) kubeconfig 文件已过时

转载 作者:行者123 更新时间:2023-12-03 05:31:06 27 4
gpt4 key购买 nike

我正在学习 K8s,并使用 kubectl apply 设置了发布管道。我已经通过 Terraform 设置了 AKS 集群,第一次运行时一切似乎都很好。一旦我销毁了集群,我就重新运行了管道,我遇到了一些问题,我认为这些问题与异常中提到的 kubeconfig 文件有关。我尝试使用云外壳等来访问文件或重置它,但没有成功。如何才能恢复到干净的状态?

2020-12-09T09:08:51.7047177Z ##[section]Starting: kubectl apply
2020-12-09T09:08:51.7482440Z ==============================================================================
2020-12-09T09:08:51.7483217Z Task : Kubectl
2020-12-09T09:08:51.7483729Z Description : Deploy, configure, update a Kubernetes cluster in Azure Container Service by running kubectl commands
2020-12-09T09:08:51.7484058Z Version : 0.177.0
2020-12-09T09:08:51.7484996Z Author : Microsoft Corporation
2020-12-09T09:08:51.7485587Z Help : https://learn.microsoft.com/azure/devops/pipelines/tasks/deploy/kubernetes
2020-12-09T09:08:51.7485955Z ==============================================================================
2020-12-09T09:08:52.7640528Z [command]C:\ProgramData\Chocolatey\bin\kubectl.exe --kubeconfig D:\a\_temp\kubectlTask\1607504932712\config apply -f D:\a\r1\a/medquality-cordapp/k8s
2020-12-09T09:08:54.1555570Z Unable to connect to the server: dial tcp: lookup mq-k8s-dfee38f6.hcp.switzerlandnorth.azmk8s.io: no such host
2020-12-09T09:08:54.1798118Z ##[error]The process 'C:\ProgramData\Chocolatey\bin\kubectl.exe' failed with exit code 1
2020-12-09T09:08:54.1853710Z ##[section]Finishing: kubectl apply

发布管道的更新、工作流任务:

最初,我得到了工件,即包含 k8s yaml 的存储库的克隆,然后阶段执行 kubectl 应用。

"workflowTasks": [
{
"environment": {},
"taskId": "cbc316a2-586f-4def-be79-488a1f503564",
"version": "0.*",
"name": "kubectl apply",
"refName": "",
"enabled": true,
"alwaysRun": false,
"continueOnError": false,
"timeoutInMinutes": 0,
"definitionType": null,
"overrideInputs": {},
"condition": "succeeded()",
"inputs": {
"kubernetesServiceEndpoint": "82e5971b-9ac6-42c6-ac43-211d2f6b60e4",
"namespace": "",
"command": "apply",
"useConfigurationFile": "false",
"configuration": "",
"arguments": "-f $(System.DefaultWorkingDirectory)/medquality-cordapp/k8s",
"secretType": "dockerRegistry",
"secretArguments": "",
"containerRegistryType": "Azure Container Registry",
"dockerRegistryEndpoint": "",
"azureSubscriptionEndpoint": "",
"azureContainerRegistry": "",
"secretName": "",
"forceUpdate": "true",
"configMapName": "",
"forceUpdateConfigMap": "false",
"useConfigMapFile": "false",
"configMapFile": "",
"configMapArguments": "",
"versionOrLocation": "version",
"versionSpec": "1.7.0",
"checkLatest": "false",
"specifyLocation": "",
"cwd": "$(System.DefaultWorkingDirectory)",
"outputFormat": "json",
"kubectlOutput": ""
}
}
]
```

最佳答案

我可以看到您正在使用 kubernetesServiceEndpoint 作为 Kubectl 任务中的服务连接类型。

Once I destroyed the cluster I reran the pipeline, I get issues....

如果集群被破坏。 azure devops 中的 kubernetesServiceEndpoint 仍连接到原始集群。使用原始 kubernetesServiceEndpoint 的 Kubectl 任务仍在寻找旧集群。由于旧集群已被破坏,它将因上述错误而失败。

您可以通过更新 kubernetesServiceEndpoint 来解决此问题在 azure devops 中使用新创建的集群:

转到 Azure devops 项目设置-->服务连接-->找到您的 Kubernetes 服务连接-->点击编辑进行更新配置。

但是如果你的 kubernete 集群经常被破坏和重新创建。我建议使用 Azure 资源管理器 作为服务连接类型来连接到 Kubectl 任务中的集群。请参阅下面的屏幕截图。

通过使用azureSubscriptionEndpoint并指定azureResourceGroup,只要集群名称不变,重新创建集群多少次都没有关系。

enter image description here

请参阅文档以创建 Azure Resource Manager service connection

关于Azure 容器服务 (AKS) kubeconfig 文件已过时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65214000/

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