Skip to content

Commit bf417cf

Browse files
committed
Update docs after last workshop
1 parent ce0413b commit bf417cf

File tree

17 files changed

+180
-98
lines changed

17 files changed

+180
-98
lines changed

Makefile

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
build-and-push: backend frontend-v1 frontend-v2
2+
build-and-push: backend frontend-v1 frontend-v2 frontend-v3
33

44
backend:
55
cd services/calculator-backend && \
@@ -16,5 +16,10 @@ frontend-v2:
1616
docker build -t quay.io/kubernetes-workshop/calculator-frontend:v2 --build-arg appVersion=2 .
1717
docker push quay.io/kubernetes-workshop/calculator-frontend:v2
1818

19+
frontend-v3:
20+
cd services/calculator-frontend && \
21+
docker build -t quay.io/kubernetes-workshop/calculator-frontend:v3 --build-arg appVersion=3 .
22+
docker push quay.io/kubernetes-workshop/calculator-frontend:v3
23+
1924
serve-docs:
2025
cd docs && docker run --rm -it --name github-pages -u `id -u`:`id -g` -v `pwd`:/usr/src/app -p 4000:4000 starefossen/github-pages jekyll serve --watch --force_polling -H 0.0.0.0 -P 4000

docs/_config.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@ description: Start with us your first kubernetes workloads!
44

55
remote_theme: pmarsceill/[email protected]
66
aux_links:
7-
"GitHub": "https://github.com/itdesign/kubernetes-workshop"
8-
"itdesign GmbH": "https://itdesign.de"
7+
"Slides": "https://bit.ly/itd-k8s-slides"
8+
"Source on GitHub": "https://github.com/itdesign/kubernetes-workshop"
9+
"Jobs at itdesign GmbH": "https://itdesign.de/jobs"
910

1011
plugins:
1112
- jekyll-redirect-from

docs/_sass/custom/custom.scss

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,27 @@ $link-color: #a71417;
55
margin: 5px;
66
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.07), 0 4px 14px rgba(0, 0, 0, 0.05);
77
}
8-
input,
9-
button {
10-
padding: 5px;
11-
border-radius: 5px;
12-
border: 1px solid #ccc;
13-
}
14-
button {
15-
background-color: #555;
16-
font-size: 0.9em;
17-
color: #fff;
18-
}
8+
199
::placeholder {
2010
color: #ccc;
2111
}
12+
.customization {
13+
padding: 10px;
14+
background-color: rgba(167, 20, 23, 0.5);
15+
color: #fff;
16+
input {
17+
color: #000;
18+
}
19+
input,
20+
button {
21+
padding: 5px;
22+
border-radius: 5px;
23+
border: 0;
24+
}
25+
button {
26+
background-color: #555;
27+
font-size: 0.9em;
28+
color: #fff;
29+
}
30+
}
2231
}

