我正在尝试在私有子网中创建 EKS 集群。我在让它工作时遇到问题。我收到错误 unhealthy nodes in the kubernetes cluster
。不知道是由于安全组还是其他一些问题,比如 VPC 端点?
当我使用 NAT 网关设置时,它工作正常。但是我不想再使用 nat 网关了。
有人认为我不确定 EKS 集群子网的子网 ID 是否应该只是私有子网?
在下面的配置中,我同时使用了公共和私有子网。
resource "aws_eks_cluster" "main" {
name = var.eks_cluster_name
role_arn = aws_iam_role.eks_cluster.arn
vpc_config {
subnet_ids = concat(var.public_subnet_ids, var.private_subnet_ids)
security_group_ids = [aws_security_group.eks_cluster.id, aws_security_group.eks_nodes.id, aws_security_group.external_access.id]
endpoint_private_access = true
endpoint_public_access = false
}
# Ensure that IAM Role permissions are created before and deleted after EKS Cluster handling.
# Otherwise, EKS will not be able to properly delete EKS managed EC2 infrastructure such as Security Groups.
depends_on = [
"aws_iam_role_policy_attachment.aws_eks_cluster_policy",
"aws_iam_role_policy_attachment.aws_eks_service_policy"
]
}
答案 0 :(得分:0)
由于您没有 NAT 网关/实例,您的节点无法连接到互联网并失败,因为它们无法“与控制平面和其他 AWS 服务通信”(来自here).
因此,您可以使用 VPC 端点来启用与普通和服务的通信。要查看为 EKS 正确设置的带有私有子网的 VPC,您可以检查 AWS provided VPC template for EKS(来自 here)。
从模板中,us-east-1
中的 VPC 端点:
请注意,除了 S3 之外,所有这些端点都不是免费的。因此,您必须考虑运行廉价的 NAT 实例或网关是否比维护这些端点更便宜或更贵。