InfraGo is an open-source static file server application based on the native net/http
module. This project was created as an exercise and should serve as a simple example of what you can build with Go, Docker and Kubernetes.
infrago-demo.mov
To build the Go binary, ensure you're on the root directory of the project and run:
go build -o infrago
You can either build a local Docker Image manually or using the available make commands.
Buildind a Docker Image with docker buildx
docker buildx build -f Dockerfile . -t docker.io/moatorres/infrago
Building a Docker Image with make
make build
You can deploy the resources as you'd normally do with kubectl
.
Deploying locally with kubectl
kubectl apply -f k8s/dev/deployment.yaml
kubectl apply -f k8s/dev/ingress.yaml
Deploying with make
make deploy-dev
Skaffold handles the workflow for building, pushing and deploying your application, allowing you to focus on what matters most: writing code. ✨ Learn more about Skaffold here.
Installing skaffold
on your machine
# For Linux x86_64 (amd64)
curl -Lo skaffold https://storage.googleapis.com/skaffold/releases/latest/skaffold-linux-amd64 && \
sudo install skaffold /usr/local/bin/
# For Linux ARMv8 (arm64)
curl -Lo skaffold https://storage.googleapis.com/skaffold/releases/latest/skaffold-linux-arm64 && \
sudo install skaffold /usr/local/bin/
Deploying with skaffold
skaffold dev -p demo
Let's see how our deployment behaves on Kubernetes. It's advised that you install skaffold
. Skaffold handles the workflow for building, pushing and deploying your application, allowing you to focus on what matters most: writing code. ✨
- Open three terminals on your machine then run the following command in the first one.
skaffold dev -p dev
- Move to the second terminal and run the following command to get the names of the running pods.
kubectl get pods
- Now run
kubectl logs -f pods/infrago-7f5dbb59cf-dvx8g
. This will allow us to follow our pod's logs. Remember to replaceinfrago-7f5dbb59cf-dvx8
with the name of your pod. - Go to the third terminal and run
kubectl get pods infrago-7f5dbb59cf-dvx8g -w
to watch the pod's state. - Now go back to the first terminal and press
ctrl c
to stop theskaffold
process.
See what happened? Since we specified a terminationGracePeriodSeconds: 120
on our Deployment, our server was able to catch the 'terminated'
signal, wait for 10 seconds, and then exit the process before being shut down by Kubernetes.
- Loggo is a zero-dependency JSON-based logger written in Go
⚡️ Powered by OSS — < >
with ☕️ by Moa Torres