Skip to content

Commit 4ef27b6

Browse files
authored
Merge pull request aws-samples#327 from dalbhanj/master
minor changes to automated cloud9 readme
2 parents 1fb74d3 + 77a85e0 commit 4ef27b6

File tree

6 files changed

+88
-79
lines changed

6 files changed

+88
-79
lines changed

cloud9-development/readme.adoc

Lines changed: 77 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -87,99 +87,99 @@ At this point, you should have everything you need to complete any of the sectio
8787

8888
=== Automated Deployment using CloudFormation
8989

90-
You can also use a CloudFormation template to create the Kubernetes Development Environment. These templates will create the Cloud9 IDE with IAM Role as well as the kops state store bucket.
90+
You can also use CloudFormation templates to create the Cloud9 development environment. The template will create the Cloud9 IDE, IAM Role required for kops and S3 bucket for kops state store.
9191

92-
To launch the template in your account, you will need to download one of the following:
92+
|===
9393

94-
* To use an existing Subnet, download link:templates/lab-ide-novpc.template[lab-ide-novpc.template]
95-
* To use a new VPC/Subnet, download link:templates/lab-ide-vpc.template[lab-ide-vpc.template]
94+
|Region | Launch template with new VPC | Launch template with existing VPC
95+
| *N. Virginia* (us-east-1)
96+
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]
97+
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]
9698

97-
==== Option 1: Console
99+
| *Ohio* (us-east-2)
100+
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]
101+
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]
98102

99-
1. Log into the AWS CloudFormation Console by visiting https://console.aws.amazon.com/cloudformation/home
103+
| *Oregon* (us-west-2)
104+
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]
105+
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]
100106

101-
2. Click on **Create Stack**.
107+
| *Ireland* (eu-west-1)
108+
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]
109+
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]
102110

103-
3. Under **Choose a Template**, click to *Upload a template to Amazon S3* and upload the file you downloaded earlier.
111+
| *Frankfurt* (eu-central-1)
112+
a| image::./deploy-to-aws.png[link=https://console.aws.amazon.com/cloudformation/home?region=eu-central-1#/stacks/new?stackName=k8s-workshop&templateURL=https://s3.amazonaws.com/aws-kubernetes-artifacts/lab-ide-vpc.template]
113+
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]
104114

105-
4. Click **Next**.
115+
| *Singapore* (ap-southeast-1)
116+
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]
117+
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]
106118

107-
5. Specify a `Stack Name` and optionally a `SubnetId`. Click **Next**.
119+
| *Sydney* (ap-southeast-2)
120+
a| image::./deploy-to-aws.png[link=https://console.aws.amazon.com/cloudformation/home?region=ap-southeast-2#/stacks/new?stackName=k8s-workshop&templateURL=https://s3.amazonaws.com/aws-kubernetes-artifacts/lab-ide-vpc.template]
121+
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]
108122

109-
6. Scroll down to the bottom and click **Next**.
123+
| *Tokyo* (ap-northeast-1)
124+
a| image::./deploy-to-aws.png[link=https://console.aws.amazon.com/cloudformation/home?region=ap-northeast-1#/stacks/new?stackName=k8s-workshop&templateURL=https://s3.amazonaws.com/aws-kubernetes-artifacts/lab-ide-vpc.template]
125+
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]
110126

111-
7. Under **Capabilities**, acknowledge that CloudFormation will create IAM resources, and click **Create**.
127+
|===
112128

113-
8. Wait until the stack you just launched has a status of `CREATE_COMPLETE` (you may need to refresh), then check the box next to the new stack and select the **Outputs** tab. This will show the URL to the Cloud9 IDE (`LabIdeUrl`). Click the URL to go into your IDE.
129+
To open Cloud9 IDE environment, click on Output tab in CloudFormation Console and open Cloud9 URL
114130

115-
9. Download the build script: link:scripts/lab-ide-build.sh[lab-ide-build.sh].
131+
https://console.aws.amazon.com/cloud9/ide/<EnvironmentId>
116132

117-
10. Copy the contents of the build script and paste into the *Terminal* window in the IDE (near the bottom).
118133

119-
At this point, you should have everything you need to complete any of the section of the this workshop using your Cloud9 Environment.
134+
==== Build script
120135

