Browse the Repo

file-type-icon.circleci
file-type-icon_docs
file-type-iconexamples
file-type-iconeks-cluster-managed-workers
file-type-iconeks-cluster-with-iam-role-mappings
file-type-iconuser-data
file-type-iconuser-data.sh
file-type-iconREADME.md
file-type-icondependencies.tf
file-type-iconmain.tf
file-type-iconoutputs.tf
file-type-iconvariables.tf
file-type-iconeks-cluster-with-supporting-services
file-type-iconeks-fargate-cluster-with-irsa
file-type-iconeks-fargate-cluster-with-supporting-services
file-type-iconeks-fargate-cluster
file-type-iconREADME.md
file-type-iconmodules
file-type-iconrfc
file-type-icontest
file-type-icon.gitignore
file-type-icon.pre-commit-config.yaml
file-type-iconCODEOWNERS
file-type-iconCONTRIBUTING.md
file-type-iconGRUNTWORK_PHILOSOPHY.md
file-type-iconLICENSE.md
file-type-iconREADME.adoc
file-type-iconcore-concepts.md
file-type-iconsetup.cfg

Browse the Repo

file-type-icon.circleci
file-type-icon_docs
file-type-iconexamples
file-type-iconeks-cluster-managed-workers
file-type-iconeks-cluster-with-iam-role-mappings
file-type-iconuser-data
file-type-iconuser-data.sh
file-type-iconREADME.md
file-type-icondependencies.tf
file-type-iconmain.tf
file-type-iconoutputs.tf
file-type-iconvariables.tf
file-type-iconeks-cluster-with-supporting-services
file-type-iconeks-fargate-cluster-with-irsa
file-type-iconeks-fargate-cluster-with-supporting-services
file-type-iconeks-fargate-cluster
file-type-iconREADME.md
file-type-iconmodules
file-type-iconrfc
file-type-icontest
file-type-icon.gitignore
file-type-icon.pre-commit-config.yaml
file-type-iconCODEOWNERS
file-type-iconCONTRIBUTING.md
file-type-iconGRUNTWORK_PHILOSOPHY.md
file-type-iconLICENSE.md
file-type-iconREADME.adoc
file-type-iconcore-concepts.md
file-type-iconsetup.cfg
EC2 Kubernetes Service (EKS) Cluster

EC2 Kubernetes Service (EKS) Cluster

Deploy a Kubernetes cluster on top of Amazon EC2 Kubernetes Service (EKS).

Code Preview

Preview the Code

mobile file icon

user-data.sh

down
  • #!/bin/bash
  • #
  • # This script is meant to be run in the User Data of each EKS worker instance. It registers the instance with the proper
  • # EKS cluster based on data provided by Terraform. Note that this script assumes it is running from an AMI that is
  • # derived from the EKS optimized AMIs that AWS provides.
  • set -e
  • # Send the log output from this script to user-data.log, syslog, and the console
  • # From: https://alestic.com/2010/12/ec2-user-data-output/
  • exec > >(tee /var/log/user-data.log|logger -t user-data -s 2>/dev/console) 2>&1
  • # This is purely here for testing purposes. We modify the user_data_text variable at test time to make sure updates to
  • # the EKS cluster instances can be rolled out without downtime.
  • echo "User data text: ${user_data_text}" | tee /var/log/server_text.txt
  • # Here we call the bootstrap script to register the EKS worker node to the control plane.
  • function register_eks_worker {
  • /etc/eks/bootstrap.sh --apiserver-endpoint "${eks_endpoint}" --b64-cluster-ca "${eks_certificate_authority}" "${eks_cluster_name}"
  • }
  • function run {
  • register_eks_worker
  • }

Questions? Ask away.

We're here to talk about our services, answer any questions, give advice, or just to chat.

Ready to hand off the Gruntwork?