In this lab, we will build a Docker image and deploy it to the microk8s cluster.
- Log into the microk8s VM with
vagrant ssh workshop_microk8s
- Clone your fork of the Link app in the home directory:
git clone https://github.com/base10/link.git
- Change into the Link directory with
cd link
and build the Docker image:
sudo docker build -t link-container . -f deploy/Dockerfile
- Save the image to a tar file:
sudo docker save link-container:latest > ~/link-container.tar
- Import the image in microk8s:
microk8s ctr image import ~/link-container.tar
Run this command to apply the yaml files:
kubectl apply -f deploy/k8s
- Examine microk8s resources:
kubectl get all --all-namespaces
In the output from this command, you should see a pod, a deployment, a service,
and a replicaset for link-app
.
- Run this command to scale the deployment up to 2 pods:
kubectl scale --replicas=2 deployment.apps/link-app
-
Run
kubectl get all --all-namespaces
to confirm that there are now two pods for thelink-app
deployment. -
Run this command to scale back down:
kubectl scale --replicas=1 deployment.apps/link-app
- Run
kubectl get all --all-namespaces
again to confirm that the cluster scaled back down to a single pod forlink-app
.