From 773b0515c889d37dce5224ae8ea6c6a79d022c84 Mon Sep 17 00:00:00 2001 From: Benjamin Muschko Date: Tue, 8 Dec 2020 16:40:48 -0700 Subject: [PATCH] Fix commands --- .../solution/solution.md | 2 +- .../solution/solution.md | 2 +- .../solution/solution.md | 2 +- .../solution/solution.md | 2 +- .../solution/solution.md | 2 +- .../solution/solution.md | 2 +- .../solution/solution.md | 2 +- .../solution/solution.md | 2 +- .../solution/solution.md | 2 +- .../solution/solution.md | 6 ++--- .../14-exposing-service/solution/solution.md | 27 ++++++++++++------- 11 files changed, 30 insertions(+), 21 deletions(-) diff --git a/exercises/01-creating-inspecting-pod/solution/solution.md b/exercises/01-creating-inspecting-pod/solution/solution.md index 43481075..53bfd469 100644 --- a/exercises/01-creating-inspecting-pod/solution/solution.md +++ b/exercises/01-creating-inspecting-pod/solution/solution.md @@ -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 ``` diff --git a/exercises/02-creating-using-configmap/solution/solution.md b/exercises/02-creating-using-configmap/solution/solution.md index 47d9943c..00793b1f 100644 --- a/exercises/02-creating-using-configmap/solution/solution.md +++ b/exercises/02-creating-using-configmap/solution/solution.md @@ -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. diff --git a/exercises/03-creating-using-secret/solution/solution.md b/exercises/03-creating-using-secret/solution/solution.md index f8b8ee38..e2847349 100644 --- a/exercises/03-creating-using-secret/solution/solution.md +++ b/exercises/03-creating-using-secret/solution/solution.md @@ -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. diff --git a/exercises/04-creating-securitycontext/solution/solution.md b/exercises/04-creating-securitycontext/solution/solution.md index d3c494b3..0c53af0c 100644 --- a/exercises/04-creating-securitycontext/solution/solution.md +++ b/exercises/04-creating-securitycontext/solution/solution.md @@ -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. diff --git a/exercises/05-defining-resource-requirements/solution/solution.md b/exercises/05-defining-resource-requirements/solution/solution.md index 3c5311cb..95131422 100644 --- a/exercises/05-defining-resource-requirements/solution/solution.md +++ b/exercises/05-defining-resource-requirements/solution/solution.md @@ -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 diff --git a/exercises/06-using-service-account/solution/solution.md b/exercises/06-using-service-account/solution/solution.md index 81fcd932..e5a47e79 100644 --- a/exercises/06-using-service-account/solution/solution.md +++ b/exercises/06-using-service-account/solution/solution.md @@ -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`. diff --git a/exercises/07-creating-init-container/solution/solution.md b/exercises/07-creating-init-container/solution/solution.md index 417bd1a1..b777d28f 100644 --- a/exercises/07-creating-init-container/solution/solution.md +++ b/exercises/07-creating-init-container/solution/solution.md @@ -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: diff --git a/exercises/08-implementing-adapter-pattern/solution/solution.md b/exercises/08-implementing-adapter-pattern/solution/solution.md index 7d98c427..e679edbb 100644 --- a/exercises/08-implementing-adapter-pattern/solution/solution.md +++ b/exercises/08-implementing-adapter-pattern/solution/solution.md @@ -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: diff --git a/exercises/09-defining-pod-probes/solution/solution.md b/exercises/09-defining-pod-probes/solution/solution.md index 21845860..4db772e7 100644 --- a/exercises/09-defining-pod-probes/solution/solution.md +++ b/exercises/09-defining-pod-probes/solution/solution.md @@ -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. diff --git a/exercises/11-using-labels-annotations/solution/solution.md b/exercises/11-using-labels-annotations/solution/solution.md index ada91400..59aae8d6 100644 --- a/exercises/11-using-labels-annotations/solution/solution.md +++ b/exercises/11-using-labels-annotations/solution/solution.md @@ -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 ``` diff --git a/exercises/14-exposing-service/solution/solution.md b/exercises/14-exposing-service/solution/solution.md index 9ca850ba..a5bd1e08 100644 --- a/exercises/14-exposing-service/solution/solution.md +++ b/exercises/14-exposing-service/solution/solution.md @@ -10,10 +10,11 @@ NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE myapp ClusterIP 10.108.88.208 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 @@ -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) @@ -81,16 +82,24 @@ spec: $ kubectl get services NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE -myapp NodePort 10.108.88.208 80:30441/TCP 3m +myapp NodePort 10.109.232.76 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 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’