A simple Go web server that logs visitor IPs to PostgreSQL and displays the visitor count.
Designed for Kubernetes deployment with GitOps (Argo CD) and CI/CD (GitHub Actions).
- Displays visitor count and pod name on a simple HTML page
- Logs visitor IP and timestamp to PostgreSQL
/healthzendpoint for load balancer health checks- Multi-stage Docker build (final image ~15MB)
- CI/CD via GitHub Actions (triggered by git tag)
- GitOps deployment via Argo CD
WebGoDummy/
├── main.go # Go web server
├── index.html # HTML template (embedded in binary)
├── go.mod # Go module dependencies
├── go.sum # Dependency checksums
├── Dockerfile # Multi-stage Docker build
└── .github/workflows/ci.yaml # GitHub Actions CI/CD pipeline
git clone https://github.com/juijeong8324/WebGoDummy.git
cd WebGoDummygo mod tidySet environment variables and run:
export DB_HOST=localhost
export DB_PORT=5432
export DB_USER=postgres
export DB_PASSWORD=yourpassword
export DB_NAME=visitorsdb
go run main.goVisit http://localhost:8080
docker build -t web-go-db:v1 .docker run -p 8080:8080 \
-e DB_HOST=<your-db-host> \
-e DB_PORT=5432 \
-e DB_USER=postgres \
-e DB_PASSWORD=yourpassword \
-e DB_NAME=visitorsdb \
web-go-db:v1Pushing a git tag triggers the following pipeline:
CI (GitHub Actions)
- Build Docker image
- Push image to Docker Hub
- Update image tag in the GitOps repository (
04-deploy.yaml)
CD (Argo CD)
- Detects the change in GitOps repository
- Automatically syncs to the cluster
git add .
git commit -m "feat: something"
git push
# Deploy
git tag v1
git push origin v1| Secret | Description |
|---|---|
DOCKERHUB_USERNAME |
Docker Hub username |
DOCKERHUB_TOKEN |
Docker Hub access token |
OPS_GITHUB_TOKEN |
GitHub personal access token (repo scope) |
| Variable | Default | Description |
|---|---|---|
DB_HOST |
- | PostgreSQL host |
DB_PORT |
5432 |
PostgreSQL port |
DB_USER |
- | PostgreSQL username |
DB_PASSWORD |
- | PostgreSQL password |
DB_NAME |
- | PostgreSQL database name |
Kubernetes manifests are managed separately in the GitOps repository.
| File | Description |
|---|---|
03-postgres.yaml |
PostgreSQL StatefulSet |
04-deploy.yaml |
Go app Deployment (replicas: 2) |
05-hpa.yaml |
Horizontal Pod Autoscaler |
06-ingress.yaml |
Ingress |
07-networkpolicy.yaml |
NetworkPolicy |
08-service.yaml |
Service |