Skip to content

stunthamster/kubetraining

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Kubernetes Training Application

This is a complete Kubernetes training setup with a Go frontend and backend application.

Structure

  • backend/ - Go backend API service
  • frontend/ - Go frontend web application
  • k8s/ - Kubernetes configuration files

Building Docker Images

# Build backend
cd backend
docker build -t your-registry/backend:latest .
docker push your-registry/backend:latest

# Build frontend
cd ../frontend
docker build -t your-registry/frontend:latest .
docker push your-registry/frontend:latest

Deploying to Kubernetes

  1. Update the image names in the deployment files to match your Docker registry.

  2. Apply the configurations:

# Deploy backend
kubectl apply -f k8s/backend-deployment.yaml
kubectl apply -f k8s/backend-service.yaml

# Deploy frontend
kubectl apply -f k8s/frontend-deployment.yaml
kubectl apply -f k8s/frontend-service.yaml

# Deploy ingress
kubectl apply -f k8s/ingress.yaml
  1. Add to your /etc/hosts file:
127.0.0.1 training.local
  1. Access the application at http://training.local

Architecture

  • Backend: REST API service on port 8080

    • /health - Health check endpoint
    • /api/data - Returns JSON data with request counter
  • Frontend: Web UI on port 8081

    • Displays a simple web interface
    • Calls backend API via proxy endpoint
    • Shows backend responses

Kubernetes Resources

  • Deployments: Manage replica sets for both services

    • Backend: 3 replicas
    • Frontend: 2 replicas
  • Services: Internal networking

    • Backend: ClusterIP service on port 8080
    • Frontend: ClusterIP service on port 80
  • Ingress: External access via NGINX ingress controller

    • Routes / to frontend
    • Routes /api to backend

Testing Locally

# Run backend locally
cd backend
go run main.go

# Run frontend locally (in another terminal)
cd frontend
BACKEND_URL=http://localhost:8080 go run main.go

Visit http://localhost:8081 to see the frontend.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published