-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding sources for the technical peer review track (#268)
- Loading branch information
Showing
9 changed files
with
263 additions
and
0 deletions.
There are no files selected for viewing
34 changes: 34 additions & 0 deletions
34
instruqt/technical-peer-review/01-getting-started/assignment.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
--- | ||
slug: getting-started | ||
id: vuw8ykv0xxbc | ||
type: challenge | ||
title: Getting Started | ||
teaser: Why is the pod not running | ||
notes: | ||
- type: text | ||
contents: |- | ||
This track uses a single node Kubernetes cluster on a sandbox virtual machine. | ||
Please wait while we boot the VM for you and start Kubernetes. | ||
## Objectives | ||
In this track, this is what you'll learn: | ||
- Find the problem | ||
- Fix the problem | ||
tabs: | ||
- title: Shell | ||
type: terminal | ||
hostname: kubernetes-vm | ||
difficulty: basic | ||
timelimit: 1800 | ||
--- | ||
|
||
👋 Introduction | ||
=============== | ||
|
||
Use the terminal and `kubectl` to understand why the pod is not running. | ||
|
||
🏁 Solution | ||
=========== | ||
|
||
Use the terminal and `kubectl` to redeploy the pod and make sure it is in a running state. |
31 changes: 31 additions & 0 deletions
31
instruqt/technical-peer-review/01-getting-started/setup-kubernetes-vm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#!/bin/bash | ||
|
||
# Create the nginx deployment | ||
cat <<EOF | kubectl apply -f - | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
labels: | ||
app: nginx | ||
name: nginx | ||
spec: | ||
replicas: 1 | ||
selector: | ||
matchLabels: | ||
app: nginx | ||
template: | ||
metadata: | ||
labels: | ||
app: nginx | ||
spec: | ||
initContainers: | ||
- image: busybox | ||
name: coffee | ||
command: | ||
- sh | ||
- -c | ||
- sleeeep 10 | ||
containers: | ||
- image: nginx | ||
name: nginx | ||
EOF |
42 changes: 42 additions & 0 deletions
42
instruqt/technical-peer-review/02-exposing-nginx/assignment.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
--- | ||
slug: exposing-nginx | ||
id: mrlgykq8y8ed | ||
type: challenge | ||
title: Expose the NGINX service | ||
teaser: Why can't I access nginx | ||
notes: | ||
- type: text | ||
contents: You've just deployed NGINX. Now let's try browsing it | ||
tabs: | ||
- title: Shell | ||
type: terminal | ||
hostname: kubernetes-vm | ||
- title: NodePort | ||
type: service | ||
hostname: kubernetes-vm | ||
path: / | ||
port: 30001 | ||
difficulty: basic | ||
timelimit: 1800 | ||
--- | ||
|
||
👋 Introduction | ||
=============== | ||
|
||
Use the terminal, the browser tab and `kubectl` to understand why you can't access nginx. | ||
|
||
🏁 Solution | ||
=========== | ||
|
||
Use the terminal and `kubectl` to fix the issue. | ||
|
||
<details> | ||
<summary>Hint</summary> | ||
|
||
``` | ||
k create svc nodeport my-nginx --node-port=30001 --tcp=80 --dry-run=client -o yaml > nginxsvc.yaml | ||
``` | ||
|
||
And change the `selecter` to use `app: nginx`. | ||
|
||
</details> |
16 changes: 16 additions & 0 deletions
16
instruqt/technical-peer-review/02-exposing-nginx/setup-kubernetes-vm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#!/bin/bash | ||
cat <<EOF | kubectl apply -f - | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
labels: | ||
app: nginx | ||
name: nginx | ||
spec: | ||
ports: | ||
- port: 80 | ||
protocol: TCP | ||
selector: | ||
app: nginx | ||
type: ClusterIP | ||
EOF |
57 changes: 57 additions & 0 deletions
57
instruqt/technical-peer-review/03-awkward-scaling/assignment.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
--- | ||
slug: awkward-scaling | ||
id: rkvhyttuiahw | ||
type: challenge | ||
title: Awkward scaling | ||
teaser: Someone did some weird way of scaling | ||
notes: | ||
- type: text | ||
contents: Something is wrong with the pods. Try to understand why, and find one | ||
or multiple ways of fixing it. | ||
tabs: | ||
- title: Shell | ||
type: terminal | ||
hostname: kubernetes-vm | ||
- title: NodePort | ||
type: service | ||
hostname: kubernetes-vm | ||
path: / | ||
port: 30001 | ||
difficulty: basic | ||
timelimit: 1800 | ||
--- | ||
|
||
👋 Introduction | ||
=============== | ||
|
||
Use the terminal and `kubectl` to understand why you sometimes can't access nginx. | ||
Use the `check-nginx.sh` script to verify if nginx is running. | ||
|
||
<details> | ||
<summary>The script</summary> | ||
|
||
``` | ||
#!/bin/bash | ||
echo "Checking nginx" | ||
for i in {1..10} | ||
do | ||
curl -s -o /dev/null -w "Response: %{http_code} %{errormsg}" localhost:30001 | ||
echo "" | ||
sleep 2 | ||
done | ||
``` | ||
</details> | ||
|
||
🏁 Solution | ||
=========== | ||
|
||
Use the terminal and `kubectl` to fix the issue. | ||
|
||
<details> | ||
<summary>Hint</summary> | ||
|
||
Someone created a second deployment instead of changing the number of replicas. Use `k scale`? Or edit the deployment? | ||
Also this is a great opportunity to talk about `readinessProbes` and `livenessProbes`. | ||
|
||
</details> |
49 changes: 49 additions & 0 deletions
49
instruqt/technical-peer-review/03-awkward-scaling/setup-kubernetes-vm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
#!/bin/bash | ||
|
||
# Create the nginx deployment | ||
cat <<EOF | kubectl apply -f - | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
labels: | ||
app: nginx | ||
name: nginx-extra | ||
spec: | ||
replicas: 2 | ||
selector: | ||
matchLabels: | ||
app: nginx | ||
template: | ||
metadata: | ||
labels: | ||
app: nginx | ||
spec: | ||
initContainers: | ||
- image: busybox | ||
name: coffee | ||
command: | ||
- sh | ||
- -c | ||
- sleep 10 | ||
containers: | ||
- image: busybox | ||
name: milk | ||
command: | ||
- sh | ||
- -c | ||
- sleep 1800 | ||
EOF | ||
|
||
# Create the check-nginx.sh script | ||
cat <<EOF > check-nginx.sh | ||
#!/bin/bash | ||
echo "Checking nginx" | ||
for i in {1..10} | ||
do | ||
curl -s -o /dev/null -w "Response: %{http_code} %{errormsg}" localhost:30001 | ||
echo "" | ||
sleep 2 | ||
done | ||
EOF | ||
chmod +x check-nginx.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
version: "3" | ||
virtualmachines: | ||
- name: kubernetes-vm | ||
image: instruqt/k3s-v1-25-0 | ||
shell: /bin/bash | ||
machine_type: n1-standard-2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
slug: technical-peer-review | ||
id: nrjmvv9bmgky | ||
title: Technical Peer Review | ||
teaser: Solve some k8s problems | ||
description: Solve some k8s problems with the help from Replicated engineers. | ||
icon: https://cdn.instruqt.com/assets/templates/kubernetes.png | ||
tags: [] | ||
owner: replicated | ||
developers: | ||
- [email protected] | ||
checksum: "15144180777240178116" |
17 changes: 17 additions & 0 deletions
17
instruqt/technical-peer-review/track_scripts/setup-kubernetes-vm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#!/bin/bash | ||
|
||
# Wait for the Instruqt host bootstrap to finish | ||
until [ -f /opt/instruqt/bootstrap/host-bootstrap-completed ] | ||
do | ||
sleep 1 | ||
done | ||
|
||
# Wait for the Kubernetes API server to become available | ||
while ! curl --silent --fail --output /dev/null http://localhost:8001/api | ||
do | ||
sleep 1 | ||
done | ||
|
||
# Enable bash completion for kubectl | ||
echo "source /usr/share/bash-completion/bash_completion" >> /root/.bashrc | ||
echo "complete -F __start_kubectl k" >> /root/.bashrc |