Expected Outcome:
-
Setup Lab Environment
Lab Requirements:
-
Browser
-
AWS Account
Average Lab Time: 15 Minutes
This section walks you through the creating a Kubernetes development environment using AWS Cloud9. This will provide you with a cloud-based integrated development environment (IDE) that will let you write, run, and debug containerized workloads using just a web browser. We will also deploy an RDS instance, ECR repository and a Jenkins instance for the CI/CD portion of the workshop.
We can create the Cloud9 development environment via CloudFormation. This CloudFormation template will spin up the Cloud9 IDE, as well as configure the IDE environment for the rest of the workshop.
Click on the "Deploy to AWS" button and follow the CloudFormation prompts to begin.
Note
|
Please choose the region closest to you. |
Region |
Launch template in a new VPC |
Oregon (us-west-2) |
To open the Cloud9 IDE environment, click on the "Outputs" tab in CloudFormation Console and click on the "Cloud9IDE" URL.
You should see an environment similar to this:
Once your Cloud9 is ready, download the build script and install in your IDE. This will prepare your IDE for running tutorials in this workshop. The build script installs the following:
-
jq
-
kubectl (the Kubernetes CLI, which we’ll cover in great detail later in the workshop)
-
kops (Kubernetes Operations, which we’ll also cover in detail later)
-
configures the AWS CLI and stores necessary environment variables in bash_profile
-
creates an SSH key
-
clone the workshop repository into Cloud9
To install the script, run this command in the "bash" terminal tab of the Cloud9 IDE:
aws s3 cp s3://aws-container-migration-workshop/lab-ide-build.sh . && \ chmod +x lab-ide-build.sh && \ . ./lab-ide-build.sh
Note
|
All shell commands (starting with "$") throughout the rest of the workshop should be run in this tab. You may want to resize it upwards to make it larger. |
At this point you can restart the Cloud9 IDE terminal session to ensure that the kublectl completion is enabled. Once a new terminal window is opened, type kubectl get nodes
. You do not have to run the command. It is normal for this command to fail with an error message if you run it. You have not yet created the Kubernetes cluster. We are merely testing to make sure the kubectl
tool is installed on the command line correctly and can autocomplete.
One last step is required so that the Cloud9 IDE uses the assigned IAM Instance profile. Open the "AWS Cloud9" menu, go to "Preferences", go to "AWS Settings", and disable "AWS managed temporary credentials" as depicted in the diagram here:
kops create cluster \ --name example.cluster.k8s.local \ --zones $AWS_AVAILABILITY_ZONES \ --yes
We deployed a good amount of AWS resources and infrastructure, before moving on lets perform a few validation tests to assure everything is working as intended.
-
Validate connection to the postgres instance. Check the output from the main cloudformation stack and look for the "RDSEndpoint".
Connect to your postgresql instance:
psql -h <RDSEndpoint> -U petstore -d postgres
Create the petstore db
CREATE DATABASE petstore;
Show all databases:
\l
Exit database:
\q
-
Verify connection to the Jenkins instance
From the cloudformation output retrieve the Jenkins ip and open in a browser. The credentials are as follows:
u: jenkins p: jenkins101
-
Verify that your Kubernetes cluster shows 3 instances:
kubectl get nodes
Once you have finished with the workshop, please don’t forget to spin down your cluster or you will incur additional charges. (We will also remind you at the end!)
In your Cloud9 IDE, check if there are any running kubernetes clusters
$ kops get cluster
Delete kubernetes cluster
$ kops delete cluster example.cluster.k8s.local --yes
Wait until all resources are deleted by kops