在terraform中创建新集群后,我能写点什么来编辑/.kube/config文件吗



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
config_path = local.kubectl_config_path
config_context =  data.aws_eks_cluster.cluster.arn
}
##################################################################

data "aws_availability_zones" "available" {
}
locals {
cluster_name = "Cluster-${random_string.suffix.result}"
kubectl_config_path = "C:/Users/User/.kube/config"
}

我想访问群集而不需要自己在配置文件中编辑Infos。

想知道我是否只能用地形或者还有其他办法吗?

谢谢

您不需要提供

config_path = local.kubectl_config_path
config_context =  data.aws_eks_cluster.cluster.arn

当您提供了hostcluster_ca_certificatetoken时。因此,无需写入本地kubeconfig文件即可访问集群,terraform kubernetes提供程序即可工作。

如果您想替换当前的本地kubeconfig文件以手动运行kubectl命令,您可以通过null资源写入kubeconfig.local exec`reference

最新更新