Skip to content

Instantly share code, notes, and snippets.

@ruzickap
Last active November 24, 2023 19:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ruzickap/6982495aa919223956ff2368f9b285e9 to your computer and use it in GitHub Desktop.
Save ruzickap/6982495aa919223956ff2368f9b285e9 to your computer and use it in GitHub Desktop.
Create Amazon EKS cluster using eksctl
#!/bin/bash -eux
export CLUSTER_NAME="${CLUSTER_NAME:-ruzickap}"
export AWS_DEFAULT_REGION="${AWS_DEFAULT_REGION:-eu-central-1}"
export KUBECONFIG="/tmp/kubeconfig-${CLUSTER_NAME}.conf"
export TAGS="Owner=petr.ruzicka@gmail.com Environment=dev Group=Cloud_Native Squad=Cloud_Container_Platform"
set -euxo pipefail
cat > "/tmp/eksctl-${CLUSTER_NAME}.yaml" << EOF
apiVersion: eksctl.io/v1alpha5
kind: ClusterConfig
metadata:
name: ${CLUSTER_NAME}
region: ${AWS_DEFAULT_REGION}
tags: &tags
$(echo "${TAGS}" | sed "s/ /\\n /g; s/^/ /g; s/=/: /g")
iam:
withOIDC: true
managedNodeGroups:
- name: managed-ng-1
amiFamily: AmazonLinux2
# Uncomment to use - Arm-based AWS Graviton2 processors
# instanceType: t4g.medium
instanceType: t3a.medium
desiredCapacity: 2
minSize: 0
maxSize: 3
volumeSize: 30
tags:
<<: *tags
compliance:na:defender: eks-node
volumeEncrypted: true
EOF
eksctl create cluster --config-file "/tmp/eksctl-${CLUSTER_NAME}.yaml" --kubeconfig "${KUBECONFIG}"
echo -e "*****\n export KUBECONFIG=${KUBECONFIG} \n*****"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment