Erlang cluster on Kubernetes: Basic init container
This seems like it would be less invasive and more generic than making changes to the main container. Consider the situation where you wanted to use that container with something other than cert-manager (Amazon KMS, for example). By separating that concern into an init container, we make it easier to change our minds later.
This post talks about adding a simple “Hello World!” init container to the pod. I’ll add the certificate stuff in a later post.
Dockerfile is as follows:
FROM docker.io/alpine WORKDIR /erlclu-init COPY erlclu-init.sh erlclu-init.sh ENTRYPOINT ["/erlclu-init/erlclu-init.sh"]
erlclu-init.sh script is as follows:
#!/bin/sh echo "Hello from $(hostname)"
We add it to the deployment as follows:
#... spec: initContainers: - name: erlclu-init image: docker.k3s.differentpla.net/erlclu-init:0.1.0 imagePullPolicy: Always containers: #...
The Makefile is as follows:
all: build-init-image push-init-image build-init-image: podman build -f Dockerfile.init -t erlclu-init push-init-image: podman push erlclu-init $(DOCKER_REGISTRY)/erlclu-init:$(RELEASE_VSN)
Note: it expects to inherit the environment variables from the top-level Makefile.