In this post we will review the steps to create a kubernetes cluster on AWS EKS service.
First we need to configure AWS CLI credentails and zone. I like to use a script to handle these configurations:
env.sh
export AWS_SHARED_CREDENTIALS_FILE=${PWD}/credentials
export AWS_CONFIG_FILE=${PWD}/config
export AWS_PAGER=""
Where the credentials file contains your AWS access key, and the config file contains the region configuration.
credentials
[default]
aws_access_key_id = XXXXXXXXXXXXXXXXXXXX
aws_secret_access_key = XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
config
[default]
region=us-east-1
output=json
AWS EKS cluster is partly managed by the eksctl CLI, which creates several AWS cloud formation templates that configure the kubernetes cluster entities on AWS.
To install eksctl, use the following:
curl --silent --location "https://github.com/weaveworks/eksctl/releases/latest/download/eksctl_$(uname -s)_amd64.tar.gz" | tar xz -C /tmp
sudo mv /tmp/eksctl /usr/local/bin
Next create a YAML file to configure the cluster:
cluster.yaml
apiVersion: eksctl.io/v1alpha5
kind: ClusterConfig
metadata:
name: my-eks-cluster
region: us-east-1
availabilityZones:
- us-east-1a
- us-east-1b
nodeGroups:
- name: ng-1
instanceType: m5.large
desiredCapacity: 2
ssh:
publicKeyPath: ./id_rsa.pub
availabilityZones:
- us-east-1a
Notice that the file points to an existing SSH public key, which will be used for the EC2 instances that are part of the cluster.
Also note that even we have used 2 availability zones for the cluster control plane, we have configured its nodes in a single availability zone, which means higher communication but less availability.
See also the schema of the YAML file here, and some examples here.
Next, we can install the cluster using the following command:
eksctl create cluster -f ./cluster.yaml
The installation lasts ~20 minutes (go have a coffee...), and it can be tracked in the AWS cloud formation GUI. Once complete, it configures the ~/.kube/config file, so we can connect to the cluster, and run, for example:
$ kubectl get nodes
NAME STATUS ROLES AGE VERSION
ip-192-168-1-114.ec2.internal Ready <none> 10m v1.18.9-eks-d1db3c
ip-192-168-12-214.ec2.internal Ready <none> 10m v1.18.9-eks-d1db3c
We can also create the ~/.kube/config on another machine using the command:
aws eks update-kubeconfig --name cdn-middle-1 --region us-east-1
Positive site, where did u come up with the information on this posting? I'm pleased I discovered it though, ill be checking back soon to find out what additional posts you include. google ads
ReplyDeleteSome of info is from AWS site https://docs.aws.amazon.com/eks/latest/userguide/eksctl.html, but other is from various posts I've found in stackoverflow, after encountering some issues.
ReplyDelete