This repository has been archived by the owner on Sep 27, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
BATIAI-303 Simplify cluster deployments by making the 1-* scripts par…
…t of the TF rollout (#1) * eni configs * cleanup * remove comments
- Loading branch information
Showing
2 changed files
with
67 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
############################################################################### | ||
# Kubernetes provider configuration | ||
############################################################################### | ||
|
||
data "aws_eks_cluster_auth" "cluster" { | ||
name = var.cluster_name | ||
} | ||
|
||
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 | ||
exec { | ||
api_version = "client.authentication.k8s.io/v1alpha1" | ||
args = ["eks", "get-token", "--cluster-name", var.cluster_name] | ||
command = "aws" | ||
} | ||
} | ||
|
||
resource "kubernetes_manifest" "eniconfig_subnets"{ | ||
|
||
for_each = var.vpc_eni_subnets | ||
|
||
depends_on = [ | ||
helm_release.karpenter | ||
] | ||
|
||
manifest = { | ||
"apiVersion" = "crd.k8s.amazonaws.com/v1alpha1" | ||
"kind" = "ENIConfig" | ||
"metadata" = { | ||
"name" = "${each.key}" | ||
} | ||
"spec" = { | ||
"subnet" = "eni-${each.value}" | ||
"securityGroups" = [ | ||
"${var.worker_security_group_id}" | ||
] | ||
} | ||
} | ||
|
||
} | ||
|
||
resource "null_resource" "rotate_nodes_after_eniconfig_creation" { | ||
|
||
count = var.rotate_nodes_after_eniconfig_creation ? 1 : 0 | ||
|
||
provisioner "local-exec" { | ||
command = <<-EOT | ||
aws ec2 terminate-instances --instance-ids $(aws ec2 describe-instances --filter "Name=tag:Name,Values=$CLUSTER_NAME-general" "Name=instance-state-name,Values=running" --query "Reservations[].Instances[].[InstanceId]" --output text) --output text | ||
EOT | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters