http4k on k8s
Bootstrapped minimal http4k
app with inbuilt support for k8s
using this guide.
Different stages of transition of the app onto k8s
- Run locally using
gradle
- Run using
docker
- Run using
docker compose
- Run on k8s using
kubectl
- Run on k8s using
helm
For steps 1 to 3, you reach application by
curl -v http://localhost:8081/liveness
curl -v http://localhost:8081/readiness
curl http://localhost:8080/ping
For step 4 & 5, only http://localhost:8080/ping
is exposed.
liveness
and readiness
probes are not exposed.
Instead they are used internally by k8s.
./gradlew run
./gradle install
docker build --tag backend .
docker images
Use --detach
instead of --rm
to run in background.
docker run \
--name backend \
--publish "8080:8080" \
--publish "8081:8081" \
--rm \
backend
docker ps -a
docker rm -f backend
docker compose up --build
docker ps -a
docker compose down
Enable k8s
in Docker Desktop
for macOS.
Check which k8s you are connected to.
kubectl config get-contexts
kubectl config use-contexts docker-desktop
kubectl get nodes
If you are not using [default] namespace
, you will have to pass --namespace {{custom_namespace}}
.
[Optional] Install k8s dashboard
kubectl apply -f https://raw.githubusercontent.com/kubernetes/dashboard/v2.7.0/aio/deploy/recommended.yaml
kubectl apply -f k8s/k8s-backend.yaml
kubectl get services
kubectl get deployments
kubectl get pods
kubectl delete service backend-service
kubectl delete deployment backend-app
helm install backend-app helm/backend