Guestbook
Docker Compose File
# docker-compose.yml
version: "2"

services:

  redis-master:
    image: k8s.gcr.io/redis:e2e
    ports:
      - "6379"

  redis-slave:
    image: gcr.io/google_samples/gb-redisslave:v3
    ports:
      - "6379"
    environment:
      - GET_HOSTS_FROM=dns

  frontend:
    image: gcr.io/google-samples/gb-frontend:v4
    ports:
      - "80:80"
    environment:
      - GET_HOSTS_FROM=dns
    labels:
      kompose.service.type: LoadBalancer
        
Create K8s Manifest Files
# convert docker-compose.yml
kompose convert

# convert a specific docker-compose file
# kompose -f [compose_file_name] convert
kompose -f compose.yaml convert

# convert multiple docker-compose file
kompose -f docker-compose.yml -f docker-guestbook.yml convert
        
Deployment
kubectl apply -f redis-leader-deployment.yaml
kubectl apply -f redis-leader-service.yaml
kubectl apply -f redis-follower-deployment.yaml
kubectl apply -f redis-follower-service.yaml
kubectl apply -f frontend-deployment.yaml
kubectl apply -f frontend-service.yaml
        
Access the App
kubectl port-forward svc/frontend 8080:80

http://localhost:8080
        
Cleaning Up
# kubectl get deployment
kubectl delete deployment frontend
kubectl delete deployment redis-follower
kubectl delete deployment redis-leader

# kubectl get service
kubectl delete service frontend
kubectl delete service redis-follower
kubectl delete service redis-leader
        
Reference
  • Guestbook