'configmaps "aws-auth" not found
I launched an EKS cluster using terraform module
My template looks something like this:
module "eks" {
source = "terraform-aws-modules/eks/aws"
version = "17.20.0"
cluster_name = "${var.cluster_name}"
cluster_version = var.cluster_version
subnets = ["${var.public_subnet_1}",
"${var.public_subnet_2}","${var.public_subnet_3}"]
vpc_id = var.vpc_id
cluster_security_group_id = "${var.master_sg_id}"
worker_security_group_id = "${var.master_sg_id}"
workers_additional_policies =[aws_iam_policy.siera_alb_ingress_controller_policy.arn]
workers_role_name = "${var.cluster_name}-${var.environment}-${var.aws_region}-worker-role"
map_roles = [
{
rolearn = "arn:aws:iam::${var.account_no}:role/${var.cluster_name}-${var.environment}-${var.aws_region}-worker-role"
username = "system:node:{{EC2PrivateDNSName}}"
groups = ["system:bootstrappers","system:nodes"]
},
{
rolearn = "arn:aws:sts::${var.account_no}:assumed-role/${var.assumed_role_1}"
username = "admin"
groups = ["system:masters","system:nodes","system:bootstrappers"]
},
{
rolearn = "arn:aws:sts::${var.account_no}:assumed-role/${var.assumed_role_2}"
username = "admin"
groups = ["system:masters","system:nodes","system:bootstrappers"]
}
]
tags = {
Purpose = "${var.project}"
Environment = "${var.environment}"
}
worker_groups_launch_template = [
{
name = "${var.cluster_name}-lt"
key_name = "${var.node_key}"
additional_userdata = <<EOT
"echo dummy"
EOT
instance_type = "${var.node_size}"
asg_min_size = 3
asg_desired_capacity = 3
asg_max_size = 5
autoscaling_enabled = true
asg_force_delete = true
public_ip = true
enable_monitoring = false
root_volume_size = 80
suspended_processes = ["AZRebalance"]
tags = [
{
"key" = "k8s.io/cluster-autoscaler/enabled"
"propagate_at_launch" = "false"
"value" = "true"
},
{
"key" = "k8s.io/cluster-autoscaler/${var.cluster_name}"
"propagate_at_launch" = "false"
"value" = "true"
}
]
}
]
manage_aws_auth = false
}
As you can see I'm trying to add aws-auth configmap using map_roles.
After launching the cluster when I run kubectl describe configmap -n kube-system aws-auth
It gives this error: Error from server (NotFound): configmaps "aws-auth" not found
What am I missing? Please help
Solution 1:[1]
Hey im seeing the same issue and the problem is that kubernetes provider is not connecting to the recently created cluster. I have added a piece of code in the main.tf that made it before creating the module itself.
...
provider "kubernetes" {
host = module.app_cluster.cluster_endpoint
cluster_ca_certificate = base64decode(module.app_cluster.cluster_certificate_authority_data)
exec {
api_version = "client.authentication.k8s.io/v1alpha1"
command = "aws"
# This requires the awscli to be installed locally where Terraform is executed
args = ["eks", "get-token", "--cluster-name", module.app_cluster.cluster_id]
}
}
module "app_cluster" {
source = "terraform-aws-modules/eks/aws"
version = "~> 18.0"
cluster_name = "${terraform.workspace}-cluster"
cluster_version = "1.21"
vpc_id = "${var.vpc}"
subnet_ids = "${var.subnets}"
...
Hope it helps!
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
