Skip to content

AldrionDev/http-server-devops

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

HTTP Server DevOps Project

A simple HTTP server demonstrating a full DevOps workflow: containerization, CI/CD, Kubernetes deployment, and Terraform infrastructure.

Stack

  • Language: Go
  • Container: Docker
  • CI/CD: GitHub Actions
  • Registry: GitHub Container Registry
  • Orchestration: Kubernetes
  • IaC: Terraform

Planned Project Structure

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

Tasks

  • Task 1: HTTP Server
  • Task 2: Dockerize
  • Task 3: CI/CD Pipeline
  • Task 4: Kubernetes Deployment
  • Task 5: Terraform Configuration

Installation & Usage

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 Usage

Build image

docker build -t http-server-devops:local .

Run container

docker run --rm -p 8080:8080 http-server-devops:local

Test container

curl http://localhost:8080/

Run with custom port

docker run --rm -p 9090:9090 -e PORT=9090 http-server-devops:local
curl http://localhost:9090/

CI/CD

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: write

No external Docker registry credentials are required.

Kubernetes Deployment

The application can be deployed to a local Kubernetes cluster using minikube.

Start minikube

minikube start -p http-server-devops

Check cluster status

minikube status -p http-server-devops
kubectl config current-context
kubectl get nodes

Deploy application

kubectl apply -f k8s/namespace.yaml
kubectl apply -f k8s/deployment.yaml
kubectl apply -f k8s/service.yaml

Check resources

kubectl get all -n http-server-devops

Access application

minikube service http-server -n http-server-devops --url -p http-server-devops

Use the returned URL:

curl <URL>

Expected response:

Hello, World!

Health check

curl <URL>/health

Expected response:

ok

Remove deployment

kubectl delete namespace http-server-devops

Delete local cluster

minikube delete -p http-server-devops

The deployment uses the released image:

ghcr.io/aldriondev/http-server-devops:latest

Terraform Deployment

The Kubernetes manifests can also be deployed using Terraform with the Kubernetes provider.

Terraform uses the local kubeconfig context:

http-server-devops

start minikube

minikube start -p http-server-devops

Check cluster status

minikube status -p http-server-devops
kubectl config current-context
kubectl get nodes

Deploy application with Terraform

cd terraform
terraform init
terraform validate
terraform plan
terraform apply

Check resources

kubectl get all -n http-server-devops

Access application

minikube service http-server -n http-server-devops --url -p http-server-devops

Use the returned URL:

curl <URL>

Expected response:

Hello, World!

Health check

curl <URL>/health

Expected response:

ok

Destroy resources

terraform destroy

Delete local cluster

minikube delete -p http-server-devops

The Terraform configuration reuses the kubernetes yaml manifests from k8s/ directory.

k8s/namespace.yaml k8s/deployment.yaml k8s/service.yaml

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors