/eks

AWS Engineering Learning Series - EKS

Primary LanguageShell

AWS Engineering Learning Series - EKS

Labs

Launching your Lab Environment

Follow the below steps to get setup with a Cloud9 environment and create your Cluster.

1. Launch a Cloud9 Environment

This will be where you'll be performing the labs throughout the sessions.

Click the button to begin creating a CloudFormation stack for the region you are assigned.

Preferably right click an open it in a new tab.

Region CloudFormation
eu-central-1 (Frankfurt) Launch Stack

Just before clicking "Create stack" button, please tick "I acknowledge that AWS CloudFormation might create IAM resources."

If you get stuck, the CloudFormation template is available here and also in this repo.

2. Attach the IAM Role to the Cloud9 instance

This will allow your cloud9 environment access to perform the actions needed for the sessions.

This can be done in the EC2 console, navigate to your EC2 instances, or click the link below:

Preferably right click an open it in a new tab.

Region EC2
eu-central-1 (Frankfurt) Console link
  • Select the Cloud9 instance
  • Click Actions > Instance Settings > Attach/Replace IAM Role
  • Filter the roles, searching for "cloud9"
  • Click Apply once the role is selected

3. Access your Cloud9 environment

This can be done in the Cloud9 console, navigate to Cloud9 or click the link below:

Preferably right click an open it in a new tab.

Region EC2
eu-central-1 (Frankfurt) Console link
  • Click Open IDE

4. Setup the Cloud9 environment

The environment will be our workstation for the sessions, there are a few steps needed to get it setup

  • From within the Cloud9 environment perform the below steps:

    • Click on AWS Cloud9 (top left) > Preferences
    • Click on AWS SETTINGS > Credentials
    • Turn off 'AWS managed temporary credentials'
  • Change to a dark theme if you prefer:

    • View > Themes > UI Themes > Classic Dark

Run the below commands in the Cloud9 terminal

Clone the repository

$ git clone https://github.com/aws-vls-dub/eks.git

Run the bootstrap script

The script installs and configures the necessary pre-requisites

$ eks/scripts/bootstrap.sh

Confirm the IAM role is as expected


Scaling Down your Worker Nodes

Your voucher should cover the costs for the full period of the learning series but if, between sessions, you want to prevent extra costs you can scale down your clusters using eksctl as follows:

$ eksctl get clusters
$ eksctl get nodegroup --cluster eks
$ eksctl scale nodegroup --cluster=eks --nodes=0 ng-xxxxxxx

Note: As of 2019-09-30 there is a bug with the above command github/issues/809 that does not update the min value of the auto scaling group. To get around this scale the nodes to 0, then to 1 and then to 0 again (using the last command above).

Cleanup (Only do this after the end of all three sessions)

After the end of all three sessions, follow the below steps to delete the EKS cluster and Cloud9 environment

Delete all the Services

Delete all the services of type LoadBalancer which have provisioned ELBs in your account:

$ # List all services with type LoadBalancer
$ kubectl get svc --all-namespaces -o json \
    | jq -r '.items[] | select(.spec.type == "LoadBalancer") | .metadata.name'

# For each of the outputted services do
$ kubectl delete svc <service name>
service "<service name>" deleted

Then you can delete the cluster, node group and CloudFormation stack.

Delete the EKS cluster

This can be done in the Cloud9 console, navigate to Cloud9, or click the link below:

Region EC2
eu-central-1 (Frankfurt) Console link
  • Delete the EKS cluster from the Cloud9 terminal with the below command:
$ eksctl delete cluster eks

Delete the Cloud9 CloudFormation stack

This can be done in the CloudFormation console, navigate to CloudFormation, or click the link below:

Region EC2
eu-central-1 (Frankfurt) Console link

There may be a number of stacks, select the stack named "cloud9", and click the "Delete" button