简体   繁体   中英

Can't create AWS ALB kubernetes ingress controller in Terraform

I used this repo to create an AWS EKS cluster using Terraform. Now, I am trying to add a an ALB kubernetes ingress controller following this guide

Everything works fine until I try to add the kubernetes cluster role. Then I get this error:

kubernetes_cluster_role.alb-ingress: Creating...

Error: Post "https://E8475B1B3693C979073BF0D721D876A7.sk1.ap-southeast-1.eks.amazonaws.com/apis/rbac.authorization.k8s.io/v1/clusterroles": dial tcp: lookup E8475B1B3693C979073BF0D721D876A7.sk1.ap-southeast-1.eks.amazonaws.com on 127.0.0.53:53: no such host

on main.tf line 6, in resource "kubernetes_cluster_role" "alb-ingress": 6: resource "kubernetes_cluster_role" "alb-ingress" {

With all the other infrastructure in place (or not, I get the same error), here is my minimal code to produce the error.

provider "aws" {
  region  = "ap-southeast-1"
  version = "~> 2.65.0"
}

resource "kubernetes_cluster_role" "alb-ingress" {
  metadata {
    name = "alb-ingress-controller"
    labels = {
      "app.kubernetes.io/name" = "alb-ingress-controller"
    }
  }

  rule {
    api_groups = ["", "extensions"]
    resources  = ["configmaps", "endpoints", "events", "ingresses", "ingresses/status", "services"]
    verbs      = ["create", "get", "list", "update", "watch", "patch"]
  }

  rule {
    api_groups = ["", "extensions"]
    resources  = ["nodes", "pods", "secrets", "services", "namespaces"]
    verbs      = ["get", "list", "watch"]
  }
}

Need to copy kubeconfig locally to ~/.kube/config before running a separate terraform manifest for the kubernetes ingress controller. Also set endpoint_private_access = true in the eks cluster resource

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM