Repository navigation
[terraform-aws] Support bring-your-own VPC and private EKS API endpoint - #1767
timothy-cloudopsguy wants to merge 4 commits into
Conversation
the-glu
left a comment
There was a problem hiding this comment.
Thanks for the PR, first partial review
| 'service.beta.kubernetes.io/aws-load-balancer-scheme': 'internet-facing', | ||
| 'service.beta.kubernetes.io/aws-load-balancer-eip-allocations': std.join(',', ipNames), | ||
| 'service.beta.kubernetes.io/aws-load-balancer-subnets': metadata.subnet, | ||
| 'service.beta.kubernetes.io/aws-load-balancer-subnets': metadata.public_subnet, |
There was a problem hiding this comment.
The same change need to be done for helm as well to put LB in correct subnets no?
| public_access_cidrs = [ | ||
| "0.0.0.0/0" | ||
| ] | ||
| subnet_ids = local.vpc_id == "" ? aws_subnet.dss[*].id : var.private_subnet_ids |
There was a problem hiding this comment.
I tried a fresh deployment with old config and it's failling
│ Error: Not enough list items
│
│ with module.terraform-aws-kubernetes.aws_eks_cluster.kubernetes_cluster,
│ on ../../dependencies/terraform-aws-kubernetes/cluster.tf line 6, in resource "aws_eks_cluster" "kubernetes_cluster":
│ 6: subnet_ids = local.vpc_id == "" ? aws_subnet.dss[*].id : var.private_subnet_ids
│
│ Attribute vpc_config.0.subnet_ids requires 1 item minimum, but config has only 0 declared.
I think that because local.vpc_id cannot be empty and therefor always try to use private_subnet_ids - it should be var.local_vpc no?
| description = var.use_public_subnets ? "Allow traffic from the internet" : "Allow traffic from the VPC" | ||
| type = "ingress" | ||
| from_port = 0 | ||
| to_port = 65535 |
There was a problem hiding this comment.
Why open everything where as only port 443 is needed for the API ? I do have the feeling that too large.
There was a problem hiding this comment.
to be fair, the security group as it is today is only created and never attached to anything, so it's doing no better or worse? :-) But I agree, scope it down to the minimum is best. I guess I wasn't sure what that minimum was since it was not attached and used before.
| } | ||
|
|
||
| resource "aws_security_group_rule" "eks-controlplane-ingress" { | ||
| description = var.use_public_subnets ? "Allow traffic from the internet" : "Allow traffic from the VPC" |
There was a problem hiding this comment.
In public mode, why is that needed? It's handeled by public_access_cidrs no?
| # This is the subnet where Kubernetes workload will be running. | ||
| data "aws_subnet" "main_subnet" { | ||
| id = aws_subnet.dss[0].id | ||
| # If a VPC ID is provided, we need to retrieve the subnets from the existing VPC, and add the tags to the existing subnets |
There was a problem hiding this comment.
This will change subnet that are not managed by the chart - shouldn't it be done externally to avoid multiple source of management for those?
Summary
Adds an option to deploy the DSS EKS cluster into an existing VPC with the application and Kubernetes control plane running on private subnets. By default nothing changes: existing deployments keep the Terraform-managed VPC and public endpoint.
When using private subnets, the application running on Kubernetes is still accessible via the NLB/ALB, it just points internally. The Kubernetes cluster and api endpoints are not accessible outside of the private subnets.
With
use_public_subnets = false, the EKS API server is only reachable from inside the VPC. Terraform runskubectl, Helm and Tanka against the cluster, so the machine running Terraform must either:Otherwise the cluster is created and then the first Kubernetes or Helm step fails with the API endpoint unreachable (
dial tcp …: i/o timeout). The control-plane security group allows the VPC's CIDR range. If you connect from a different range (for example a VPN client pool or a peered VPC), add an ingress rule for it.New variables (
terraform-aws-dss)vpc_id""private_subnet_ids[]public_subnet_ids[]use_public_subnetstrueDefined in
utils/definitions/and generated intovariables.gen.tf/TFVARS.gen.md.Changes
vpc_idis blank.moved {}blocks keep existing state addresses working.role/internal-elb, public subnets getrole/elb, and both getkubernetes.io/cluster/<name>=shared.metadata.public_subnet(Terraform output →terraform-commons-dss→ Tanka). It falls back tosubnet, so existing Tanka setups are unaffected.0.0.0.0/0when the endpoint is public, or the VPC's CIDR range when it's private.Upgrade impact (existing deployments, default settings)
No VPC or subnet resources are replaced. Expect these in-place changes:
eks-controlplanesecurity group attached to the cluster'svpc_config, plus a new ingress ruleendpoint_private_access:false→trueExample (
terraform.tfvars)