Lesson  in  Kubernetes 101

Challenge: build the store image

The image you left behind in the previous lesson weighs 360 MB, carries the compiler inside and runs as root. Turn it into a multistage build, publish it in the cluster's registry and deploy it.

In the previous lesson you built the api image and learned to order its layers so the cache is worth something. But you left one problem untouched: that image weighs more than 350 MB and carries inside the Go compiler, the package manager and your source code. None of that is needed to run the binary.

Here you solve it, and close the circle along the way: the image stops living on your machine, gets published in the cluster's registry and ends up running inside a Pod. It is the first time in the course that you deploy something of your own.

The challenge asks three things of the final image: under 30 MB, no shell inside, and a user that isn't root. All three are checked automatically, and all three have consequences much later on (the Security chapter takes for granted that the image doesn't run as root, and the one on debugging takes for granted that there is no curl inside to use).

There are no guided steps: you have the starting Dockerfile, the collapsed hints in case you get stuck, and the automatic verification.

Passing criterion: the image registry.iximiuz.com/tienda/api:2.1.0 is published in the registry, weighs less than 30 MB, has no shell, declares a non-root user, and there is an api Pod running it that answers on port 8080.

Previous lesson
Images and layers