Comment on What's the best approach to deploy a static website to K8s cluster from a CI pipeline?
ArbiterXero@lemmy.world 1 year agoThe docker image needs to actually host the site, so more than just files, you’ll need nginx in the image.
K8s is WAY over complicated for this, it’s designed for auto scaling and self healing, but I’m assuming you’re using this as a “cool” or “learning” exercise.
Helm packages for k8s are super helpful and will give you a template for all the networking pieces
xinayder@infosec.pub 1 year ago
That’s a nice suggestion. I guess I can make the CI build a Docker image containing my website’s files and then have a plugin for it to restart the pod that serves the website so it fetches the latest image.
ArbiterXero@lemmy.world 1 year ago
K8s is that “restart” mechanism.
Docker images are just the thing that it restarts.
Docker itself or “docker compose” can restart images and do everything you need, but if you want to go the full k8s it’s complicated but great learning
doeknius_gloek@feddit.de 1 year ago
One simple way to pull the new image into your cluster is to overwrite the
latest
tag, specifyimagePullPolicy: always
in your deployment and then usekubectl rollout restart deployment my-static-site
from within your pipeline to restart all pods. Kubernetes will then terminate all pods and replace them with new ones that pull the latest image.You can also work with versioned tags and
kubectl set image deployment/my-static-site site=my/image:version
. This might be a bit nicer and allowsimagePullPolicy: IfNotPresent
, but you have to pass your version number into your pipeline somehow, e.g. with git tags.