Skip to content

Commit

Permalink
Fix commands
Browse files Browse the repository at this point in the history
  • Loading branch information
bmuschko committed Dec 8, 2020
1 parent c22fc01 commit 773b051
Show file tree
Hide file tree
Showing 11 changed files with 30 additions and 21 deletions.
2 changes: 1 addition & 1 deletion exercises/01-creating-inspecting-pod/solution/solution.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ $ kubectl create namespace ckad-prep
Next, create the Pod in the new namespace.

```shell
$ kubectl run mypod --image=nginx:2.3.5 --port=80 --namespace=ckad-prep
$ kubectl run mypod --image=nginx:2.3.5 --restart=Never --port=80 --namespace=ckad-prep
pod/mypod created
```

Expand Down
2 changes: 1 addition & 1 deletion exercises/02-creating-using-configmap/solution/solution.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Create the ConfigMap and point to the text file upon creation.
```shell
$ kubectl create configmap db-config --from-env-file=config.txt
configmap/db-config created
$ kubectl run backend --image=nginx -o yaml --dry-run=client > pod.yaml
$ kubectl run backend --image=nginx -o yaml --dry-run=client --restart=Never > pod.yaml
```

The final YAML file should look similar to the following code snippet.
Expand Down
2 changes: 1 addition & 1 deletion exercises/03-creating-using-secret/solution/solution.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ secret/db-credentials created
$ kubectl get secrets
NAME TYPE DATA AGE
db-credentials Opaque 1 26s
$ kubectl run backend --image=nginx -o yaml --dry-run=client > pod.yaml
$ kubectl run backend --image=nginx -o yaml --dry-run=client --restart=Never > pod.yaml
```

Edit the YAML file and create an environment that reads the relevant key from the secret.
Expand Down
2 changes: 1 addition & 1 deletion exercises/04-creating-securitycontext/solution/solution.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Start by creating the Pod definition as YAML file.

```shell
$ kubectl run secured --image=nginx -o yaml --dry-run=client > secured.yaml
$ kubectl run secured --image=nginx -o yaml --dry-run=client --restart=Never > secured.yaml
```

Edit the YAML file, add a volume and a volume mount. Add a security context with the relevant group ID.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ requests.cpu 0 2
requests.memory 0 500m
```

Next, create the YAML file named `pod.yaml` with more requested memory than available in the quota. You can start by running the command `kubectl run mypod --image=nginx -o yaml --dry-run=client > pod.yaml` and then edit the produced YAML file. Remember to _replace_ the `resources` attribute that has been created automatically.
Next, create the YAML file named `pod.yaml` with more requested memory than available in the quota. You can start by running the command `kubectl run mypod --image=nginx -o yaml --dry-run=client --restart=Never > pod.yaml` and then edit the produced YAML file. Remember to _replace_ the `resources` attribute that has been created automatically.

```yaml
apiVersion: v1
Expand Down
2 changes: 1 addition & 1 deletion exercises/06-using-service-account/solution/solution.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ secrets:
Next, you can create a new Pod and assign the service account to it.

```shell
$ kubectl run backend --image=nginx --serviceaccount=backend-team
$ kubectl run backend --image=nginx --restart=Never --serviceaccount=backend-team
```

You can print out the token from the volume source at `/var/run/secrets/kubernetes.io/serviceaccount`.
Expand Down
2 changes: 1 addition & 1 deletion exercises/07-creating-init-container/solution/solution.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Start by generating the basic skeleton of the Pod.

```shell
$ kubectl run business-app --image=bmuschko/nodejs-read-config:1.0.0 --port=8080 -o yaml --dry-run=client > business-app.yaml
$ kubectl run business-app --image=bmuschko/nodejs-read-config:1.0.0 --port=8080 -o yaml --dry-run=client --restart=Never > business-app.yaml
```

You should end up with the following configuration:
Expand Down
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.

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

Expand Down
2 changes: 1 addition & 1 deletion exercises/09-defining-pod-probes/solution/solution.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Create the intial YAML with the following command.

```shell
$ kubectl run hello --image=bmuschko/nodejs-hello-world:1.0.0 --port=3000 -o yaml --dry-run=client > pod.yaml
$ kubectl run hello --image=bmuschko/nodejs-hello-world:1.0.0 --port=3000 -o yaml --dry-run=client --restart=Never > pod.yaml
```

Edit the YAML file and add the probes.
Expand Down
6 changes: 3 additions & 3 deletions exercises/11-using-labels-annotations/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.

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

Expand Down
27 changes: 18 additions & 9 deletions exercises/14-exposing-service/solution/solution.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@ NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
myapp ClusterIP 10.108.88.208 <none> 80/TCP 15s
```

Create a deployment and a Pod using the Deployment using the `run` command.
Create a Deployment and a Pod using the Deployment using the `run` command.

```shell
$ kubectl run myapp --image=nginx --port=80 --expose
$ kubectl create deployment myapp --image=nginx --port=80
deployment.apps/myapp created
$ kubectl get deployments,pods
NAME DESIRED CURRENT UP-TO-DATE AVAILABLE AGE
deployment.extensions/myapp 1 1 1 1 59s
Expand All @@ -39,8 +40,8 @@ pod/myapp-7bc568bfdd-l5nmz 1/1 Running 0 69s
Determine the cluster IP and use it for the `wget` command.

```shell
$ kubectl run tmp --image=busybox --restart=Never -it --rm -- wget -O- 10.108.88.208:80
Connecting to 10.108.88.208:80 (10.108.88.208:80)
$ kubectl run tmp --image=busybox --restart=Never -it --rm -- wget -O- 10.109.232.76:80
Connecting to 10.109.232.76:80 (10.109.232.76:80)
<!DOCTYPE html>
<html>
<head>
Expand Down Expand Up @@ -81,16 +82,24 @@ spec:

$ kubectl get services
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
myapp NodePort 10.108.88.208 <none> 80:30441/TCP 3m
myapp NodePort 10.109.232.76 <none> 80:30342/TCP 3m
```

Run a `wget` or `curl` command against the service using port `30441`. On Docker for Windows/Mac you may have to use localhost or 127.0.0.1 (see [issue](https://github.com/docker/for-win/issues/1950)).
Get the internal IP address of the node. That's 192.168.64.2 in this case.

```shell
$ wget -O- localhost:30441
--2019-05-10 16:32:35-- http://localhost:30441/
$ kubectl get nodes -o wide
NAME STATUS ROLES AGE VERSION INTERNAL-IP EXTERNAL-IP OS-IMAGE KERNEL-VERSION CONTAINER-RUNTIME
minikube Ready master 175d v1.19.2 192.168.64.2 <none> Buildroot 2019.02.10 4.19.107 docker://19.3.8
```

Run a `wget` or `curl` command against the service using port `30342`.

```shell
$ wget -O- 192.168.64.2:30342
--2019-05-10 16:32:35-- http://192.168.64.2:30342/
Resolving localhost (localhost)... ::1, 127.0.0.1
Connecting to localhost (localhost)|::1|:30441... connected.
Connecting to localhost (localhost)|::1|:30342... connected.
HTTP request sent, awaiting response... 200 OK
Length: 612 [text/html]
Saving to: ‘STDOUT’
Expand Down

0 comments on commit 773b051

Please sign in to comment.