Skip to content

Demonstrating k8s

Local Kubernetes (docker)

Enable Kubernetes in Docker desktop.

  • Deploy Busybox:

    # under lab/local-play
    kubectl apply -f busybox.yaml
    
  • Deploy a webapp

    # under lab/local-play
    kubectl apply -f python-web-server.yaml
    kubectl port-forward service/python-webserver-service  8080
    
  • Deploy k8s dashboard:

    kubectl apply -f https://raw.githubusercontent.com/kubernetes/dashboard/v2.7.0/aio/deploy/recommended.yaml
    
  • Deploy postgresql

    kubectl apply -f postgresql.yaml
    # Then use psql
    kubectl exec -it [pod-name] --  psql -h localhost -U admin --password -p 5432 postgresdb
    
  • Expose via a service

    kubectl expose deployment guestbook --type="NodePort" --port=3000
    kubectl get svc guestbook
    
  • Scale the application

    kubectl scale --replicas=10 deployment guestbook
    kubectl rollout status deployment guestbook
    kubectl get pods
    
  • Update the application version

    kubectl set image deployment/guestbook guestbook=ibmcom/guestbook:v2
    
  • Rollout last version

    kubectl rollout undo deployment guestbook
    
  • Remove the app

    kubectl delete deployment guestbook
    kubectl delete svc guestbook