From ce4e2ffe46a35051e2517551e1ce3589a767ce3f Mon Sep 17 00:00:00 2001 From: Jerome Petazzoni Date: Sun, 3 May 2020 17:01:59 +0200 Subject: [PATCH] Add sleep command in init container example It can be tricky to illustrate what's going on here, since installing git and cloning the repo can be so fast. So we're sleeping a few seconds to help with this demo and make it easier to show the race condition. --- k8s/nginx-4-with-init.yaml | 2 +- slides/k8s/volumes.md | 6 ++---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/k8s/nginx-4-with-init.yaml b/k8s/nginx-4-with-init.yaml index d41ecd7a..c3023070 100644 --- a/k8s/nginx-4-with-init.yaml +++ b/k8s/nginx-4-with-init.yaml @@ -14,7 +14,7 @@ spec: initContainers: - name: git image: alpine - command: [ "sh", "-c", "apk add --no-cache git && git clone https://github.com/octocat/Spoon-Knife /www" ] + command: [ "sh", "-c", "apk add git && sleep 5 && git clone https://github.com/octocat/Spoon-Knife /www" ] volumeMounts: - name: www mountPath: /www/ diff --git a/slides/k8s/volumes.md b/slides/k8s/volumes.md index a5a9c730..8e408c2f 100644 --- a/slides/k8s/volumes.md +++ b/slides/k8s/volumes.md @@ -404,7 +404,7 @@ spec: initContainers: - name: git image: alpine - command: [ "sh", "-c", "apk add --no-cache git && git clone https://github.com/octocat/Spoon-Knife /www" ] + command: [ "sh", "-c", "apk add git && git clone https://github.com/octocat/Spoon-Knife /www" ] volumeMounts: - name: www mountPath: /www/ @@ -422,9 +422,7 @@ spec: kubectl create -f ~/container.training/k8s/nginx-4-with-init.yaml ``` -- Repeat the same operation as earlier - - (try to send HTTP requests as soon as the pod comes up) +- Try to send HTTP requests as soon as the pod comes up