Projects:Kubernetes: verschil tussen versies

Naar navigatie springen Naar zoeken springen
533 bytes toegevoegd ,  10 mrt 2019
Regel 167: Regel 167:
</pre>
</pre>


Because of <code>--restart=Never</code>, if you exit your shell, the pod will exit and automatically be removed. If you don't give the parameter, kubectl will instead create a Deployment containing your Pod, instead of just the Pod; this means that when your Pod exits, the Deployment will have 0 out of 1 Pods running, so a new Pod will automatically be created:
In the command above, we gave <code>--restart=Never</code>. There are three parameters to this option:
 
* <code>Never</code>: When the pod exits, it will not be recreated. If this is given, <code>kubectl</code> will just create a Pod.
* <code>OnFailure</code>: When the pod exits with failure, it will be recreated, otherwise not. In other words, <code>kubectl</code> will start a Job to create the Pod. (If that doesn't make sense, quickly check up on Jobs in the Concepts section above!)
* <code>Always</code>: When the pod exits, it will be recreated. You guessed it: in this case, <code>kubectl</code> will create a Deployment. (If you didn't guess it, re-check the Concepts section!)
 
The default is <code>--restart=Always</code> so you'll see the container is recreated like this:


<pre>
<pre>
$ kubectl run -ti --image=ubuntu:bionic bash  
$ kubectl run -ti --image=ubuntu:bionic bash  
kubectl run --generator=deployment/apps.v1 is DEPRECATED and will be removed in a future version. Use kubectl run --generator=run-pod/v1 or kubectl create instead.
If you don't see a command prompt, try pressing enter.
If you don't see a command prompt, try pressing enter.
root@bash-58654c7f4b-9bhcq:/# touch foobarbaz
root@bash-58654c7f4b-9bhcq:/# touch foobarbaz
Regel 186: Regel 191:


As you can see, the container restarted, as <code>/foobarbaz</code> did not exist anymore when re-attaching after the <code>exit</code>. Any state in the filesystem of the container/pod will be gone upon restart.
As you can see, the container restarted, as <code>/foobarbaz</code> did not exist anymore when re-attaching after the <code>exit</code>. Any state in the filesystem of the container/pod will be gone upon restart.
If you tried this, you can check and remove the deployment like this:
<pre>
$ kubectl get deployments     
NAME  READY  UP-TO-DATE  AVAILABLE  AGE
bash  1/1    1            1          3s
$ kubectl delete deployment bash
deployment.extensions "bash" deleted
</pre>


== Storage using Volumes ==
== Storage using Volumes ==

Navigatiemenu