Skip to content

Commit

Permalink
Assign tags
Browse files Browse the repository at this point in the history
  • Loading branch information
bmuschko committed Apr 20, 2024
1 parent 6d02494 commit a829c1b
Show file tree
Hide file tree
Showing 12 changed files with 21 additions and 21 deletions.
2 changes: 1 addition & 1 deletion exercises/07-init-container/app/web/build-image.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
To build the Docker image simply run the `build` command and provide the tag `bmuschko/nodejs-read-config:1.0.0`.

```
docker build -t bmuschko/nodejs-read-config:1.0.0 .
$ docker build -t bmuschko/nodejs-read-config:1.0.0 .
```
2 changes: 1 addition & 1 deletion exercises/07-init-container/instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Kubernetes runs an init container before the main container. In this lab, the in
> [!NOTE]
> If you do not already have a cluster, you can create one by using minikube or you can use the O'Reilly interactive lab ["Adding an Init Container"](https://learning.oreilly.com/scenarios/adding-an-init/9781098163921/).
1. Create a new Pod in a YAML file named `business-app.yaml`. The Pod should define two containers, one init container and one main application container. Name the init container `configurer` and the main container `web`. The init container uses the image `busybox`, the main container uses the image `bmuschko/nodejs-read-config:1.0.0`. Expose the main container on port 8080.
1. Create a new Pod in a YAML file named `business-app.yaml`. The Pod should define two containers, one init container and one main application container. Name the init container `configurer` and the main container `web`. The init container uses the image `busybox:1.36.1`, the main container uses the image `bmuschko/nodejs-read-config:1.0.0`. Expose the main container on port 8080.
2. Edit the YAML file by adding a new volume of type `emptyDir` that is mounted at `/usr/shared/app` for both containers.
3. Edit the YAML file by providing the command for the init container. The init container should run a `wget` command for downloading the file `https://raw.githubusercontent.com/bmuschko/ckad-crash-course/master/exercises/07-init-container/app/config/config.json` into the directory `/usr/shared/app`.
4. Start the Pod and ensure that it is up and running.
Expand Down
6 changes: 3 additions & 3 deletions exercises/07-init-container/solution/solution.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ metadata:
spec:
initContainers:
- name: configurer
image: busybox
image: busybox:1.36.1
containers:
- image: bmuschko/nodejs-read-config:1.0.0
name: web
Expand All @@ -62,7 +62,7 @@ metadata:
spec:
initContainers:
- name: configurer
image: busybox
image: busybox:1.36.1
volumeMounts:
- name: configdir
mountPath: "/usr/shared/app"
Expand Down Expand Up @@ -94,7 +94,7 @@ metadata:
spec:
initContainers:
- name: configurer
image: busybox
image: busybox:1.36.1
command:
- wget
- "-O"
Expand Down
2 changes: 1 addition & 1 deletion exercises/08-adapter-pattern/instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ The adapter pattern helps with providing a simplified, homogenized view of an ap
> [!NOTE]
> If you do not already have a cluster, you can create one by using minikube or you can use the O'Reilly interactive lab ["Creating a Sidecar Container"](https://learning.oreilly.com/scenarios/creating-a-sidecar/9781098163938/).
1. Create a new Pod in a YAML file named `adapter.yaml`. The Pod declares two containers. The container `app` uses the image `busybox` and runs the command `while true; do echo "$(date) | $(du -sh ~)" >> /var/logs/diskspace.txt; sleep 5; done;`. The adapter container `transformer` uses the image `busybox` and runs the command `sleep 20; while true; do while read LINE; do echo "$LINE" | cut -f2 -d"|" >> $(date +%Y-%m-%d-%H-%M-%S)-transformed.txt; done < /var/logs/diskspace.txt; sleep 20; done;` to strip the log output off the date for later consumption by a monitoring tool. Be aware that the logic does not handle corner cases (e.g. automatically deleting old entries) and would look different in production systems.
1. Create a new Pod in a YAML file named `adapter.yaml`. The Pod declares two containers. The container `app` uses the image `busybox:1.36.1` and runs the command `while true; do echo "$(date) | $(du -sh ~)" >> /var/logs/diskspace.txt; sleep 5; done;`. The adapter container `transformer` uses the image `busybox:1.36.1` and runs the command `sleep 20; while true; do while read LINE; do echo "$LINE" | cut -f2 -d"|" >> $(date +%Y-%m-%d-%H-%M-%S)-transformed.txt; done < /var/logs/diskspace.txt; sleep 20; done;` to strip the log output off the date for later consumption by a monitoring tool. Be aware that the logic does not handle corner cases (e.g. automatically deleting old entries) and would look different in production systems.
2. Before creating the Pod, define an `emptyDir` volume. Mount the volume in both containers with the path `/var/logs`.
3. Create the Pod, log into the container `transformer`. The current directory should continuously write a new file every 20 seconds.
6 changes: 3 additions & 3 deletions exercises/08-adapter-pattern/solution/solution.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
You can create the initial Pod setup with the following command.

