Skip to content

Latest commit

 

History

History
149 lines (90 loc) · 4.9 KB

getting-started.adoc

File metadata and controls

149 lines (90 loc) · 4.9 KB

Container Adoption Lab

Getting Started

Expected Outcome:

  • Setup Lab Environment

Lab Requirements:

  • Browser

  • AWS Account

Average Lab Time: 15 Minutes

Introduction

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.

Create AWS Cloud9 Environment

AWS Cloud9 Console

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)

deploy to aws

To open the Cloud9 IDE environment, click on the "Outputs" tab in CloudFormation Console and click on the "Cloud9IDE" URL.

CloudFormation Output Tab

You should see an environment similar to this:

cloud9 development environment welcome

Build Script

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

Running the script in Cloud9 Terminal

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:

cloud9 disable temp credentials

Create kops cluster

kops create cluster \
  --name example.cluster.k8s.local \
  --zones $AWS_AVAILABILITY_ZONES \
  --yes

Validate everything is working as intended

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.

  1. 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
  1. 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
  1. Verify that your Kubernetes cluster shows 3 instances:

    kubectl get nodes

Workshop Cleanup

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!)

Delete Kubernetes cluster resources

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

Delete Cloud9 Envionment

Go to CloudFormation console, right click template with name 'k8s-workshop' and select 'Delete Stack'

This should delete all the resources associated with this workshop