From 3c5b855dc46fcb856670af213a67f885a3f28517 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my-Christophe=20Schermesser?= Date: Tue, 21 May 2019 11:10:59 +0200 Subject: [PATCH] fix: use sh in md (#28) --- 05-pods/README.md | 14 +++++++------- 06-label-annotation/README.md | 6 +++--- 07-deployment/README.md | 18 +++++++++--------- 08-service/README.md | 20 ++++++++++---------- 09-cronjob/README.md | 6 +++--- 10-secrets/README.md | 4 ++-- 11-probes/README.md | 4 ++-- 12-resources/README.md | 2 +- 13-affinity-anti-affinity/README.md | 6 +++--- 14-pdb/README.md | 8 ++++---- 15-hpa-vpa/README.md | 2 +- 16-sidecar-containers/README.md | 2 +- 17-volumes/README.md | 16 ++++++++-------- 18-stateful-set/README.md | 8 ++++---- 19-controllers/README.md | 2 +- 20-operators/README.md | 2 +- 21-rbac/README.md | 2 +- 17 files changed, 61 insertions(+), 61 deletions(-) diff --git a/05-pods/README.md b/05-pods/README.md index df59607..3eb70eb 100644 --- a/05-pods/README.md +++ b/05-pods/README.md @@ -43,7 +43,7 @@ Let's have a look a the fields: Let's `apply` this manifest to Kubernetes. This will tell Kubernetes to create the `pod` and run it. -```bash +```sh $ kubectl apply -f 05-pods/01-simple-pod.yml pod "simple-pod" created @@ -55,7 +55,7 @@ We also could have used the `kubectl create -f ...`. But it's better to have a d Now list all the `pods` running in Kubernetes. `get` is the `ls` of Kubernetes. -```bash +```sh $ kubectl get pod NAME READY STATUS RESTARTS AGE @@ -66,7 +66,7 @@ simple-pod 1/1 Running 0 4s Let's have a look at the logs of this `pod`: -```bash +```sh $ kubectl logs simple-pod 2018-10-01T09:21:59 INFO This is simple service in version v0.5.0 listening on port 9876 [at line 142] @@ -78,7 +78,7 @@ $ kubectl logs simple-pod Our first `pod` is now running. Now `describe` it. `describe` is a `get` on steroid, with more information. -```bash +```sh $ kubectl describe pod simple-pod [a lot of stuff] @@ -92,7 +92,7 @@ Look at the information provided. Get the field `IP`, it's the internal ip for t Connect to the cluster, and try to `curl` this ip - `172.17.0.4` in the example. -```bash +```sh $ minikube ssh $ curl 172.17.0.4:9876/info @@ -101,7 +101,7 @@ $ curl 172.17.0.4:9876/info Kubernetes has a useful add-on, a web dashboard. It's included by default in minikube. You can start it with: -```bash +```sh minikube dashboard ``` @@ -112,7 +112,7 @@ minikube dashboard ## Clean up -```bash +```sh kubectl delete pod --all ``` diff --git a/06-label-annotation/README.md b/06-label-annotation/README.md index 40d3959..86f4906 100644 --- a/06-label-annotation/README.md +++ b/06-label-annotation/README.md @@ -28,7 +28,7 @@ Apply the pod `06-label-annotation/02-nginx.yml`. It is a simple nginx with 2 la Let's list all the pods that are in the `env=production`: -```bash +```sh $ kubectl get pods -l env=production NAME READY STATUS RESTARTS AGE @@ -38,7 +38,7 @@ simple-pod 1/1 Running 0 13s Let's list all the pods that are in the `env=production,tier=frontend`: -```bash +```sh $ kubectl get pods -l env=production,tier=frontend NAME READY STATUS RESTARTS AGE @@ -53,7 +53,7 @@ Nothing to see here. ## Clean up -```bash +```sh kubectl delete pod --all ``` diff --git a/07-deployment/README.md b/07-deployment/README.md index add63fc..cac958e 100644 --- a/07-deployment/README.md +++ b/07-deployment/README.md @@ -51,7 +51,7 @@ Let's have a look at the manifest: Apply the deployment: -```bash +```sh $ kubectl apply -f 07-deployment/01-simple-deployment.yml deployment.apps/simple-deployment created ``` @@ -60,7 +60,7 @@ deployment.apps/simple-deployment created Let's have a look at what this `deployment` created for us: -```bash +```sh $ kubectl get deployment NAME DESIRED CURRENT UP-TO-DATE AVAILABLE AGE simple-deployment 2 2 2 2 2m @@ -68,7 +68,7 @@ simple-deployment 2 2 2 2 2m Firstly, Kubernetes created a `deployment`. We see a lot of 2s. It is the number of replicas that are available. Let's have a look at the pods we have running: -```bash +```sh $ kubectl get pod NAME READY STATUS RESTARTS AGE @@ -80,7 +80,7 @@ The `deployment` created 2 pods for us, the number we put in `replicas`. We see Did Kubernetes created something else for us? Let's have a look -```bash +```sh $ kubectl get all NAME READY STATUS RESTARTS AGE @@ -108,19 +108,19 @@ We won't go into details of what a [`ReplicaSet`](https://kubernetes.io/docs/con Let's play with our `deployment` now. Update the number of `replicas` in the yaml, to a reasonable number - say `5`. -```bash +```sh kubectl apply -f 07-deployment/01-simple-deployment.yml ``` You can also use `kubectl scale`: -```bash +```sh kubectl scale --replicas=5 -f 07-deployment/01-simple-deployment.yml ``` You can also edit the manifest in place with `kubectl edit`: -```bash +```sh kubectl edit deployment simple-deployment ``` @@ -136,7 +136,7 @@ Change again the number of replicas to `2`, reapply, see what is happening. We know how to scale up/down a deployment, but how can we deploy a new version of the application. To achieve this, we need to tell Kubernetes to update the image we are using in our `deployment`, for this: -```bash +```sh $ kubectl set image deployment/simple-deployment simple-service=mhausenblas/simpleservice:0.5.0 deployment.apps "simple-deployment" image updated ``` @@ -152,7 +152,7 @@ Remember the command `kubectl describe deployment`. ## Clean up -```bash +```sh kubectl delete deployment,rs,pod --all ``` diff --git a/08-service/README.md b/08-service/README.md index 5fe9582..20f5e9b 100644 --- a/08-service/README.md +++ b/08-service/README.md @@ -8,7 +8,7 @@ In this section you will learn how to access your application from outside your If it's not already done install the `minikube` addon `ingress`: -```bash +```sh $ minikube addons enable ingress ✅ ingress was successfully enabled ``` @@ -21,7 +21,7 @@ What we need is a `service`. It'll allow us to access our pods internally or ext First apply the `deployment`: -```bash +```sh $ kubectl apply -f 08-service/01-simple-deployment.yml deployment.apps "simple-deployment" created ``` @@ -30,21 +30,21 @@ Now start another container. We will use it to see what we can access internally Apply the pod: -```bash +```sh $ kubectl apply -f 08-service/02-bash.yml pod "bash" created ``` And connect to it: -```bash +```sh $ kubectl exec -it bash -- /bin/bash root@bash:/# ``` Install `dnsutils` & `curl` in the container, you will need them: -```bash +```sh root@bash:/# apt update && apt install dnsutils curl [...] ``` @@ -85,14 +85,14 @@ is central to Kubernetes. It is with those fields that you will tell Kubernetes Apply the service: -```bash +```sh $ kubectl apply -f 08-service/03-simple-service.yml service "simple-service" created ``` Your service is now accessible internally, try this in your `bash` container: -```bash +```sh root@bash:/# nslookup simple-service Server: 10.96.0.10 Address: 10.96.0.10#53 @@ -147,14 +147,14 @@ Let's have a look at the manifest: Apply the ingress: -```bash +```sh $ kubectl apply -f 08-service/04-ingress.yml ingress.extensions "simple-ingress" created ``` Get the IP of your minikube cluster: -```bash +```sh $ minikube ip 192.168.99.100 ``` @@ -204,7 +204,7 @@ You have seen a lot different `kind` of Kubernetes, let's take a step back and s ## Clean up -```bash +```sh kubectl delete ingress,service,deployment,rs,pod --all ``` diff --git a/09-cronjob/README.md b/09-cronjob/README.md index 9ea65f6..74e48e1 100644 --- a/09-cronjob/README.md +++ b/09-cronjob/README.md @@ -33,7 +33,7 @@ spec: Let's apply it: -```bash +```sh $ kubectl apply -f 09-cronjob/01-simple-cronjob.yml cronjob.batch "simple-cronjob" created ``` @@ -63,7 +63,7 @@ This manifest is fairly close to a `CronJob`. Apply it and see what is happening. Does it restarts? -```bash +```sh $ kubectl apply -f 09-cronjob/02-simple-job.yml job.batch "simple-job" created ``` @@ -77,7 +77,7 @@ If you have a long running background process - like a consumer of a queue - you ## Clean up -```bash +```sh kubectl delete deployment,rs,service,cronjob,pod --all ``` diff --git a/10-secrets/README.md b/10-secrets/README.md index f50eaec..309c4bf 100644 --- a/10-secrets/README.md +++ b/10-secrets/README.md @@ -17,7 +17,7 @@ data: You can apply the file: -```bash +```sh $ kubectl apply -f 10-secrets/01-secrets.yml secret "mysecret" created ``` @@ -78,7 +78,7 @@ Nothing to see here. ## Clean up -```bash +```sh kubectl delete service,deployment,pod,secrets --all ``` diff --git a/11-probes/README.md b/11-probes/README.md index 416f2bc..90de194 100644 --- a/11-probes/README.md +++ b/11-probes/README.md @@ -111,7 +111,7 @@ Run `kubectl get deployments -w` and see what is happening. The pods are "Running" but not ready (the READY column to 0/1). -```bash +```sh kubectl get pods NAME READY STATUS RESTARTS AGE readiness-deployment-5dd7f6ff87-jsm9f 0/1 Running 0 2m17s @@ -134,7 +134,7 @@ Nothing to see here. ## Clean up -```bash +```sh kubectl delete service,deployment,pod --all ``` diff --git a/12-resources/README.md b/12-resources/README.md index c824c05..b21a0ca 100644 --- a/12-resources/README.md +++ b/12-resources/README.md @@ -123,7 +123,7 @@ Review and apply the file [04-ram-limits.yml](./04-ram-limits.yml). Look at the ## Clean up -```bash +```sh kubectl delete service,deployment,pod --all ``` diff --git a/13-affinity-anti-affinity/README.md b/13-affinity-anti-affinity/README.md index 2932acb..2451680 100644 --- a/13-affinity-anti-affinity/README.md +++ b/13-affinity-anti-affinity/README.md @@ -101,13 +101,13 @@ Node affinity is very close to pod affinity. Instead of specifying a `podAffinit Each resource in Kubernetes can have labels, even nodes. You can see them with `kubectl`: -```bash +```sh kubectl get nodes --show-labels ``` You can add labels to a node with: -```bash +```sh kubectl label nodes [nodeName] gpu=yes ``` @@ -145,7 +145,7 @@ Nothing to see here. ## Clean up -```bash +```sh kubectl delete service,deployment,pod --all ``` diff --git a/14-pdb/README.md b/14-pdb/README.md index d8ee2ba..029fc72 100644 --- a/14-pdb/README.md +++ b/14-pdb/README.md @@ -33,7 +33,7 @@ If you want to see the effect of a PDB, you will need a multi-node Kubernetes. A Use the [configuration file](./kind.yml) provided to create your cluster: -```bash +```sh kind create cluster --config kind.yml ``` @@ -41,7 +41,7 @@ Review and apply the manifests in [01-pdb.yml](./01-pdb.yml). Why did we specify In a terminal run the command: -```bash +```sh kubectl get pods -owide -w ``` @@ -49,7 +49,7 @@ It will display all the pods with the node where it's deployed. The `-w` is to w In another termimal run the command: -```bash +```sh kubectl drain kind-worker2 --ignore-daemonsets ``` @@ -63,7 +63,7 @@ Nothing to see here. ## Clean up -```bash +```sh kubectl delete service,deployment,pod --all ``` diff --git a/15-hpa-vpa/README.md b/15-hpa-vpa/README.md index 4b61401..cf71612 100644 --- a/15-hpa-vpa/README.md +++ b/15-hpa-vpa/README.md @@ -125,7 +125,7 @@ Nothing to see here. ## Clean up -```bash +```sh kubectl delete service,deployment,pod,crd,vpa --all ``` diff --git a/16-sidecar-containers/README.md b/16-sidecar-containers/README.md index 582ee61..c611f6d 100644 --- a/16-sidecar-containers/README.md +++ b/16-sidecar-containers/README.md @@ -39,7 +39,7 @@ This exercice is taken from the [official Kubernetes documentation](https://kube ## Clean up -```bash +```sh kubectl delete service,deployment,pod --all ``` diff --git a/17-volumes/README.md b/17-volumes/README.md index 47a3cc6..fdf5fc9 100644 --- a/17-volumes/README.md +++ b/17-volumes/README.md @@ -46,7 +46,7 @@ Let's review some parameters: Apply it: -```bash +```sh kubectl apply -f 10-volumes/01-simple-mysql-pv.yml ``` @@ -67,7 +67,7 @@ spec: The manifest is pretty similar to the `PersistentVolume`: -```bash +```sh kubectl apply -f 10-volumes/02-simple-mysql-pvc.yml ``` @@ -75,7 +75,7 @@ kubectl apply -f 10-volumes/02-simple-mysql-pvc.yml Now let's create the `deployment` of mysql: -```bash +```sh kubectl apply -f 10-volumes/03-simple-mysql-deployment.yml ``` @@ -96,13 +96,13 @@ There is a bunch of parameters we haven't seen yet: Let's finish by creating a `service` to have stable DNS entry inside our cluster. -```bash +```sh kubectl apply -f 10-volumes/04-simple-mysql-service.yml ``` Finally let's access the mysql: -```bash +```sh kubectl run -it --rm --image=mysql:5.6 --restart=Never mysql-client -- mysql -h mysql -ppassword If you don't see a command prompt, try pressing enter. @@ -120,14 +120,14 @@ mysql> show databases; Create a new database in mysql: -```bash +```sh mysql> CREATE DATABASE testing; Query OK, 1 row affected (0.01 sec) ``` Now delete the service and the deployment: -```bash +```sh kubectl delete service,deployment --all ``` @@ -139,6 +139,6 @@ Nothing to see here. ## Clean up -```bash +```sh kubectl delete service,deployment,pvc,pv,pod --all ``` diff --git a/18-stateful-set/README.md b/18-stateful-set/README.md index 1395bb4..95a3239 100644 --- a/18-stateful-set/README.md +++ b/18-stateful-set/README.md @@ -13,7 +13,7 @@ They are intended for use in environments with many users spread across multiple By default, all objects are in the `default` namespace. There is a "hidden" `namespace` where Kubernetes runs services for itself. Try: -```bash +```sh $ kubectl get namespace NAME STATUS AGE default Active 56d @@ -21,7 +21,7 @@ kube-public Active 56d kube-system Active 56d ``` -```bash +```sh $ kubectl get all --namespace=kube-system [lot of stuff] @@ -33,7 +33,7 @@ It is a tool to validate your Kubernetes YAML files: