Docker is a software that allow users to run lightweight virtual machines. You can build Docker "containers" with a Dockerfile. A container is a single lightweight virtual machine running an os, with its own memory space and storage. It is created on an image, which is a template with preconfigured software. A container differs from a virtual machine because it uses the same kernel as the host computer, whereas a virtual machine has its own kernel. Containers are faster and lighter.
If you're running big apps that needs lot of containers/services, such as a database, web servers, monitoring tools, ftp, ssh..., you'll need a way to properly manage multiple Docker containers. It's not an easy task; you need to restart automatically crashed containers, to share data between them, to make sure some are fetchable from outside and some not... That's what Kubernetes does.
In Kubernetes, you have:
All the above objects are described in YAML files.
Minikube is the software that we use to create a virtual machine that runs Kubernetes, and insures compatibility with VirtualBox. It features many tools, such as a dashboard to see how are you'r pods going.
βΈοΈ: Kubernetes cheat sheet
# Create a pod from a YAML file
kubectl create -f <yourfile.yaml>
# Delete a pod
kubectl delete deployment <your deployment>
kubectl delete service <your service>
# and so on if you have different objects
# Get a shell in a pod
# First get the pod full name with:
kubectl get pods
# Then, your pod name should look like "grafana-5bbf569f68-svdnz"
kubectl exec -it <pod name> -- /bin/sh
# Copy data to pod or to our computer
kubectl cp <pod name>:<file> <to>
# or vice versa
kubectl cp <from> <pod name>:<to>
# Restart a deployment
kubectl rollout restart deployment <name>
# Launch minikube dashboard
minikube dashboard
# Get cluster external IP
minikube ip
# Reset Minikube VM
minikube delete
π³: Docker cheat sheet
# Build a docker image from a Dockerfile
docker build -t <your image name> <your Dockerfile dir>
# Start an instance of a docker image
docker run -it <your image name>
# Really important if you want to bind some ports on the container
# to your own computer, use -p option.
# Exemple for an Apache image using port 80 in the container as our port 80
docker run -it debian:apache -p80:80
# See all images
docker images
# See running containers
docker ps
# Stop a container
docker kill <container ID>
# Delete all unused Docker images and cache and free SO MUCH SPACE on
# your computer
docker system prune
π: Documentations
Kubernetes NodePort vs LoadBalancer vs Ingress? When should I use what?
πΊ : Full courses