Skip to content

Commit eff61d2

Browse files
committed
Added back required restart=Never for busybox only
1 parent 57f19cf commit eff61d2

File tree

5 files changed

+22
-22
lines changed

5 files changed

+22
-22
lines changed

a.core_concepts.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,9 @@ kubectl run nginx --image=nginx --dry-run=client -o yaml | kubectl create -n myn
7777
<p>
7878

7979
```bash
80-
kubectl run busybox --image=busybox --command -it -- env # -it will help in seeing the output
80+
kubectl run busybox --image=busybox --command --restart=Never -it -- env # -it will help in seeing the output
8181
# or, just run it without -it
82-
kubectl run busybox --image=busybox --command -- env
82+
kubectl run busybox --image=busybox --command --restart=Never -- env
8383
# and then, check its logs
8484
kubectl logs busybox
8585
```
@@ -94,7 +94,7 @@ kubectl logs busybox
9494

9595
```bash
9696
# create a YAML template with this command
97-
kubectl run busybox --image=busybox --dry-run=client -o yaml --command -- env > envpod.yaml
97+
kubectl run busybox --image=busybox --restart=Never --dry-run=client -o yaml --command -- env > envpod.yaml
9898
# see it
9999
cat envpod.yaml
100100
```
@@ -234,13 +234,13 @@ Alternatively you can also try a more advanced option:
234234
# Get IP of the nginx pod
235235
NGINX_IP=$(kubectl get pod nginx -o jsonpath='{.status.podIP}')
236236
# create a temp busybox pod
237-
kubectl run busybox --image=busybox --env="NGINX_IP=$NGINX_IP" --rm -it -- sh -c 'wget -O- $NGINX_IP:80'
237+
kubectl run busybox --image=busybox --env="NGINX_IP=$NGINX_IP" --rm -it --restart=Never -- sh -c 'wget -O- $NGINX_IP:80'
238238
```
239239

240240
Or just in one line:
241241

242242
```bash
243-
kubectl run busybox --image=busybox --rm -it -- wget -O- $(kubectl get pod nginx -o jsonpath='{.status.podIP}:{.spec.containers[0].ports[0].containerPort}')
243+
kubectl run busybox --image=busybox --rm -it --restart=Never -- wget -O- $(kubectl get pod nginx -o jsonpath='{.status.podIP}:{.spec.containers[0].ports[0].containerPort}')
244244
```
245245

246246
</p>
@@ -318,9 +318,9 @@ kubectl exec -it nginx -- /bin/sh
318318
<p>
319319

320320
```bash
321-
kubectl run busybox --image=busybox -it -- echo 'hello world'
321+
kubectl run busybox --image=busybox -it --restart=Never -- echo 'hello world'
322322
# or
323-
kubectl run busybox --image=busybox -it -- /bin/sh -c 'echo hello world'
323+
kubectl run busybox --image=busybox -it --restart=Never -- /bin/sh -c 'echo hello world'
324324
```
325325

326326
</p>
@@ -332,7 +332,7 @@ kubectl run busybox --image=busybox -it -- /bin/sh -c 'echo hello world'
332332
<p>
333333

334334
```bash
335-
kubectl run busybox --image=busybox -it --rm -- /bin/sh -c 'echo hello world'
335+
kubectl run busybox --image=busybox -it --rm --restart=Never -- /bin/sh -c 'echo hello world'
336336
kubectl get po # nowhere to be found :)
337337
```
338338

b.multi_container_pods.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
Easiest way to do it is create a pod with a single container and save its definition in a YAML file:
1010

1111
```bash
12-
kubectl run busybox --image=busybox -o yaml --dry-run=client -- /bin/sh -c 'echo hello;sleep 3600' > pod.yaml
12+
kubectl run busybox --image=busybox --restart=Never -o yaml --dry-run=client -- /bin/sh -c 'echo hello;sleep 3600' > pod.yaml
1313
vi pod.yaml
1414
```
1515

@@ -135,7 +135,7 @@ kubectl apply -f pod-init.yaml
135135
kubectl get po -o wide
136136

137137
# Execute wget
138-
kubectl run box --image=busybox -it --rm -- /bin/sh -c "wget -O- IP"
138+
kubectl run box --image=busybox --restart=Never -it --rm -- /bin/sh -c "wget -O- IP"
139139

140140
# you can do some cleanup
141141
kubectl delete po box

e.observability.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ kubectl delete -f pod.yaml
142142
<p>
143143

144144
```bash
145-
kubectl run busybox --image=busybox -- /bin/sh -c 'i=0; while true; do echo "$i: $(date)"; i=$((i+1)); sleep 1; done'
145+
kubectl run busybox --image=busybox --restart=Never -- /bin/sh -c 'i=0; while true; do echo "$i: $(date)"; i=$((i+1)); sleep 1; done'
146146
kubectl logs busybox -f # follow the logs
147147
```
148148

@@ -157,7 +157,7 @@ kubectl logs busybox -f # follow the logs
157157
<p>
158158

159159
```bash
160-
kubectl run busybox --image=busybox -- /bin/sh -c 'ls /notexist'
160+
kubectl run busybox --restart=Never --image=busybox -- /bin/sh -c 'ls /notexist'
161161
# show that there's an error
162162
kubectl logs busybox
163163
kubectl describe po busybox
@@ -173,7 +173,7 @@ kubectl delete po busybox
173173
<p>
174174

