Simple Kubernetes manifests can be found in the k8s folder. The configuration there, as well as the instructions in this document, are designed for a local bare-metal cluster (particularly using minikube) for testing how the distributed system behaves across multiple replicas.
There are 3 manifests in the k8s folder:
app.yaml: TheDeploymentandServicefor thesession-queueappredis.yaml: Simple RedisDeploymentandServicefor thesession-queuereplicas.config.yaml: Environment variable configuration forsession-queuewith some sensible testing defaults.
Make sure minikube is running on your machine with:
minikube startThe app manifest points at a local image rather than pulling from a remote registry for local testing ease. Build the image in minikube's environment with the following:
eval $(minikube docker-env)
docker build -t session-queue:latest .Now with the image built and available, you should be able to apply all the manifests, with:
kubectl apply -f k8sThe URL of session-queue's NodePort Service can now be retrieved with minikube:
minikube service session-queue --urlYou should now be able to interact with the system, using a HTTP client of your choice, with this URL. For example, with HTTPie:
http POST {url}/join
http GET {url}/status "Authorization: Bearer {token}"You can also access logs of the replicas with:
kubectl get pods # This will list random-generated pod names
kubectl logs {pod} --followAs mentioned, the out-the-box manifests are made for local development testing. There are various changes that could/should be made for a production-ready k8s deployment, including:
- Pushing the image to a remote registry and not using
imagePullPolicy: Never - Using a
Serviceof typeLoadBalancerto expose the deployment (particularly if on a cloud environment) - Storing the JWT secret outside of config/source control, and using something like ESO to inject it