A simple HTTP server demonstrating a full DevOps workflow: containerization, CI/CD, Kubernetes deployment, and Terraform infrastructure.
- Language: Go
- Container: Docker
- CI/CD: GitHub Actions
- Registry: GitHub Container Registry
- Orchestration: Kubernetes
- IaC: Terraform
http-server-devops/
├── .github/ # GitHub Actions workflows
│ └── workflows/
│ └── docker-publish.yml
├── k8s/ # Kubernetes manifests
│ └── namespace.yaml
│ └── deployment.yaml
│ └── service.yaml
├── terraform/ # Terraform configuration
├── Dockerfile
├── go.mod
├── main.go
├── main_test.go
└── README.md
- Task 1: HTTP Server
- Task 2: Dockerize
- Task 3: CI/CD Pipeline
- Task 4: Kubernetes Deployment
- Task 5: Terraform Configuration
Run the server locally:
go run .The server will start on the default port 8080. You can access it in your browser or using curl:
curl http://localhost:8080/Configure port
PORT=9090 go run .curl http://localhost:9090/Run tests:
go test ./...docker build -t http-server-devops:local .docker run --rm -p 8080:8080 http-server-devops:localcurl http://localhost:8080/docker run --rm -p 9090:9090 -e PORT=9090 http-server-devops:localcurl http://localhost:9090/This project uses GitHub Actions to run tests, build the Docker image, and publish it to GitHub Container Registry.
The workflow is defined in:
.github/workflows/docker-publish.yml
On pull requests to main, the pipeline:
- runs Go tests
- builds the Docker image without publishing it
On pushes to main, the pipeline:
- runs Go tests
- builds the Docker image
- publishes the image to GitHub Container Registry
Published image:
ghcr.io/aldriondev/http-server-devops
Published tags:
latest- ghcr.io/aldriondev/http-server-devops:latest
The workflow uses the built-in GITHUB_TOKEN with following permissions:
permissions:
contents: read
packages: writeNo external Docker registry credentials are required.
The application can be deployed to a local Kubernetes cluster using minikube.
minikube start -p http-server-devopsminikube status -p http-server-devops
kubectl config current-context
kubectl get nodeskubectl apply -f k8s/namespace.yaml
kubectl apply -f k8s/deployment.yaml
kubectl apply -f k8s/service.yamlkubectl get all -n http-server-devopsminikube service http-server -n http-server-devops --url -p http-server-devopsUse the returned URL:
curl <URL>Expected response:
Hello, World!
Health check
curl <URL>/healthExpected response:
ok
kubectl delete namespace http-server-devopsminikube delete -p http-server-devopsThe deployment uses the released image:
ghcr.io/aldriondev/http-server-devops:latest
The Kubernetes manifests can also be deployed using Terraform with the Kubernetes provider.
Terraform uses the local kubeconfig context:
http-server-devops
minikube start -p http-server-devopsminikube status -p http-server-devops
kubectl config current-context
kubectl get nodescd terraform
terraform init
terraform validate
terraform plan
terraform applykubectl get all -n http-server-devopsminikube service http-server -n http-server-devops --url -p http-server-devopsUse the returned URL:
curl <URL>Expected response:
Hello, World!
Health check
curl <URL>/healthExpected response:
ok
terraform destroyminikube delete -p http-server-devopsThe Terraform configuration reuses the kubernetes yaml manifests from k8s/ directory.
k8s/namespace.yaml k8s/deployment.yaml k8s/service.yaml