```
$ kubectl run adapter --image=busybox -o yaml --dry-run=client --restart=Never -- /bin/sh -c 'while true; do echo "$(date) | $(du -sh ~)" >> /var/logs/diskspace.txt; sleep 5; done;' > adapter.yaml
$ kubectl run adapter --image=busybox:1.36.1 -o yaml --dry-run=client --restart=Never -- /bin/sh -c 'while true; do echo "$(date) | $(du -sh ~)" >> /var/logs/diskspace.txt; sleep 5; done;' > adapter.yaml
```
The final Pod YAML file should look something like this:

Expand All @@ -22,13 +22,13 @@ spec:
- /bin/sh
- -c
- 'while true; do echo "$(date) | $(du -sh ~)" >> /var/logs/diskspace.txt; sleep 5; done;'
image: busybox
image: busybox:1.36.1
name: app
volumeMounts:
- name: config-volume
mountPath: /var/logs
resources: {}
- image: busybox
- image: busybox:1.36.1
name: transformer
args:
- /bin/sh
Expand Down
2 changes: 1 addition & 1 deletion exercises/10-labels-annotations-cli/instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ In this exercise, you will exercise assigning labels and annotations to a set of
> [!NOTE]
> If you do not already have a cluster, you can create one by using minikube or you can use the O'Reilly interactive labs ["Assigning Labels to Pods Imperatively"](https://learning.oreilly.com/scenarios/assigning-labels-to/9781098163952/) and ["Assigning Annotations to Pods Imperatively"](https://learning.oreilly.com/scenarios/assigning-annotations-to/9781098163976/).
1. Create three different Pods with the names `frontend`, `backend` and `database` that use the image `nginx`. For convenience, you can use the file [`pods.yaml`](./pods.yaml) to create the Pods.
1. Create three different Pods with the names `frontend`, `backend` and `database` that use the image `nginx:1.25.5-alpine`. For convenience, you can use the file [`pods.yaml`](./pods.yaml) to create the Pods.
2. Declare labels for those Pods, as follows:

- `frontend`: `env=prod`, `team=shiny`
Expand Down
6 changes: 3 additions & 3 deletions exercises/10-labels-annotations-cli/pods.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ metadata:
name: frontend
spec:
containers:
- image: nginx
- image: nginx:1.25.5-alpine
name: nginx
restartPolicy: Never
---
Expand All @@ -14,7 +14,7 @@ metadata:
name: backend
spec:
containers:
- image: nginx
- image: nginx:1.25.5-alpine
name: nginx
restartPolicy: Never
---
Expand All @@ -24,6 +24,6 @@ metadata:
name: database
spec:
containers:
- image: nginx
- image: nginx:1.25.5-alpine
name: nginx
restartPolicy: Never
6 changes: 3 additions & 3 deletions exercises/10-labels-annotations-cli/solution/solution.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
You can assign labels upon Pod creation with the `--labels` option.

