This repository contains a small Go HTTP service that can be run locally with Podman or deployed to a local Kubernetes cluster with Kind.
The project has three main parts:
-
Go HTTP service
A lightweight web server that exposes:/for the main response/healthfor liveness checks/readyfor readiness checks/failto simulate an unhealthy state
-
Container image
The Go application is packaged into a container image so it can run consistently in different environments. -
Kubernetes deployment
The app can be deployed to a local Kind cluster using a Deployment and a NodePort Service, with health probes configured for Kubernetes.
The repository is organized to separate application code, deployment manifests, and build files:
cmd/— application entry pointsinternal/— internal application packagesdeploy/— Kubernetes manifests and Kind configurationbuild/— container build filesgo.mod— Go module definition
The container build expects the repository root to be the build context. That way, the Dockerfile in build/ can copy the files it needs from the project root:
podman build -f build/Containerfile -t localhost/hello-go-service .
Before you start, make sure the required tools are installed:
- podman
- kind
- kubectl
(Optional) If you're using Kind with Podman, you may also want to Docker/Podman compatibility settings:
sudo apt update && sudo apt install podman-dockerexport DOCKER_HOST="unix://$XDG_RUNTIME_DIR/podman/podman.sock"sudo apt install podman-dockersudo ln -s /run/podman/podman.sock /var/run/docker.sock
Build the Go application into a container image from the repository root:
podman build -f build/Containerfile -t localhost/hello-go-service .
This is the quickest way to test the service without Kubernetes. It maps port 8082 on your machine to port 8080 inside the container:
podman run -d -p 8082:8080 hello-go-service
Use this option if you want to test the app in a Kubernetes environment. Kind runs a local cluster inside containers.
Create the cluster:
KIND_EXPERIMENTAL_PROVIDER=podman kind create cluster --name go-learning --config deploy/kind-config.yaml
If using Podman Desktop, load the image into the cluster so Kubernetes can use it:
kind load docker-image localhost/hello-go-service:latest --name go-learning
Otherwise, the Podman-native way is:
podman save --format docker-archive -o hello.tar localhost/hello-go-service:latestkind load image-archive hello.tar --name go-learning
Deploy the application and service:
kubectl apply -f deploy/deployment.yamlkubectl apply -f deploy/service.yaml
If you update the image but keep the same tag, restart the deployment so Kubernetes runs the newer image:
kubectl rollout restart deployment hello-go-deploymentkubectl rollout status deployment hello-go-deployment
The rollout status command is useful because it tells you when the new pods are ready and the update has completed successfully.
These checks help confirm the app is responding correctly:
-
curl -v localhost:8082/
Returns the main response for the app. -
curl -v localhost:8082/health
Checks whether the service is healthy. -
curl -v localhost:8082/ready
Checks whether the service is ready to receive traffic. -
curl -v localhost:8082/fail
Forces the service into an unhealthy state for testing. -
curl -v localhost:8082/health
Should now return500after calling/fail.
If you change the Go code, rebuild the image and redeploy it.
Use this when you want to keep the same tag, such as latest, and refresh the running workload manually:
- Rebuild the image
- Reload it into Kind:
kind load docker-image localhost/hello-go-service:latest --name go-learning
- Restart the deployment:
kubectl rollout restart deployment hello-go-deployment
- Wait for the update to finish:
kubectl rollout status deployment hello-go-deployment
This works well for local development, but it requires a manual restart because Kubernetes does not automatically detect changes when the image tag stays the same.
Use this when you want deployments to clearly track a specific image version:
- Build a versioned image, for example:
podman build -t localhost/hello-go-service:v2 .
- Update
deploy/deployment.yamlto use the new tag - Apply the updated manifest:
kubectl apply -f deploy/deployment.yaml
- Check rollout progress:
kubectl rollout status deployment hello-go-deployment
This is usually the cleaner approach because each version is explicit and easier to trace.