Just an example of deploying a simple golang http server on a Kubernetes cluster
- Golang
- Just
- Docker Desktop
- Kubectl
- Define
DOCKERHUB_USERNAME
andDOCKERHUB_TOKEN
variables asActions
secrets into the Github repository Settings
Run tests
just test
Clean tests cache
just cleancache
Run application as standalone
just run
Check running with
curl localhost:8080
curl localhost:8080/headers
Build application binary
just build
Build docker image
just dockerbuild
Deploy to local kubernetes cluster -e.g. Docker Desktop- using the local built image
just deploy
Check deployment with
kubectl get services -n go-http-server
curl localhost:8000
Deploy to local kubernetes cluster -e.g. Docker Desktop- using the image from remote registry -Dockerhub-
just deployfromremote
Check deployment with
kubectl get services -n go-http-server
curl localhost:8000
Show logs from all deployment pods
just showlogs
Teardown the local kubernetes deployment -e.g. Docker Desktop-
just teardown
This repository contains a basic CI/CD pipeline (made with GitHub Actions), which runs the tests and uploads the docker image to the Dockerhub registry.
You can check it in the .github/workflows/main.yml
file.
- Access to
https://hub.docker.com/
and Sign In - Create a new repository with your docker hub account (Button
Create repository
) - Open a terminal and execute:
sudo docker login # Enter username and password
sudo docker build . --tag <username>/<repository-name>:<tag> --file <dockerfile-location>
# Example: sudo docker build . --tag antoniomarfer/go-http-server:main --file build/package/Dockerfile
sudo docker push <username>/<repository-name>:<tag>
# Example: sudo docker push antoniomarfer/go-http-server:main