Skip to content

Commit 9675845

Browse files
author
charlyF
committed
2 parents ca6f5bc + b23103f commit 9675845

File tree

8 files changed

+104
-67
lines changed

8 files changed

+104
-67
lines changed

01-path-basics/101-start-here/readme.adoc

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Click on the "Deploy to AWS" button and follow the CloudFormation prompts to beg
2020

2121
[NOTE]
2222
AWS Cloud9 is currently available in 5 regions, and EKS is currently available in 2 regions (us-east-1 and us-west-2).
23-
Please choose the region closest to you. If you choose a region for Cloud9 that does not support EKS, you will need to change the `AWS_DEFAULT_REGION` environment variable later.
23+
Please choose the region closest to you. If you choose a region for Cloud9 that does not support EKS, you need to create VPC resources and change environment variables. This configuration has not been tested.
2424

2525
|===
2626

@@ -29,25 +29,17 @@ Please choose the region closest to you. If you choose a region for Cloud9 that
2929
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/v0.5/lab-ide-vpc.template]
3030
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/v0.5/lab-ide-novpc.template]
3131

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/v0.5/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/v0.5/lab-ide-novpc.template]
35-
3632
| *Oregon* (us-west-2)
3733
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/v0.5/lab-ide-vpc.template]
3834
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/v0.5/lab-ide-novpc.template]
3935

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/v0.5/lab-ide-vpc.template]
42-
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/v0.5/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/v0.5/lab-ide-vpc.template]
46-
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/v0.5/lab-ide-novpc.template]
47-
4836
|===
4937

50-
To open the Cloud9 IDE environment, click on the "Outputs" tab in CloudFormation Console and click on the "Cloud9IDE" URL.
38+
Accept the default stack name and Click *Next*. You can give Tags such as Key=Name, Value=k8s-workshop, and click *Next*. Make sure
39+
to check *I acknowledge that AWS CloudFormation might create IAM resources with custom names* and click *Create*.
40+
41+
CloudFormation creates nested stacks and builds several resources that are required for this workshop. Wait until all the resources are created. Once the status for *k8s-workshop* changes to *CREATE_COMPLETE*,
42+
you can open Cloud9 IDE. To open the Cloud9 IDE environment, click on the "Outputs" tab in CloudFormation Console and click on the "Cloud9IDE" URL.
5143

5244
image:cloudformation-output-tab.png[CloudFormation Output Tab]
5345

@@ -82,12 +74,8 @@ To install the script, run this command in the "bash" terminal tab of the Cloud9
8274

8375
image:cloud9-run-script.png[Running the script in Cloud9 Terminal]
8476

85-
If you deployed your Cloud9 IDE in any region not supported by EKS, you will need to manually set the `AWS_DEFAULT_REGION` environment variable to a region supported by EKS:
86-
87-
export AWS_DEFAULT_REGION=us-east-1
88-
echo "AWS_DEFAULT_REGION=us-east-1" >> ~/.bash_profile
8977

90-
At this point you can restart the Cloud9 IDE terminal session to ensure that the kubectl 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.
78+
At this point you can restart the Cloud9 IDE terminal session to ensure that the kubectl completion is enabled. Once a new terminal window is opened, type `kubectl ver` and press `Tab` to autocomplete and press `Enter`. This will ensure that the `kubectl` tool is installed on the command line correctly and can autocomplete.
9179

9280
[NOTE]
9381
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.

01-path-basics/101-start-here/scripts/lab-ide-build.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ chmod +x kubectl && sudo mv kubectl /usr/local/bin/
2323
echo "source <(kubectl completion bash)" >> ~/.bashrc
2424