121-
==== Option 2: CLI
122-
123-
Get a list of existing public subnets.
124-
125-
.Command
126-
[source,bash]
127-
----
128-
aws ec2 describe-subnets --query 'Subnets[?MapPublicIpOnLaunch==`true`].SubnetId'
129-
----
130-
131-
.Output
132-
[source,output]
133-
----
134-
[
135-
"subnet-1234abcd",
136-
"subnet-5678ef12",
137-
...
138-
]
139-
----
140-
141-
Launch the CloudFormation stack, substituting a SubnetId for `<SubnetId>`.
142-
143-
.Command
144-
[source,bash]
145-
----
146-
aws cloudformation create-stack --stack-name "LabIDE" --template-body file://lab-ide-novpc.template --capabilities CAPABILITY_NAMED_IAM --parameters ParameterKey=SubnetId,ParameterValue=<SubnetId>
147-
----
148-
149-
If you are using the link:templates/lab-ide-vpc.template[lab-ide-vpc.template], launch the stack using:
150-
151-
.Command
152-
[source,bash]
153-
----
154-
aws cloudformation create-stack --stack-name "LabIDE" --template-body file://lab-ide-vpc.template --capabilities CAPABILITY_NAMED_IAM
155-
----
156-
157-
Once launched, occasionally poll the status of the stack.
158-
159-
.Command
160-
[source,bash]
161-
----
162-
aws cloudformation describe-stacks --stack-name LabIDE --query "Stacks[0].StackStatus" --output text
163-
----
164-
165-
When this changes from `CREATE_IN_PROGRESS` to `CREATE_COMPLETE`, get the URL of the Cloud9 IDE.
166-
167-
.Command
168-
[source,bash]
169-
----
170-
aws cloudformation describe-stacks --stack-name LabIDE --query 'Stacks[0].Outputs[?OutputKey==`LabIdeUrl`].OutputValue' --output text
171-
----
172-
173-
.Output
174-
[source,output]
175-
----
176-
https://console.aws.amazon.com/cloud9/ide/<EnvironmentId>
177-
----
136+
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 will install the following,
178137

179-
Launch the IDE by copying the URL into your browser.
138+
- jq
139+
- kubectl
140+
- kops
141+
- configures AWS CLI and stores variables in bash_profile (for ex: AWS_AVAILABILITY_ZONES, KOPS_STATE_STORE etc)
142+
- creates an SSH key
143+
- clone's workshop repository into Cloud9
180144

181-
Download the build script: link:scripts/lab-ide-build.sh[lab-ide-build.sh].
145+
Run these commands in your Cloud9 IDE
182146

183-
Copy the contents of the build script and paste into the *Terminal* window in the IDE (near the bottom).
147+
aws s3 cp s3://aws-kubernetes-artifacts/lab-ide-build.sh .
148+
chmod +x lab-ide-build.sh
149+
. ./lab-ide-build.sh
184150

185-
At this point, you should have everything you need to complete any of the section of the this workshop using your Cloud9 Environment.
151+
One last step is required so that Cloud9 IDE uses assigned IAM Instance profile. Open Cloud9 preferences and go to AWS Settings to disable AWS managed temporary credential as depicted in the diagram
152+
153+
image:cloud9-disable-temp-credentials.png[]
154+
155+
156+
Go to this link link:../cluster-install[to create Kubernetes cluster using kops]
157+
158+
159+
=== Workshop cleanup
160+
161+
==== Delete kubernetes cluster resources
162+
163+
In your Cloud9 IDE, check if there are any running kubernetes cluster
164+
165+
kops get cluster
166+
167+
Delete kubernetes cluster
168+
169+
kops delete cluster example.cluster.k8s.local --yes
170+
171+
Wait until all resources are deleted by kops
172+
173+
==== Delete S3 bucket
174+
175+
See the link:https://docs.aws.amazon.com/AmazonS3/latest/user-guide/empty-bucket.html[documentation] to delete S3 bucket using AWS Console
176+
177+
Note: you can get the name of S3 bucket name (KOPS_STATE_STORE) in the Outputs tab in your CloudFormation Console
178+
179+
==== Delete Cloud9
180+
181+
Go to CloudFormation console, right click template with name 'k8s-workshop' and select #Delete Stack
182+
183+
This should delete all the resources associated with this workshop
184+
185+
====

cloud9-development/scripts/lab-ide-build.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,5 +41,8 @@ echo "AWS_AVAILABILITY_ZONES=$AWS_AVAILABILITY_ZONES" >> ~/.bash_profile
4141
echo "KOPS_STATE_STORE=$KOPS_STATE_STORE" >> ~/.bash_profile
4242
echo "export AWS_AVAILABILITY_ZONES KOPS_STATE_STORE" >> ~/.bash_profile
4343

44+
# Create SSH key
45+
ssh-keygen -t rsa -N "" -f ~/.ssh/id_rsa
46+
4447
# Download lab Repository
4548
git clone https://github.com/aws-samples/aws-workshop-for-kubernetes

cloud9-development/templates/lab-ide-novpc.template

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,9 @@
237237
]
238238
]
239239
}
240-
}
240+
},
241+
"KOPSSTATESTORE": {
242+
"Value": { "Ref": "KopsStateStore" }
243+
}
241244
}
242245
}

cloud9-development/templates/lab-ide-vpc.template

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,7 @@
435435
}
436436
},
437437
"Outputs": {
438-
"LabIdeUrl": {
438+
"Cloud9IDE": {
439439
"Value": {
440440
"Fn::Join": [
441441
"",
@@ -447,6 +447,9 @@
447447
]
448448
]
449449
}
450+
},
451+
"KOPSSTATESTORE": {
452+
"Value": { "Ref": "KopsStateStore" }
450453
}
451454
}
452455
}
90.7 KB
Loading

images/deploy-to-aws.png

907 Bytes
Loading

0 commit comments

Comments
 (0)