```
$ kubectl run frontend --image=nginx --restart=Never --labels=env=prod,team=shiny
$ kubectl run frontend --image=nginx:1.25.5-alpine --restart=Never --labels=env=prod,team=shiny
pod/frontend created
$ kubectl run backend --image=nginx --restart=Never --labels=env=prod,team=legacy,app=v1.2.4
$ kubectl run backend --image=nginx:1.25.5-alpine --restart=Never --labels=env=prod,team=legacy,app=v1.2.4
pod/backend created
$ kubectl run database --image=nginx --restart=Never --labels=env=prod,team=storage
$ kubectl run database --image=nginx:1.25.5-alpine --restart=Never --labels=env=prod,team=storage
pod/database created
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@
> [!NOTE]
> If you do not already have a cluster, you can create one by using minikube or you can use the O'Reilly interactive lab ["Creating a Horizontal Pod Autoscaler for a Deployment"](https://learning.oreilly.com/scenarios/creating-a-horizontal/9781098164034/).
1. Create a Deployment named `nginx` with 1 replica. The Pod template of the Deployment should use container image `nginx:1.23.4`, set the CPU resource request to 0.5, and the memory resource request/limit to 500Mi.
1. Create a Deployment named `nginx:1.23.4` with 1 replica. The Pod template of the Deployment should use container image `nginx:1.23.4`, set the CPU resource request to 0.5, and the memory resource request/limit to 500Mi.
2. Create a HorizontalPodAutoscaler for the Deployment named `nginx-hpa` that scales to minium of 3 and a maximum of 8 replicas. Scaling should happen based on an average CPU utilization of 75%, and an average memory utilization of 60%.
3. Inspect the HorizontalPodAutoscaler object and identify the currently-utilized resources. How many replicas do you expect to exist?
2 changes: 1 addition & 1 deletion exercises/28-service/solution/solution.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ pod/myapp-7d6cd46d65-jrc2q 1/1 Running 0 106s
Determine the cluster IP and the port for the Service. In this case, it's `10.109.149.59:80`. Alternatively, you can use the DNS name `myapp`. Use the information with the `wget` command.

```
$ kubectl run tmp --image=busybox --restart=Never -it --rm -- wget -O- 10.109.149.59:80
$ kubectl run tmp --image=busybox:1.36.1 --restart=Never -it --rm -- wget -O- 10.109.149.59:80
Connecting to 10.109.149.59:80 (10.109.149.59:80)
writing to stdout
<!DOCTYPE html>
Expand Down
2 changes: 1 addition & 1 deletion exercises/29-troubleshooting-service/instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ Kate is an developer in charge of implementing a web-based application stack. Sh
1. Create the objects from the YAML manifest [setup.yaml](./setup.yaml).
2. Inspect the objects in the namespace `y72`.
3. Create a temporary Pod using the image `busybox` in the namespace `y72`. The container command should make a `wget` call to the Service `web-app`. The `wget` will not be able to establish a successful connection to the Service.
3. Create a temporary Pod using the image `busybox:1.36.1` in the namespace `y72`. The container command should make a `wget` call to the Service `web-app`. The `wget` will not be able to establish a successful connection to the Service.
4. Identify the root cause for the connection issue and fix it. Verify the correct behavior by repeating the previous step. The `wget` call should return a sucessful response.
4 changes: 2 additions & 2 deletions exercises/29-troubleshooting-service/solution/solution.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ replicaset.apps/web-app-5f77f59c78 2 2 2 10m
The Service named `web-app` is of type `ClusterIP`. You can only access the Service from within the cluster. Trying to connect to the Service by its DNS name from a temporary Pod in the same namespace won't be allowed.

```
$ kubectl run tmp --image=busybox --restart=Never -it --rm -n y72 -- wget web-app
$ kubectl run tmp --image=busybox:1.36.1 --restart=Never -it --rm -n y72 -- wget web-app
Connecting to web-app (10.106.215.153:80)
wget: can't connect to remote host (10.106.215.153): Connection refused
pod "tmp" deleted
Expand Down Expand Up @@ -84,7 +84,7 @@ service/web-app edited
After changing the Service configuration, you will find that you can open a connection to the Pod running the application.

```
$ kubectl run tmp --image=busybox --restart=Never -it --rm -n y72 -- wget web-app
$ kubectl run tmp --image=busybox:1.36.1 --restart=Never -it --rm -n y72 -- wget web-app
Connecting to web-app (10.106.215.153:80)
saving to 'index.html'
index.html 100% |********************************| 12 0:00:00 ETA
Expand Down

0 comments on commit a829c1b

Please sign in to comment.