2525
# Install Heptio Authenticator
26-
curl -o heptio-authenticator-aws https://amazon-eks.s3-us-west-2.amazonaws.com/1.10.3/2018-06-05/bin/linux/amd64/heptio-authenticator-aws
27-
chmod +x ./heptio-authenticator-aws && sudo mv heptio-authenticator-aws /usr/local/bin/
26+
curl -o aws-iam-authenticator https://amazon-eks.s3-us-west-2.amazonaws.com/1.10.3/2018-06-05/bin/linux/amd64/heptio-authenticator-aws
27+
chmod +x ./aws-iam-authenticator && sudo mv aws-iam-authenticator /usr/local/bin/
2828

2929
# Install kops
3030
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

01-path-basics/101-start-here/templates/config-k8s-workshop

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ users:
1717
user:
1818
exec:
1919
apiVersion: client.authentication.k8s.io/v1alpha1
20-
command: heptio-authenticator-aws
20+
command: aws-iam-authenticator
2121
args:
2222
- "token"
2323
- "-i"

01-path-basics/102-your-first-cluster/readme.adoc

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,54 @@ echo $EKS_SECURITY_GROUPS
6868
```
6969
If any of those environment variables are blank, please re-run the "Build Script" section of the link:../101-start-here[Cloud9 Environment Setup].
7070

71+
If you receive an *UnsupportedAvailabilityZoneException* error during EKS cluster creation, your account is using an AZ that is currently resource constrained. This occurs mostly in N.Virginia region (us-east-1).
72+
73+
```
74+
An error occurred (UnsupportedAvailabilityZoneException) when calling the CreateCluster operation: Cannot create cluster 'k8s-workshop' because us-east-1c,
75+
the targeted availability zone, does not currently have sufficient capacity to support the cluster. Retry and choose from these availability zones: us-east-1a, us-east-1b, us-east-1d
76+
```
77+
78+
If you receive this error, you need to remove the constrained AZ (us-east-1c in this example) from *`EKS_SUBNET_IDS`* environment variable. Follow these steps to update your environment variable.
79+
80+
Save the EKS recommended AZ's that is referred in your CLI output in an environment variable.
81+
Note: you only need two AZ's defined to create EKS cluster
82+
83+
$ export EKS_VALID_AZS=us-east-1a,us-east-1b
84+
85+
Run the command below to determine subnet ID's
86+
87+
$ aws ec2 describe-subnets --filters "Name=vpc-id,Values=$EKS_VPC_ID" "Name=availabilityZone,Values=$EKS_VALID_AZS" --query 'Subnets[*].[SubnetId]' --output text
88+
subnet-6e672524
89+
subnet-18b10e44
90+
91+
Save this output as `*EKS_SUBNET_IDS*` environment variable
92+
93+
$ export EKS_SUBNET_IDS=subnet-6e672524,subnet-18b10e44
94+
95+
Re-run EKS create-cluster and you should now be able to create cluster. The output should look similar to this
96+
97+
{
98+
"cluster": {
99+
"status": "CREATING",
100+
"name": "k8s-workshop",
101+
"certificateAuthority": {},
102+
"roleArn": "arn:aws:iam::123456789012:role/k8s-workshop-EksServiceRo-AWSServiceRoleForAmazonE-1PCSJFFFAF4BL",
103+
"resourcesVpcConfig": {
104+
"subnetIds": [
105+
"subnet-6e672524",
106+
"subnet-18b10e44"
107+
],
108+
"vpcId": "vpc-a779b4dd",
109+
"securityGroupIds": [
110+
"sg-d093de9a"
111+
]
112+
},
113+
"version": "1.10",
114+
"arn": "arn:aws:eks:us-east-1:123456789012:cluster/k8s-workshop",
115+
"createdAt": 1532734869.147
116+
}
117+
}
118+
71119
=== Create the configuration file
72120

73121
In order to access the cluster locally, use a configuration file (sometimes referred to as a `kubeconfig` file). This configuration file can be created automatically.
@@ -80,6 +128,12 @@ Once the cluster has moved to the `ACTIVE` state, download and run the `create-k
80128

81129
This will create a configuration file at `$HOME/.kube/config` and update the necessary environment variable for default access.
82130

