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. ✨
Open three terminals on your machine, then run the following command in the first one:
skaffold dev -p dev
In the second terminal, run the following command to get the names of the running pods:
kubectl get pods
Follow your pod’s logs by running the command below.
Replace infrago-7f5dbb59cf-dvx8g with the actual name of your pod:
kubectl logs -f pods/infrago-7f5dbb59cf-dvx8g
In the third terminal, watch the pod’s state with:
kubectl get pods infrago-7f5dbb59cf-dvx8g -w
Return to the first terminal and press Ctrl + C to stop the skaffold process.
See what happened? Since we specified terminationGracePeriodSeconds: 120 in 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