-
Notifications
You must be signed in to change notification settings - Fork 9.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
kube_config parameter for data.aws_eks_cluster #8149
Conversation
I will add acceptance test output tomorrow, after unsetting TF_LOG and teeing so it doesn't spill over my console buffer size ;) |
Hi @vickleford 👋 Thanks for submitting this enhancement. If the Kubernetes provider accepts loading the configuration content directly via a string, I can certainly see how this would seem like a potential way to ease connecting the two providers. I do have some reservations about hardcoding kubeconfig generation functionality into the AWS provider though:
locals {
kubeconfig = <<KUBECONFIG
apiVersion: v1
clusters:
- cluster:
server: ${aws_eks_cluster.demo.endpoint}
certificate-authority-data: ${aws_eks_cluster.demo.certificate_authority.0.data}
name: kubernetes
contexts:
- context:
cluster: kubernetes
user: aws
name: aws
current-context: aws
kind: Config
preferences: {}
users:
- name: aws
user:
exec:
apiVersion: client.authentication.k8s.io/v1alpha1
command: aws-iam-authenticator
args:
- "token"
- "-i"
- "${aws_eks_cluster.demo.name}"
KUBECONFIG
}
output "kubeconfig" {
value = "${local.kubeconfig}"
}
data "aws_eks_cluster" "example" {
name = "example"
}
data "aws_eks_cluster_auth" "example" {
name = "example"
}
provider "kubernetes" {
host = "${data.aws_eks_cluster.example.endpoint}"
cluster_ca_certificate = "${base64decode(data.aws_eks_cluster.example.certificate_authority.0.data)}"
token = "${data.aws_eks_cluster_auth.example.token}"
load_config_file = false
} An alternative option here might be creating a Another alternative would be implementing the second half of hashicorp/terraform-provider-kubernetes#161, which is directly configuring # Very quick design sketch with example arguments
provider "kubernetes" {
host = "${aws_eks_cluster.example.endpoint}"
cluster_ca_certificate = "${base64decode(aws_eks_cluster.example.certificate_authority.0.data)}"
load_config_file = false
exec {
command = "aws-iam-authenticator token -i ${aws_eks_cluster.example.name}"
environment_variables = {
AWS_PROFILE = "production"
}
}
} This would be generic to accept any What do you think? 😄 |
Hello @bflad 👋 and well met! Thanks for a detailed and well-presented train of thought. If I am understanding you correctly, your hesitation is 1) limited solution vector with the template as written and 2) broadening that solution adds unwanted complexity to the aws provider. If that is on track, when I step back and consider the provider at large I have to agree with your critique as evidenced by my surprise that template generation was absent from aws-sdk and asking myself the question "where should this code live in this provider?" The alternatives proposed are quite workable. In fact, we're already generating the config as an output using locals, and this isn't terrible given that it is centralized and not repeated. Do we find agreement that this attribute is both valuable and at-home in this provider if the right implementation can be found? For example, what if template generation was implemented in aws-sdk and then used here instead of bogging this provider down with template generation details? If so, until then, is there a chance for this to be considered as a minimal implementation to open a door to finding more concrete use cases? It has been a long week, and I think I'm missing the elegance of your proposal about Thanks again for your fair and just feedback, attention to detail, great communication, and all of your work for the Terraform providers. I'll update you again soon. |
Hi again @vickleford 👋 It looks like work has started on implementing exec-based credential plugins in the Terraform Kubernetes Provider, e.g. hashicorp/terraform-provider-kubernetes#161 (comment) # Functionality under development - details may change during implementation
provider "kubernetes" {
cluster_ca_certificate = "${base64decode(aws_eks_cluster.cluster.certificate_authority.0.data)}"
host = "${aws_eks_cluster.cluster.endpoint}"
load_config_file = false
exec {
api_version = "client.authentication.k8s.io/v1alpha1"
args = ["token", "-i", "${aws_eks_cluster.cluster.name}"]
command = "aws-iam-authenticator"
}
} This would provide another option to completely bypass Kubernetes configuration file handling for providing Terraform Kubernetes Provider compatible information and the need for templating it within the Terraform AWS Provider for a resource attribute. Given we have various existing solutions to this problem and work in progress for another option, I'm going to close this out now due to the complexity and maintenance burden it is introducing within this provider. If there are use cases I am missing which cannot be solved with the existing provider attributes, please do reach out or preferably submit a feature request GitHub issue with additional use case details. Thanks. |
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks! |
Add a kube_config parameter for data.aws_eks_cluster so that it may be consumed in a way such as what is proposed at hashicorp/terraform-provider-kubernetes#383
Community Note
Changes proposed in this pull request:
kube_config
todata.aws_eks_cluster
Output from acceptance testing: