gpt4 book ai didi

azure - 如何使用 Terraform 'error dial tcp 127.0.0.1:80: connect: connection refused' 修复 Azure Kubernetes 服务?

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

“terraform apply”在我的本地计算机上出现以下错误的原因是什么?它似乎在构建服务器上运行良好。

我还检查了相关的 stackoverflow 消息:

  • Windows 防火墙已禁用,因此专用网络上允许 80
  • 未使用 AKS 中的 config_path,似乎没有在任何地方配置 kubeconfig
Plan: 3 to add, 0 to change, 0 to destroy.

Do you want to perform these actions?
Terraform will perform the actions described above.
Only 'yes' will be accepted to approve.

Enter a value: yes

kubernetes_namespace.azurevotefront-namespace: Creating...
kubernetes_service.azurevotefront-metadata: Creating...
kubernetes_deployment.azurevotefront-namespace: Creating...

│ Error: Post "http://localhost/api/v1/namespaces": dial tcp 127.0.0.1:80: connect: connection refused

│ with kubernetes_namespace.azurevotefront-namespace,
│ on kubernetes.tf line 1, in resource "kubernetes_namespace" "azurevotefront-namespace":
│ 1: resource "kubernetes_namespace" "azurevotefront-namespace" {



│ Error: Failed to create deployment: Post "http://localhost/apis/apps/v1/namespaces/azurevotefront-namespace/deployments": dial tcp 127.0.0.1:80: connect: connection refused

│ with kubernetes_deployment.azurevotefront-namespace,
│ on main.tf line 1, in resource "kubernetes_deployment" "azurevotefront-namespace":
│ 1: resource "kubernetes_deployment" "azurevotefront-namespace" {



│ Error: Post "http://localhost/api/v1/namespaces/azurevotefront-namespace/services": dial tcp 127.0.0.1:80: connect: connection refused

│ with kubernetes_service.azurevotefront-metadata,
│ on main.tf line 47, in resource "kubernetes_service" "azurevotefront-metadata":
│ 47: resource "kubernetes_service" "azurevotefront-metadata" {

Kubernetes.tf

resource "kubernetes_namespace" "azurevotefront-namespace" {
metadata {
annotations = {
name = "azurevotefront-annotation"
}

labels = {
mylabel = "azurevotefront-value"
}

name = "azurevotefront-namespace"
}
}

提供商.tf

terraform {
backend "azurerm" {
key = "terraform.tfstate"
resource_group_name = "MASKED"
storage_account_name = "MASKED"
access_key = "MASKED"
container_name = "MASKED"
}
required_providers {
azurerm = {
source = "hashicorp/azurerm"
version = "~>2.68"
}
kubernetes = {
source = "hashicorp/kubernetes"
version = "~> 2.4"
}
}
}

provider "azurerm" {
tenant_id = "MASKED"
subscription_id = "MASKED"
client_id = "MASKED"
client_secret = "MASKED"
features {}
}

最佳答案

正如评论中提到的,您缺少 kubernetes 提供程序配置:

provider "kubernetes" {
host = azurerm_kubernetes_cluster.aks.kube_admin_config.0.host
client_certificate = base64decode(azurerm_kubernetes_cluster.aks.kube_admin_config.0.client_certificate)
client_key = base64decode(azurerm_kubernetes_cluster.aks.kube_admin_config.0.client_key)
cluster_ca_certificate = base64decode(azurerm_kubernetes_cluster.aks.kube_admin_config.0.cluster_ca_certificate)
}

关于azure - 如何使用 Terraform 'error dial tcp 127.0.0.1:80: connect: connection refused' 修复 Azure Kubernetes 服务?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/71326164/

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