docs/tutorial/00-get-started/01-setup-account.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,10 @@ The project in Google Cloud contains all the resources you will create during th
1414
1. Open the [Cloud Console](https://console.cloud.google.com)
1515
2. Login with your Google account used for registration
1616
3. Find your personal project for the workshop (`k8sworkshop-stuttgart2019-[0-9]+`)
17-
4. Enter your project id below, this will customize the tutorial<br>
17+
4. <div class="customization">
18+
Enter your project id below, this will customize the tutorial:<br>
1819
<input id="gcloud-project-id" placeholder="k8sworkshop-stuttgart2019-22" style="width:300px"> <button id="gcloud-project-id-apply">Apply</button>
20+
</div>
1921

2022
## Start Cloud Shell
2123

@@ -35,4 +37,4 @@ We have a repository that contains examples and solutions that will help to solv
3537
```
3638
2. You should see the repository with its directories in the upper screen:
3739
![Screenshot of workspace files in cloud shell](01-workspace-files.png)
38-
3. The directory `kubernetes-workshop/k8s-files` contains everything we need for the workshop.
40+
3. The directory `kubernetes-workshop/k8s-examples` contains everything we need for the workshop.

docs/tutorial/00-get-started/03-access-cluster.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,13 @@ The Cloud Shell provides a proxy that allows us access to the resources in your
1515
```
1616
2. Access your cluster using the preview functionality of Cloud Shell:
1717
![Screenshot of Cloud Shell preview](03-cloud-shell-preview.png)
18-
3. This will open a new tab with an URL like `https://8080-dot-7136354-dot-devshell.appspot.com/path`.
19-
Paste the URL **without** the path into the following field, it will customize the tutorial:<br>
20-
<input id="gcloud-shell-url" placeholder="https://8080-dot-7136354-dot-devshell.appspot.com" style="width:400px"> <button id="gcloud-shell-url-apply">Apply</button><br>
21-
4. Test [this link]($GCLOUD_SHELL_URL/version) to verify the proxy is set up correctly. You should see a JSON response:
18+
3. This will open a new tab with an URL.
19+
4. <div class="customization">
20+
Paste the URL <b>without</b> the path into the following field, it will customize the tutorial:<br>
21+
Example: https://8080-dot-7136354-dot-devshell.appspot.com<br>
22+
<input id="gcloud-shell-url" placeholder="https://8080-dot-7136354-dot-devshell.appspot.com" style="width:400px"> <button id="gcloud-shell-url-apply">Apply</button>
23+
</div>
24+
5. Test [this link]($GCLOUD_SHELL_URL/version) to verify the proxy is set up correctly. You should see a JSON response:
2225
```json
2326
{
2427
"major": "1",

docs/tutorial/01-run-the-backend/01-first-pod.md

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -52,19 +52,20 @@ pod "calculator-backend" created
5252

5353
## Monitor the startup
5454

55-
You can now monitor the startup of the pod with `kubectl get pods -w`. The flag `-w` enables the
56-
watch mode on every update the console is updated with the new pod state.
55+
You can now monitor the startup of the pod with `kubectl get pods`.
5756

58-
You can exit the watch mode with `ctrl-c`.
57+
After a successful startup the output should look like this:
5958

60-
The output can be seen as follows:
59+
```
60+
NAME READY STATUS RESTARTS AGE
61+
calculator-backend 1/1 Running 0 3s
62+
```
63+
64+
During the startup the console would look like this:
6165

6266
```
6367
NAME READY STATUS RESTARTS AGE
6468
calculator-backend 0/1 Pending 0 0s
65-
calculator-backend 0/1 Pending 0 0s
66-
calculator-backend 0/1 ContainerCreating 0 0s
67-
calculator-backend 1/1 Running 0 3s
6869
```
6970

7071
## Access the pod
@@ -85,7 +86,7 @@ To run your calculation against the API you can use the Swagger UI.
8586

8687
1. Click on `GET /calculate`
8788
2. Click on `Try it out` on the right side
88-
3. Enter a expression into the field, e.g. `100 * sqrt(3)`
89+
3. Enter a valid expression into the field, e.g. `100 * sqrt(3)`
8990
4. Click on `Execute`
9091
5. The UI displays the response below:
9192
![Screenshot of the response](01-api-response-success.png)
@@ -103,4 +104,4 @@ The service does not handle invalid expressions well. It crashes when an invalid
103104
3. Execute an invalid expression, e.g. `sqrt(Hello World)`
104105
4. The UI displays the error:
105106
![Screenshot of the response](01-api-response-error.png)
106-
5. Try a valid expression, there will still be an error.
107+
5. Now try a valid expression, there will still be an error.

docs/tutorial/01-run-the-backend/03-deployment.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,13 @@ We will change the configuration to use a deployment instead of a manually creat
1919

2020
## Write the deployment definition
2121

22-
To get started copy the contents of `kubernetes-workshop/k8s-examples/deployment.yml` into your `backend.yml`.
23-
24-
1. Under `.spec.template.spec` you'll find the similar fields like in the pod configuration, make the same changes as previously.
25-
2. The two new configuration items `livenessProbe` and `readinessProbe` need to configured with the correct port of your service, otherwise the health checks will fail.
26-
3. Ensure that the deployment has the name `calculator-backend`.
27-
4. Also ensure that `.template.metadata.labels.'app.kubernetes.io/name'` is set to the same value, we will need this later.
22+
1. Delete all contents of your `backend.yml`.
23+
2. Copy the contents from `kubernetes-workshop/k8s-examples/deployment.yml`.
24+
3. Under `.spec.template.spec` you'll find the similar fields like in the pod configuration, make the same changes as previously.
25+
4. The two new configuration items `livenessProbe` and `readinessProbe` need to configured with the correct port of your service, otherwise the health checks will fail.
26+
5. Ensure that the deployment has the name `calculator-backend`.
27+
6. Also ensure that `.template.metadata.labels.'app.kubernetes.io/name'` is set to the same value, we will need this later.
28+
7. The last required change is to set `.spec.selector.matchLabels` to the same content as the labels.
2829

2930
## Apply the pod definition
3031

docs/tutorial/01-run-the-backend/04-fault-tolerance.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,11 @@ service does only provide access to the pods that are up and running. Crashed po
7373
```
7474
3. Use the correct selector at `.spec.selectors.'app.kubernetes.io/name'` to find the pods of your `calculator-backend`. The selector
7575
is used to identify the pods which should be load balanced by the service.
76-
4. Use the right `targetPort` so that the service can find our backend (look at `.spec.containers[].ports`).
76+
4. Set `.metadata.name` to `calculator-backend`.
77+
5. Use the right `targetPort` so that the service can find our backend (look at `.spec.containers[].ports`).
7778
![Diagram of port definitions between services](04-service-ports.svg)
78-
5. Use `kubectl apply -f k8s-files/` to apply the changes.
79-
6. `kubectl get services -o wide` should now show the service:
79+
6. Use `kubectl apply -f k8s-files/` to apply the changes.
80+
7. `kubectl get services -o wide` should now show the service:
8081
```
8182
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE SELECTOR
8283
calculator-backend ClusterIP 10.110.74.55 <none> 80/TCP 11m app=calculator-backend

docs/tutorial/02-add-the-frontend/02-public-access.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ We will now expose the frontend to the public internet.
1212

1313
## Change the configuration
1414

15-
1. Edit the `frontend.yml` and change the type from `ClusterIP` to `LoadBalancer`.
15+
1. Edit the `frontend.yml` and set the service to `LoadBalancer`. You need to have a look into the [API documentation](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.11/#servicespec-v1-core) of Kubernetes.
1616
2. Apply the configuration: `kubectl apply -f k8s-files/`.
1717
3. Watch for the service to update: `kubectl get svc -w`
1818
4. The service changed the type to `LoadBalancer` and external-ip changed into the state `<pending>`, we will now wait until an IP is assigned.
@@ -23,8 +23,10 @@ We will now expose the frontend to the public internet.
2323
calculator-frontend LoadBalancer 10.3.248.49 <pending> 80:31311/TCP 3s
2424
calculator-frontend LoadBalancer 10.3.248.49 35.246.160.32 80:31311/TCP 1m
2525
```
26+
<div class="customization">
2627
Enter the external IP of your service, this will customize the tutorial:<br>
2728
<input id="gcloud-public-ip" placeholder="35.246.160.32" style="width:400px"> <button id="gcloud-public-ip-apply">Apply</button>
29+
</div>
2830
6. You can now access your frontend using [`http://$GCLOUD_PUBLIC_IP/`](http://$GCLOUD_PUBLIC_IP/).
2931

3032
The following chapter will give you more details about the network architecture in the background.

docs/tutorial/02-add-the-frontend/04-rolling-update.md

Lines changed: 2 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -21,40 +21,7 @@ It provides some new features we will look into later.
2121

2222
1. Change the docker image tag in your `frontend.yml` from `v1` to `v2`.
2323
2. Apply the changes `kubectl apply -f k8s-files/`
24-
3. Watch for the rolling update: `kubectl get pods -w`
25-
```
26-
NAME READY STATUS AGE
27-
calculator-frontend-6b5d85558c-4mh2s 1/1 Running 1h
28-
calculator-frontend-6b5d85558c-9nzh2 1/1 Running 1h
29-
calculator-frontend-6b5d85558c-msppb 1/1 Running 1h
30-
calculator-frontend-d69f59b46-fvp54 0/1 Pending 0s
31-
calculator-frontend-d69f59b46-fvp54 0/1 Pending 1s
32-
calculator-frontend-d69f59b46-fvp54 0/1 ContainerCreating 1s
33-
calculator-frontend-d69f59b46-fvp54 0/1 Running 5s
34-
calculator-frontend-d69f59b46-fvp54 1/1 Running 8s
35-
calculator-frontend-6b5d85558c-msppb 1/1 Terminating 1h
36-
calculator-frontend-d69f59b46-mfmpm 0/1 Pending 0s
37-
calculator-frontend-d69f59b46-mfmpm 0/1 Pending 0s
38-
calculator-frontend-d69f59b46-mfmpm 0/1 ContainerCreating 0s
39-
calculator-frontend-6b5d85558c-msppb 0/1 Terminating 1h
40-
calculator-frontend-d69f59b46-mfmpm 0/1 Running 4s
41-
calculator-frontend-6b5d85558c-msppb 0/1 Terminating 1h
42-
calculator-frontend-6b5d85558c-msppb 0/1 Terminating 1h
43-
calculator-frontend-d69f59b46-mfmpm 1/1 Running 8s
44-
calculator-frontend-6b5d85558c-9nzh2 1/1 Terminating 1h
45-
calculator-frontend-d69f59b46-v2vgv 0/1 Pending 0s
46-
calculator-frontend-d69f59b46-v2vgv 0/1 Pending 0s
47-
calculator-frontend-d69f59b46-v2vgv 0/1 ContainerCreating 0s
48-
calculator-frontend-6b5d85558c-9nzh2 0/1 Terminating 1h
49-
calculator-frontend-d69f59b46-v2vgv 0/1 Running 3s
50-
calculator-frontend-6b5d85558c-9nzh2 0/1 Terminating 1h
51-
calculator-frontend-6b5d85558c-9nzh2 0/1 Terminating 1h
52-
calculator-frontend-d69f59b46-v2vgv 1/1 Running 11s
53-
calculator-frontend-6b5d85558c-4mh2s 1/1 Terminating 1h
54-
```
55-
4. The old configuration is `-6b5d85558c-`. Each pod of the old configuration is terminated after a pod of the new configuration `-d69f59b46-` is running and ready `1/1`.
56-
5. You can change the configuration back to `v1` and apply the changes.
57-
6. With `kubectl rollout status deployment calculator-frontend` will see this output:
24+
3. With `kubectl rollout status deployment calculator-frontend` will see this output:
5825
```
5926
Waiting for deployment "calculator-frontend" rollout to finish: 1 out of 3 new replicas have been updated...
6027
Waiting for deployment "calculator-frontend" rollout to finish: 1 out of 3 new replicas have been updated...
@@ -66,25 +33,4 @@ It provides some new features we will look into later.
6633
Waiting for deployment "calculator-frontend" rollout to finish: 1 old replicas are pending termination...
6734
deployment "calculator-frontend" successfully rolled out
6835
```
69-
7. Now, one last rolling update. Change the frontend deployment again to `v2` and apply the changes.
70-
8. Continuously refresh the page after applying the changes.
71-
9. The page will be served with different layouts, this is because sometimes a pod of the old configuration
72-
and sometimes a pod of the new configuration answers your request.
73-
10. After some time only the new layout should be returned.
74-
75-
## We did it! 🎉
76-
77-
You are now able to do the following things using Kubernetes:
78-
79-
- Deploy an application
80-
- Inspect your application when something goes wrong
81-
- Configure multiple replicas for fault tolerance
82-
- Create a service for load balancing
83-
- Expose an application to the public internet
84-
- Update applications without any downtime
85-
86-
### Want to learn more?
87-
88-
Have a look at the new version of the frontend. It looks like history does not work correctly. 😉
89-
90-
We need to fix this! Try the [bonus chapters](../03-bonus.md).
36+
4. When the command is completed you should now [see the updated version](http://$GCLOUD_PUBLIC_IP) of the calculator.
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
---
2+
title: Rollback Changes
3+
parent: Add the Frontend
4+
---
5+
6+
# Rollback Changes
7+
8+
Sometimes a deploy has unexpected results. In this case we deployed a developer preview.
9+
This is not what we want in production. So lets rollback our changes.
10+
11+
1. Run `kubectl rollout undo deployment calculator-frontend` to revert the latest changes.
12+
2. Continuously refresh the page after applying the changes.
13+
3. The page will be served with different layouts. This is because sometimes a pod with
14+
`v3` and sometimes a pod with `v1` answers your request.
15+
4. After some time only `v1` of the calculator frontend should be visible.
16+
5. You can verify this by running `kubectl rollout status deployment calculator-frontend`:
17+
```
18+
deployment "calculator-frontend" successfully rolled out
19+
```
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
---
2+
title: Last Steps
3+
parent: Add the Frontend
4+
---
5+
6+
# Last Steps
7+
8+
We are nearing the end, but lets deploy a version that is ready to be served in our cluster. `v2` this should be safe to deploy.
9+
10+
## Deploy a stable version
11+
12+
1. Change the image in the `fronted.yml` to `v2`.
13+
2. Apply the changes and watch for pod changes:
14+
```
15+
kubectl apply -f k8s-files/ && kubectl get pods -w
16+
```
17+
3. You should now see the new pods starting and the old pods shuting down:
18+
```
19+
NAME READY STATUS RESTARTS AGE
20+
calculator-frontend-58968fd9b8-22np7 0/1 ContainerCreating 0 1s
21+
calculator-frontend-65876567ff-68p8s 1/1 Running 0 2m
22+
calculator-frontend-65876567ff-rvpvb 1/1 Running 0 34s
23+
calculator-frontend-65876567ff-wj62x 1/1 Running 0 46s
24+
calculator-frontend-58968fd9b8-22np7 0/1 Running 0 4s
25+
calculator-frontend-58968fd9b8-22np7 1/1 Running 0 6s
26+
calculator-frontend-65876567ff-rvpvb 1/1 Terminating 0 39s
27+
calculator-frontend-58968fd9b8-sfmhv 0/1 Pending 0 0s
28+
calculator-frontend-58968fd9b8-sfmhv 0/1 Pending 0 0s
29+
calculator-frontend-58968fd9b8-sfmhv 0/1 ContainerCreating 0 0s
30+
calculator-frontend-65876567ff-rvpvb 0/1 Terminating 0 40s
31+
calculator-frontend-58968fd9b8-sfmhv 0/1 Running 0 5s
32+
calculator-frontend-65876567ff-rvpvb 0/1 Terminating 0 44s
33+
calculator-frontend-65876567ff-rvpvb 0/1 Terminating 0 44s
34+
calculator-frontend-58968fd9b8-sfmhv 1/1 Running 0 9s
35+
calculator-frontend-65876567ff-wj62x 1/1 Terminating 0 1m
36+
calculator-frontend-58968fd9b8-w48gr 0/1 Pending 0 0s
37+
calculator-frontend-58968fd9b8-w48gr 0/1 Pending 0 0s
38+
calculator-frontend-58968fd9b8-w48gr 0/1 ContainerCreating 0 0s
39+
calculator-frontend-65876567ff-wj62x 0/1 Terminating 0 1m
40+
calculator-frontend-58968fd9b8-w48gr 0/1 Running 0 5s
41+
calculator-frontend-65876567ff-wj62x 0/1 Terminating 0 1m
42+
calculator-frontend-65876567ff-wj62x 0/1 Terminating 0 1m
43+
calculator-frontend-58968fd9b8-w48gr 1/1 Running 0 8s
44+
calculator-frontend-65876567ff-68p8s 1/1 Terminating 0 2m
45+
calculator-frontend-65876567ff-68p8s 0/1 Terminating 0 2m
46+
calculator-frontend-65876567ff-68p8s 0/1 Terminating 0 3m
47+
calculator-frontend-65876567ff-68p8s 0/1 Terminating 0 3m
48+
```
49+
4. The app should now be served in `v2`.
50+
51+
## We did it! 🎉
52+
53+
You are now able to do the following things using Kubernetes:
54+
55+
- Deploy an application
56+
- Inspect your application when something goes wrong
57+
- Configure multiple replicas for fault tolerance
58+
- Create a service for load balancing
59+
- Expose an application to the public internet
60+
- Update applications without any downtime
61+
62+
### Want to learn more?
63+
64+
Have a look at the new version of the frontend. It looks like history does not work correctly. 😉
65+
66+
We need to fix this! Try the [bonus chapters](../03-bonus.md).

k8s-examples/service.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ apiVersion: v1
33
metadata:
44
name: nginx-proxy
55
spec:
6-
type: ClusterIP
76
ports:
87
- port: 80
98
targetPort: 80
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import React from 'react';
2+
3+
export const BetaOverlay: React.FunctionComponent<{}> = () => (
4+
<div
5+
style={{
6+
position: 'absolute',
7+
left: '50%',
8+
top: '85px',
9+
marginLeft: '50px',
10+
transform: 'rotate(40deg)',
11+
backgroundColor: '#fff',
12+
fontSize: '40px',
13+
fontWeight: 'bold',
14+
color: '#f00',
15+
zIndex: 100
16+
}}
17+
>
18+
developer preview
19+
</div>
20+
);

0 commit comments

Comments
 (0)