131+
You can test your kubectl configuration using 'kubectl get service'
132+
133+
$ kubectl get service
134+
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
135+
kubernetes ClusterIP 10.100.0.1 <none> 443/TCP 8m
136+
83137
=== Create the worker nodes
84138

85139
Now that your EKS master nodes are created, you can launch and configure your worker nodes.
@@ -115,6 +169,20 @@ To enable worker nodes to join your cluster, download and run the `aws-auth-cm.s
115169
Watch the status of your nodes and wait for them to reach the `Ready` status.
116170

117171
$ kubectl get nodes --watch
172+
NAME STATUS ROLES AGE VERSION
173+
ip-192-168-223-116.us-west-2.compute.internal NotReady <none> 0s v1.10.3
174+
ip-192-168-223-116.us-west-2.compute.internal NotReady <none> 0s v1.10.3
175+
ip-192-168-223-116.us-west-2.compute.internal NotReady <none> 0s v1.10.3
176+
ip-192-168-147-168.us-west-2.compute.internal NotReady <none> 0s v1.10.3
177+
ip-192-168-147-168.us-west-2.compute.internal NotReady <none> 0s v1.10.3
178+
ip-192-168-102-172.us-west-2.compute.internal NotReady <none> 0s v1.10.3
179+
ip-192-168-102-172.us-west-2.compute.internal NotReady <none> 0s v1.10.3
180+
ip-192-168-223-116.us-west-2.compute.internal NotReady <none> 10s v1.10.3
181+
ip-192-168-147-168.us-west-2.compute.internal NotReady <none> 10s v1.10.3
182+
ip-192-168-102-172.us-west-2.compute.internal NotReady <none> 10s v1.10.3
183+
ip-192-168-223-116.us-west-2.compute.internal Ready <none> 20s v1.10.3
184+
ip-192-168-147-168.us-west-2.compute.internal Ready <none> 20s v1.10.3
185+
ip-192-168-102-172.us-west-2.compute.internal Ready <none> 20s v1.10.3
118186

119187
== Kubernetes Cluster Context
120188

01-path-basics/103-kubernetes-concepts/readme.adoc

Lines changed: 18 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -223,10 +223,10 @@ CPU can be requested in _cpu units_. 1 cpu unit is equivalent 1 AWS vCPU. It can
223223

224224
===== Default memory and CPU
225225

226-
By default, a container in a pod is allocated no memory request/limit and 100m CPU request and no limit. This can be verified using the previously started pod:
226+
By default, a container in a pod is not allocated any requests or limits. This can be verified using the previously started pod:
227227

228-
$ kubectl get pod/nginx-pod -o jsonpath={.spec.containers[].resources}
229-
map[requests:map[cpu:100m]]
228+
$ kubectl get pod/nginx-pod -o jsonpath={.spec.containers[].resources}
229+
map[]
230230

231231
===== Assign memory and CPU
232232

@@ -311,6 +311,10 @@ Watch the status of the Pod:
311311

312312
`OOMKilled` shows that the container was terminated because it ran out of memory.
313313

314+
To correct this, we'll need to re-create the pod with higher memory limits.
315+
316+
Although it may be instinctive to simply adjust the memory limit in the existing pod definition and re-apply it, Kubernetes does not currently support changing resource limits on running pods, so we'll need to first delete the existing pod, then recreate it.
317+
314318
In `pod-resources2.yaml`, confirm that the value of `spec.containers[].resources.limits.memory` is `300Mi`. Delete the existing Pod, and create a new one:
315319

316320
$ kubectl delete -f pod-resources1.yaml
@@ -331,7 +335,7 @@ Get more details about the resources allocated to the Pod:
331335

332336
=== Quality of service
333337

334-
Kubernetes opportunistically scavenge the difference between request and limit if they are not used by the Containers. This allows Kubernetes to oversubscribe nodes, which increases utilization, while at the same time maintaining resource guarantees for the containers that need guarantees.
338+
Kubernetes opportunistically scavenges the difference between request and limit if they are not used by the Containers. This allows Kubernetes to oversubscribe nodes, which increases utilization, while at the same time maintaining resource guarantees for the containers that need guarantees.
335339

336340
Kubernetes assigns one of the QoS classes to the Pod:
337341

@@ -920,7 +924,7 @@ As new nodes are added to the cluster, pods are started on them. As nodes are re
920924

921925
=== Create a DaemonSet
922926

923-
The folowing is an example DaemonSet that runs a Prometheus container. Let's begin with the template:
927+
The following is an example DaemonSet that runs a Prometheus container. Let's begin with the template:
924928

925929
$ cat daemonset.yaml
926930
apiVersion: extensions/v1beta1
@@ -1099,12 +1103,6 @@ Now, watch the job status again:
10991103

11001104
The output shows that the job was successfully executed.
11011105

1102-
The completed pod is not shown in the `kubectl get pods` command. Instead it can be shown by passing an additional option as shown below:
1103-
1104-
$ kubectl get pods --show-all
1105-
NAME READY STATUS RESTARTS AGE
1106-
wait-lk49x 0/1 Completed 0 1m
1107-
11081106
To delete the job, you can run this command
11091107

11101108
$ kubectl delete -f job.yaml
@@ -1184,18 +1182,7 @@ In another terminal window, watch the status of pods created:
11841182
wait-ngrgl 0/1 Completed 0 21s
11851183
wait-6l22s 0/1 Completed 0 21s
11861184

1187-
After all the pods have completed, `kubectl get pods` will not show the list of completed pods. The command to show the list of pods is shown below:
1188-
1189-
$ kubectl get pods -a
1190-
NAME READY STATUS RESTARTS AGE
1191-
wait-6l22s 0/1 Completed 0 1m
1192-
wait-f7kgb 0/1 Completed 0 2m
1193-
wait-jbdp7 0/1 Completed 0 2m
1194-
wait-ngrgl 0/1 Completed 0 1m
1195-
wait-r5v8n 0/1 Completed 0 2m
1196-
wait-smp4t 0/1 Completed 0 2m
1197-
1198-
Similarly, `kubectl get jobs` shows the status of the job after it has completed:
1185+
`kubectl get jobs` shows the status of the job after it has completed:
11991186

12001187
$ kubectl get jobs
12011188
NAME DESIRED SUCCESSFUL AGE
@@ -1209,17 +1196,13 @@ Deleting a job deletes all the pods as well. Delete the job as:
12091196

12101197
=== Prerequisites
12111198

1212-
For Kubernetes cluster versions < 1.8, Cron Job can be created with API version `batch/v2alpha1`. You can check the cluster version using this command,
1213-
1214-
$ kubectl version
1215-
Client Version: version.Info{Major:"1", Minor:"8", GitVersion:"v1.8.1", GitCommit:"f38e43b221d08850172a9a4ea785a86a3ffa3b3a", GitTreeState:"clean", BuildDate:"2017-10-12T00:45:05Z", GoVersion:"go1.9.1", Compiler:"gc", Platform:"darwin/amd64"}
1216-
Server Version: version.Info{Major:"1", Minor:"7", GitVersion:"v1.7.4", GitCommit:"793658f2d7ca7f064d2bdf606519f9fe1229c381", GitTreeState:"clean", BuildDate:"2017-08-17T08:30:51Z", GoVersion:"go1.8.3", Compiler:"gc", Platform:"linux/amd64"}
1217-
1218-
Notice that the server version is at v1.7.4. In this case, you need to explicitly enable API version `batch/v2alpha1` in Kubernetes cluster and perform a rolling-update. These steps are explained in link:../cluster-install#turn-on-an-api-version-for-your-cluster[Turn on an API version for your cluster].
1199+
For Kubernetes cluster versions < 1.8, Cron Job can be created with API version `batch/v2alpha1`. You need to explicitly enable API version `batch/v2alpha1` in Kubernetes cluster and perform a rolling-update.
12191200

1220-
NOTE: Once you switch API versions, you need to perform rolling-update of the cluster which generally takes 30 - 45 mins to complete for 3 master nodes and 5 worker nodes cluster.
1201+
If you use *Amazon EKS* for provisioning your Kubernetes cluster, your version should be >= v1.10 and you can proceed without any changes. You can check the cluster version using this command,
12211202

1222-
If you have cluster version >= 1.8, `batch/v2alpha1` API is deprecated for this version but you can switch to `batch/v1beta1` to create Cron Jobs
1203+
$ kubectl version
1204+
Client Version: version.Info{Major:"1", Minor:"10", GitVersion:"v1.10.3", GitCommit:"2bba0127d85d5a46ab4b778548be28623b32d0b0", GitTreeState:"clean", BuildDate:"2018-05-28T20:16:17Z", GoVersion:"go1.9.3", Compiler:"gc", Platform:"linux/amd64"}
1205+
Server Version: version.Info{Major:"1", Minor:"10", GitVersion:"v1.10.3", GitCommit:"2bba0127d85d5a46ab4b778548be28623b32d0b0", GitTreeState:"clean", BuildDate:"2018-05-28T20:13:43Z", GoVersion:"go1.9.3", Compiler:"gc", Platform:"linux/amd64"}
12231206

12241207
=== Create Cron Job
12251208

@@ -1578,7 +1561,7 @@ The error message indicates that a ResourceQuota is in effect, and that the Pod
15781561

15791562
Update the configuration file to:
15801563

1581-
$ cat pod-memory.yaml
1564+
$ cat pod-cpu-memory.yaml
15821565
apiVersion: v1
15831566
kind: Pod
15841567
metadata:
@@ -1597,15 +1580,15 @@ Update the configuration file to:
15971580

15981581
There is an explicity memory resource defined here. Now, try to create the pod:
15991582

1600-
$ kubectl apply -f pod-memory.yaml
1583+
$ kubectl apply -f pod-cpu-memory.yaml
16011584
pod "nginx-pod" created
16021585

16031586
The Pod is successfully created.
16041587

16051588
Get more details about the Pod:
16061589

16071590
$ kubectl get pod/nginx-pod -o jsonpath={.spec.containers[].resources}
1608-
map[requests:map[cpu:100m memory:100m]]
1591+
map[requests:map[cpu:1 memory:100m]
16091592

16101593
Get more details about the ResourceQuota:
16111594

01-path-basics/103-kubernetes-concepts/templates/pod-memory.yaml renamed to 01-path-basics/103-kubernetes-concepts/templates/pod-cpu-memory.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,6 @@ spec:
1111
resources:
1212
requests:
1313
memory: "100m"
14+
cpu: 1
1415
ports:
15-
- containerPort: 80
16+
- containerPort: 80

03-path-application-development/303-app-update/readme.adoc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ For our usecase, the application initially uses the image `arungupta/app-upgrade
1616

1717
In order to perform exercises in this chapter, you’ll need to deploy configurations to a Kubernetes cluster. To create an EKS-based Kubernetes cluster, use the link:../../01-path-basics/102-your-first-cluster#create-a-kubernetes-cluster-with-eks[AWS CLI] (recommended). If you wish to create a Kubernetes cluster without EKS, you can instead use link:../../01-path-basics/102-your-first-cluster#alternative-create-a-kubernetes-cluster-with-kops[kops].
1818

19-
All configuration files for this chapter are in the `app-udpate` directory. Make sure you change to that directory before giving any commands in this chapter.
19+
All configuration files for this chapter are in the `app-update` directory. Make sure you change to that directory before giving any commands in this chapter. If you are working in Cloud9, run:
20+
21+
cd ~/environment/aws-workshop-for-kubernetes/03-path-application-development/303-app-update/
2022

2123
== Update and Rollback
2224

0 commit comments

Comments
 (0)