175175
```bash
176-
kubectl run busybox --image=busybox -- notexist
176+
kubectl run busybox --restart=Never --image=busybox -- notexist
177177
kubectl logs busybox # will bring nothing! container never started
178178
kubectl describe po busybox # in the events section, you'll see the error
179179
# also...

f.services.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ kubectl get ep # endpoints
3535

3636
```bash
3737
kubectl get svc nginx # get the IP (something like 10.108.93.130)
38-
kubectl run busybox --rm --image=busybox -it -- sh
38+
kubectl run busybox --rm --image=busybox -it --restart=Never -- sh
3939
wget -O- IP:80
4040
exit
4141
```
@@ -46,7 +46,7 @@ or
4646

4747
```bash
4848
IP=$(kubectl get svc nginx --template={{.spec.clusterIP}}) # get the IP (something like 10.108.93.130)
49-
kubectl run busybox --rm --image=busybox -it --env="IP=$IP" -- wget -O- $IP:80 --timeout 2
49+
kubectl run busybox --rm --image=busybox -it --restart=Never --env="IP=$IP" -- wget -O- $IP:80 --timeout 2
5050
# Tip: --timeout is optional, but it helps to get answer more quickly when connection fails (in seconds vs minutes)
5151
```
5252

@@ -128,7 +128,7 @@ kubectl create deploy foo --image=dgkanatsios/simpleapp --port=8080 --replicas=3
128128

129129
```bash
130130
kubectl get pods -l app=foo -o wide # 'wide' will show pod IPs
131-
kubectl run busybox --image=busybox -it --rm -- sh
131+
kubectl run busybox --image=busybox --restart=Never -it --rm -- sh
132132
wget -O- POD_IP:8080 # do not try with pod name, will not work
133133
# try hitting all IPs to confirm that hostname is different
134134
exit
@@ -159,7 +159,7 @@ kubectl get endpoints foo # you will see the IPs of the three replica nodes, lis
159159

160160
```bash
161161
kubectl get svc # get the foo service ClusterIP
162-
kubectl run busybox --image=busybox -it --rm -- sh
162+
kubectl run busybox --image=busybox -it --rm --restart=Never -- sh
163163
wget -O- foo:6262 # DNS works! run it many times, you'll see different pods responding
164164
wget -O- SERVICE_CLUSTER_IP:6262 # ClusterIP works as well
165165
# you can also kubectl logs on deployment pods to see the container logs
@@ -210,8 +210,8 @@ kubectl create -f policy.yaml
210210

211211
# Check if the Network Policy has been created correctly
212212
# make sure that your cluster's network provider supports Network Policy (https://kubernetes.io/docs/tasks/administer-cluster/declare-network-policy/#before-you-begin)
213-
kubectl run busybox --image=busybox --rm -it -- wget -O- http://nginx:80 --timeout 2 # This should not work. --timeout is optional here. But it helps to get answer more quickly (in seconds vs minutes)
214-
kubectl run busybox --image=busybox --rm -it --labels=access=granted -- wget -O- http://nginx:80 --timeout 2 # This should be fine
213+
kubectl run busybox --image=busybox --rm -it --restart=Never -- wget -O- http://nginx:80 --timeout 2 # This should not work. --timeout is optional here. But it helps to get answer more quickly (in seconds vs minutes)
214+
kubectl run busybox --image=busybox --rm -it --restart=Never --labels=access=granted -- wget -O- http://nginx:80 --timeout 2 # This should be fine
215215
```
216216

217217
</p>

g.state.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ kubernetes.io > Documentation > Tasks > Configure Pods and Containers > [Configu
1717
Easiest way to do this is to create a template pod with:
1818

1919
```bash
20-
kubectl run busybox --image=busybox -o yaml --dry-run=client -- /bin/sh -c 'sleep 3600' > pod.yaml
20+
kubectl run busybox --image=busybox --restart=Never -o yaml --dry-run=client -- /bin/sh -c 'sleep 3600' > pod.yaml
2121
vi pod.yaml
2222
```
2323
Copy paste the container definition and type the lines that have a comment in the end:
@@ -165,7 +165,7 @@ kubectl get pv # will show as 'Bound' as well
165165
Create a skeleton pod:
166166

167167
```bash
168-
kubectl run busybox --image=busybox -o yaml --dry-run=client -- /bin/sh -c 'sleep 3600' > pod.yaml
168+
kubectl run busybox --image=busybox --restart=Never -o yaml --dry-run=client -- /bin/sh -c 'sleep 3600' > pod.yaml
169169
vi pod.yaml
170170
```
171171

@@ -255,7 +255,7 @@ There are lots of different types per cloud provider (see here)[https://kubernet
255255
<p>
256256

257257
```bash
258-
kubectl run busybox --image=busybox -- sleep 3600
258+
kubectl run busybox --image=busybox --restart=Never -- sleep 3600
259259
kubectl cp busybox:etc/passwd ./passwd # kubectl cp command
260260
# previous command might report an error, feel free to ignore it since copy command works
261261
cat passwd

0 commit comments

Comments
 (0)