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 infragoYou 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/infragoBuilding a Docker Image with make
make buildYou 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.yamlDeploying with make
make deploy-devSkaffold 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 demoLet'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.
Replaceinfrago-7f5dbb59cf-dvx8gwith 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
skaffoldprocess.
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.
- Loggo is a zero-dependency JSON-based logger written in Go
⚡️ Powered by OSS — < > with ☕️ by Moa Torres