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.
https://github.com/moatorres/infrago/assets/44585769/8109d758-6215-48a6-b888-d1c1cec94a9b
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
friendly projectSkaffold 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. ✨
skaffold dev -p dev
kubectl get pods
kubectl logs -f pods/infrago-7f5dbb59cf-dvx8g
. This will allow us to follow our pod’s logs. Remember to replace infrago-7f5dbb59cf-dvx8
with the name of your pod.kubectl get pods infrago-7f5dbb59cf-dvx8g -w
to watch the pod’s state.ctrl c
to stop the skaffold
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.
⚡️ Powered by OSS — < >
with ☕️ by Moa Torres