Hi all. I am using TF 1.5.2 to build an AWS EKS (1.25) and it seems to be ok until I got the following errors.
Error: Post “http://localhost/apis/rbac.authorization.k8s.io/v1/clusterroles”: dial tcp 127.0.0.1:80: connect: connection refused
Error: Post “http://localhost/apis/rbac.authorization.k8s.io/v1/clusterrolebindings”: dial tcp 127.0.0.1:80: connect: connection refused
Error: The configmap “aws-auth” does not exist
any ideas?
In that section of TF I am trying to create clusterroles read only for users
Cheers
Have you setup the Kubernetes provider with all the correct URL & authentication details?
Thanks Stuart. appreciated.
I read a lot of things about it but I’m not sure what to do exactly. Can you tell me where to read stuff or post the provider block I need to use?
Cheers
The Kubernetes provider documentation gives all the details:
https://registry.terraform.io/providers/hashicorp/kubernetes/latest/docs#argument-reference
Hi Stuart. So reading the link you provided is about roughly about adding the following:
provider "kubernetes" {
config_path = "~/.kube/config"
config_context = "my-context"
}
But isn’t too early in the deployment to have the config updated?
Anyway I will give it a try
Cheers
I don’t know how you are setting things up. For us we use EKS in AWS and a third-party module to handle the management. An example of using that module and the provider setup used can be seen at https://github.com/terraform-aws-modules/terraform-aws-eks/blob/master/examples/complete/main.tf#L5-L15
Thanks Stuart. So I added the following
data “aws_eks_cluster” “cluster” {
name = module.eks.cluster_id
}
data “aws_eks_cluster_auth” “cluster” {
name = module.eks.cluster_id
}
provider “kubernetes” {
host = data.aws_eks_cluster.cluster.endpoint
cluster_ca_certificate = base64decode(data.aws_eks_cluster.cluster.certificate_authority[0].data)
token = data.aws_eks_cluster_auth.cluster.token
}
but still at the end it doesn’t know how to get info from the new born eks as it keep saying
Error: Post “http://localhost/apis/rbac.authorization.k8s.io/v1/clusterroles”: dial tcp 127.0.0.1:80: connect: connection refused
Error: Post “http://localhost/apis/rbac.authorization.k8s.io/v1/clusterrolebindings”: dial tcp 127.0.0.1:80: connect: connection refused
So it tries with local host instead of
https://DF6DA0E9993C511F81DDE6E246B19AE0.gr7.eu-west-1.eks.amazonaws.com
Alfredo