Created
July 21, 2021 09:34
-
-
Save sayadi/7d705e408982d82509dcc83331f4dcc7 to your computer and use it in GitHub Desktop.
Running the EKS CoreDNS deployment on Fargate when using the Terraform EKS module
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
# By default, the AWS EKS API creates the coredns deployment template with an annotation | |
# `eks.amazonaws.com/compute-type` equal to `ec2`. This prevents coredns pods from running on Fargate. | |
# Removing this annotation fixes the issue. | |
# More on: https://github.com/hashicorp/terraform-provider-aws/issues/11327 | |
resource "null_resource" "edit_coredns" { | |
provisioner "local-exec" { | |
environment = { | |
KUBECONFIG = module.eks.kubeconfig_filename | |
CLUSTER_NAME = local.cluster_name | |
} | |
command = <<EOF | |
sleep 60 | |
aws eks update-kubeconfig --name $CLUSTER_NAME | |
kubectl -n kube-system patch deployment coredns \ | |
--type json -p='[ | |
{"op": "add", "path": "/spec/template/metadata/annotations", "value": {}}, | |
{"op": "add", "path": "/spec/template/metadata/annotations/eks.amazonaws.com~1compute-type", "value": "to-be-removed"} | |
]' | |
kubectl -n kube-system patch deployment coredns \ | |
--type json -p='[{"op": "remove", "path": "/spec/template/metadata/annotations/eks.amazonaws.com~1compute-type"}]' | |
kubectl -n kube-system rollout restart deployment coredns | |
kubectl -n kube-system rollout status deployment coredns | |
EOF | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment