Start minikube and enable ingress :

minikube start --vm-driver=virtualbox
minikube addons enable ingress


Start a pod called docker based on the docker image:

kubectl run docker --image=docker:17.11 --restart=Never docker image ls

Show the pod status:

kubectl get pods --show-all

Show the logs:

kubectl logs docker

Delete the pod:

kubectl delete pod docker

hostPath allows us to mount a file or a directory from a host to Pods and, through them, to containers. Other types are Directory/DirectoryOrCreate, File/FileOrCreate, Socket, CharDevice, BlockDevice

Create the pod:

kubectl create -f volume/docker.yml

List the docker images:

kubectl exec -it docker -- docker image ls

Delete the pod:

kubectl delete -f volume/docker.yml


Show the yml definition:

cat volume/jenkins.yml

Create the object:

kubectl create -f volume/jenkins.yml --record --save-config
kubectl rollout status deploy jenkins

Open in browser:

open "http://$(minikube ip)/jenkins"

Get the pod name:

POD_NAME=$(kubectl get pods \
    -l service=jenkins,type=master \
    -o jsonpath="{.items[*]}")

Kill the main process:

kubectl exec -it $POD_NAME kill 1

Get the pods:

kubectl get pods

Open in browser:

open "http://$(minikube ip)/jenkins"
open "http://$(minikube ip)/jenkins/newJob"
cat volume/jenkins-empty-dir.yml

Apply it:

kubectl apply -f volume/jenkins-empty-dir.yml

Wait the rollout finish:

kubectl rollout status deploy jenkins

Do the same process above and the job is persistent.

An emptyDir Volume is created when a Pod is assigned to a node. It will exist for as long as the Pod continues running on that server.

emptyDir can survive container failures. When a container crashes, a Pod is not removed from the node. Instead, Kubernetes will recreate the failed container inside the same Pod and, thus, preserve the emptyDir Volume.