Skip to content

Commit f750614

Browse files
authored
Merge pull request aws-samples#334 from scottmalkie/master
Learning Paths - First Pass
2 parents 9e59eb5 + b907d92 commit f750614

File tree

248 files changed

+883
-1054
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

248 files changed

+883
-1054
lines changed
Lines changed: 225 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,225 @@
1+
= Kubernetes - Setup Cloud9 Development Environment
2+
:toc:
3+
:icons:
4+
:linkattrs:
5+
:imagesdir: ../../resources/images
6+
7+
8+
This section walks you through the creating a Kubernetes development environment using https://aws.amazon.com/cloud9/[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.
9+
10+
== Create AWS Cloud9 Environment
11+
=== AWS Cloud9 Console
12+
13+
We can create the Cloud9 development environment via CloudFormation.
14+
This CloudFormation template will spin up the Cloud9 IDE, as well as configure the IDE environment for the rest of the workshop.
15+
16+
The CloudFormation template can create a new VPC, or be launched into an existing one.
17+
If you are unsure, we recommend the "Launch template with an existing VPC" option.
18+
19+
Click on the "Deploy to AWS" button and follow the CloudFormation prompts to begin.
20+
21+
[NOTE]
22+
AWS Cloud9 is currently only available in 5 regions.
23+
Please choose the region closest to you.
24+
25+
|===
26+
27+
|Region | Launch template with a new VPC | Launch template with an existing VPC
28+
| *N. Virginia* (us-east-1)
29+
a| image::./deploy-to-aws.png[link=https://console.aws.amazon.com/cloudformation/home?region=us-east-1#/stacks/new?stackName=k8s-workshop&templateURL=https://s3.amazonaws.com/aws-kubernetes-artifacts/lab-ide-vpc.template]
30+
a| image::./deploy-to-aws.png[link=https://console.aws.amazon.com/cloudformation/home?region=us-east-1#/stacks/new?stackName=k8s-workshop&templateURL=https://s3.amazonaws.com/aws-kubernetes-artifacts/lab-ide-novpc.template]
31+
32+
| *Ohio* (us-east-2)
33+
a| image::./deploy-to-aws.png[link=https://console.aws.amazon.com/cloudformation/home?region=us-east-2#/stacks/new?stackName=k8s-workshop&templateURL=https://s3.amazonaws.com/aws-kubernetes-artifacts/lab-ide-vpc.template]
34+
a| image::./deploy-to-aws.png[link=https://console.aws.amazon.com/cloudformation/home?region=us-east-2#/stacks/new?stackName=k8s-workshop&templateURL=https://s3.amazonaws.com/aws-kubernetes-artifacts/lab-ide-novpc.template]
35+
36+
| *Oregon* (us-west-2)
37+
a| image::./deploy-to-aws.png[link=https://console.aws.amazon.com/cloudformation/home?region=us-west-2#/stacks/new?stackName=k8s-workshop&templateURL=https://s3.amazonaws.com/aws-kubernetes-artifacts/lab-ide-vpc.template]
38+
a| image::./deploy-to-aws.png[link=https://console.aws.amazon.com/cloudformation/home?region=us-west-2#/stacks/new?stackName=k8s-workshop&templateURL=https://s3.amazonaws.com/aws-kubernetes-artifacts/lab-ide-novpc.template]
39+
40+
| *Ireland* (eu-west-1)
41+
a| image::./deploy-to-aws.png[link=https://console.aws.amazon.com/cloudformation/home?region=eu-west-1#/stacks/new?stackName=k8s-workshop&templateURL=https://s3.amazonaws.com/aws-kubernetes-artifacts/lab-ide-vpc.template]
42+
a| image::./deploy-to-aws.png[link=https://console.aws.amazon.com/cloudformation/home?region=us-west-2#/stacks/new?stackName=k8s-workshop&templateURL=https://s3.amazonaws.com/aws-kubernetes-artifacts/lab-ide-novpc.template]
43+
44+
| *Singapore* (ap-southeast-1)
45+
a| image::./deploy-to-aws.png[link=https://console.aws.amazon.com/cloudformation/home?region=ap-southeast-1#/stacks/new?stackName=k8s-workshop&templateURL=https://s3.amazonaws.com/aws-kubernetes-artifacts/lab-ide-vpc.template]
46+
a| image::./deploy-to-aws.png[link=https://console.aws.amazon.com/cloudformation/home?region=us-west-2#/stacks/new?stackName=k8s-workshop&templateURL=https://s3.amazonaws.com/aws-kubernetes-artifacts/lab-ide-novpc.template]
47+
48+
|===
49+
50+
To open the Cloud9 IDE environment, click on the "Output" tab in CloudFormation Console and click on the "Cloud9IDE" URL.
51+
52+
image:cloudformation-output-tab.png[CloudFormation Output Tab]
53+
54+
You should see an environment similar to this:
55+
56+
image:cloud9-development-environment-welcome.png[]
57+
58+
=== Build Script
59+
60+
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:
61+
62+
- jq
63+
- kubectl _(the Kubernetes CLI, which we'll cover in great detail later in the workshop)_
64+
- kops _(Kubernetes Operations, which we'll also cover in detail later)_
65+
- configures the AWS CLI and stores necessary environment variables in bash_profile
66+
- creates an SSH key
67+
- clone the workshop repository into Cloud9
68+
69+
To install the script, run this command in the "bash" terminal tab of the Cloud9 IDE:
70+
71+
aws s3 cp s3://aws-kubernetes-artifacts/lab-ide-build.sh . && \
72+
chmod +x lab-ide-build.sh && \
73+
. ./lab-ide-build.sh
74+
75+
image:cloud9-run-script.png[Running the script in Cloud9 Terminal]
76+
77+
[NOTE]
78+
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.
79+
80+
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:
81+
82+
image:cloud9-disable-temp-credentials.png[]
83+
84+
85+
You are now ready to continue on with the workshop!
86+
87+
:frame: none
88+
:grid: none
89+
:valign: top
90+
91+
[align="center", cols="3", grid="none", frame="none"]
92+
|=====
93+
|image:button-continue-standard.png[link=../102-your-first-cluster/]
94+
|image:button-continue-developer.png[link=../102-your-first-cluster/]
95+
|image:button-continue-operations.png[link=../102-your-first-cluster/]
96+
|=====
97+
98+
The next step is link:../102-your-first-cluster[to create a Kubernetes cluster using kops].
99+
100+
== Workshop Cleanup
101+
102+
Once you have finished with the workshop, please don't forget to spin down your cluster or you will incur additional charges.
103+
(We will also remind you at the end!)
104+
105+
==== Delete Kubernetes cluster resources
106+
107+
In your Cloud9 IDE, check if there are any running kubernetes cluster
108+
109+
$ kops get cluster
110+
111+
Delete kubernetes cluster
112+
113+
$ kops delete cluster example.cluster.k8s.local --yes
114+
115+
Wait until all resources are deleted by kops
116+
117+
==== Delete Cloud9 Envionment
118+
119+
Go to CloudFormation console, right click template with name 'k8s-workshop' and select 'Delete Stack'
120+
121+
This should delete all the resources associated with this workshop
122+
123+
124+
== Appendix: Manual Cloud9 Configuration
125+
126+
This appendix provides instructions for those who don't want to use the provided CloudFormation template, or who would like to configure Cloud9 manually.
127+
128+
AWS Cloud9 is only available in 5 regions currently. Please choose the region closest to you geographically.
129+
130+
[cols="1*^"]
131+
|===
132+
|link:https://us-east-1.console.aws.amazon.com/cloud9/home/create[*N. Virginia* (us-east-1)]
133+
|link:https://us-east-2.console.aws.amazon.com/cloud9/home/create[*Ohio* (us-east-2)]
134+
|link:https://us-west-2.console.aws.amazon.com/cloud9/home/create[*Oregon* (us-west-2)]
135+
|link:https://eu-west-1.console.aws.amazon.com/cloud9/home/create[*Ireland* (eu-west-1)]
136+
|link:https://ap-southeast-1.console.aws.amazon.com/cloud9/home/create[*Singapore* (ap-southeast-1)]
137+
|===
138+
139+
Once there, follow these steps:
140+
141+
1. Provide a name for your environment. Feel free to use something simple, such as `k8s-workshop`. Then click "Next Step".
142+
143+
2. Change the "Instance Type" to `t2.small (2 GiB RAM + 1 vCPU)`.
144+
145+
3. Expand the "Network settings (advanced)" section and make sure you are using the default VPC. It will have "(default)" next to the name. If you do not have a default VPC listed, it is recommended that you create a "Single Public Subnet" VPC by clicking the "Create new VPC" button and following the wizard it presents.
146+
147+
4. If everything is correct, click the "Next Step" button.
148+
149+
5. Review the configuration to ensure everything is correct and then click the "Create environment" button.
150+
151+
This will close the wizard and you will be taken to a screen informing you that your new AWS Cloud9 environment is being created. Once this is completed, the IDE will open to the following screen:
152+
153+
image:cloud9-development-environment-welcome.png[]
154+
155+
Your environment is now ready to be setup for working with Kubernetes and the rest of this workshop.
156+
157+
=== Set up Environment
158+
159+
Your AWS Cloud9 environment comes with many useful tools preinstalled, but there are still a few tweaks to these and additional tools you will need to support working with Kubernetes.
160+
161+
=== Configure the AWS CLI
162+
163+
Your AWS Cloud9 environment comes with the AWS CLI preinstalled and configured to automatically use the credentials of the currently logged in user. Make sure you are logged in as a user with link:aws-permissions.adoc[these permissions.]
164+
165+
[NOTE]
166+
*********************
167+
It is not recommended that you change the default AWS CLI config in your AWS Cloud9 environment. Instead, it is recommended that you provide the logged in user's account the permissions needed to make any requests needed by your project. More information on this can be found by visiting: https://docs.aws.amazon.com/cloud9/latest/user-guide/credentials.html[Calling AWS Services from an Environment in AWS Cloud9]
168+
*********************
169+
170+
[NOTE]
171+
All the commands below should be run in the Terminal section of your Cloud9 GUI.
172+
173+
=== Verify Docker Version
174+
175+
Docker is preinstalled. You can verify the version by running the following:
176+
177+
$ docker --version
178+
Docker version 17.06.2-ce, build 3dfb8343b139d6342acfd9975d7f1068b5b1c3d3
179+
180+
You should have a similar or newer version.
181+
182+
=== Install Kubectl CLI
183+
184+
Install the Kubectl CLI:
185+
186+
$ curl -Lo kubectl https://storage.googleapis.com/kubernetes-release/release/v1.9.2/bin/linux/amd64/kubectl && chmod +x kubectl && sudo mv kubectl /usr/local/bin/
187+
188+
Add kubectl autocompletion to your current shell:
189+
190+
$ source <(kubectl completion bash)
191+
192+
You can verify that kubectl is installed by executing the following command:
193+
194+
$ kubectl version --client
195+
Client Version: version.Info{Major:"1", Minor:"9", GitVersion:"v1.9.2", GitCommit:"6e937839ac04a38cac63e6a7a306c5d035fe7b0a", GitTreeState:"clean", BuildDate:"2017-09-28T22:57:57Z", GoVersion:"go1.8.3", Compiler:"gc", Platform:"linux/amd64"}
196+
197+
=== Install kops
198+
199+
Install kops using the following:
200+
201+
$ curl -LO https://github.com/kubernetes/kops/releases/download/$(curl -s https://api.github.com/repos/kubernetes/kops/releases/latest | grep tag_name | cut -d '"' -f 4)/kops-linux-amd64
202+
$ chmod +x kops-linux-amd64
203+
$ sudo mv kops-linux-amd64 /usr/local/bin/kops
204+
205+
=== Configure an S3 bucket for kops
206+
207+
kops needs a "`state store`" to store configuration information of the cluster. We will use a s3 bucket with versioning enabled. A state store can work with multiple kops clusters.
208+
209+
[NOTE]
210+
The bucket name must be unique otherwise you will encounter an error on deployment. We will use an example bucket name of `kops-state-store-` and add a randomly generated string to the end.
211+
212+
$ export S3_BUCKET=kops-state-store-$(cat /dev/urandom | LC_ALL=C tr -dc "[:alpha:]" | tr '[:upper:]' '[:lower:]' | head -c 32)
213+
$ export KOPS_STATE_STORE=s3://${S3_BUCKET}
214+
$ aws s3 mb $KOPS_STATE_STORE
215+
$ aws s3api put-bucket-versioning --bucket $S3_BUCKET --versioning-configuration Status=Enabled
216+
217+
=== Clone the repository
218+
219+
The workshop repository has configuration files that are used to create Kubernetes resources. You need to clone the repo to have access to those files:
220+
221+
$ git clone https://github.com/aws-samples/aws-workshop-for-kubernetes
222+
223+
At this point, you should have everything you need to complete any of the sections of the this workshop using your Cloud9 Environment.
224+
225+
====

cloud9-development/templates/lab-ide-novpc.template renamed to 01-path-basics/101-start-here/templates/lab-ide-novpc.template

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,9 +287,17 @@
287287
"Fn::Join": [
288288
"",
289289
[
290-
"https://console.aws.amazon.com/cloud9/ide/",
290+
"https://",
291+
{
292+
"Ref": "AWS::Region"
293+
},
294+
".console.aws.amazon.com/cloud9/ide/",
291295
{
292296
"Ref": "LabIDE"
297+
},
298+
"?region=",
299+
{
300+
"Ref": "AWS::Region"
293301
}
294302
]
295303
]

cloud9-development/templates/lab-ide-vpc.template renamed to 01-path-basics/101-start-here/templates/lab-ide-vpc.template

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -497,9 +497,17 @@
497497
"Fn::Join": [
498498
"",
499499
[
500-
"https://console.aws.amazon.com/cloud9/ide/",
500+
"https://",
501+
{
502+
"Ref": "AWS::Region"
503+
},
504+
".console.aws.amazon.com/cloud9/ide/",
501505
{
502506
"Ref": "LabIDE"
507+
},
508+
"?region=",
509+
{
510+
"Ref": "AWS::Region"
503511
}
504512
]
505513
]
File renamed without changes.

0 commit comments

Comments
 (0)