Skip to content

Latest commit

 

History

History
120 lines (108 loc) · 2.69 KB

minikube.md

File metadata and controls

120 lines (108 loc) · 2.69 KB

Hands-On with Basic Kubernetes Commands

  • Starting Minikube
    • Ensure Minikube is running:
      minikube start
  • kubectl Commands
    • Get cluster information:
      kubectl cluster-info
    • List nodes:
      kubectl get nodes
    • List namespaces:
      kubectl get namespaces
    • Access the Kubernetes dashboard
      minikube dashboard

Push your Image to Docker Hub

  • Tag my-fast-api:1.0 image to <docker-hub-username>/my-fast-api:1.0

    docker tag my-fastapi-app:1.0 jayanth00003/my-fastapi-app:1.0
  • Log in to Docker Hub

    docker login
  • Push my-fast-api:1.0 image to your Docker Hub account

    docker push jayanth00003/my-fastapi-app:1.0

Deploying Applications in Kubernetes

  • Creating a Deployment

    • Create a simple fastapi deployment:
      kubectl create deployment fastapi --image=jayanth00003/my-fastapi-app:1.0
    • View the deployment and pods:
      kubectl get deployments
      kubectl get pods
  • Exposing the Deployment

    • Expose fastapi deployment as a service:

      kubectl expose deployment fastapi --type=NodePort --port=8000
    • Get the service details:

      kubectl get services
    • Access the fastapi service using Minikube:

      minikube service fastapi
    • Forward the port:

      kubectl port-forward service/fastapi 7080:8000

Scaling and Updating Applications

  • Scaling the Deployment
    • Scale fastapi deployment to 3 replicas:
      kubectl scale deployment fastapi --replicas=3
    • Verify the scaling:
      kubectl get pods
  • Updating the Deployment
    • Update the fastapi image version:
      kubectl set image deployment/fastapi my-fastapi-app=jayanth00003/my-fastapi-app:2.0
    • Verify the update:
      kubectl rollout status deployment/fastapi
    • Check the pod versions:
      kubectl get pods -o wide
  • Manage your cluster
    • Pause Kubernetes:
      minikube pause
    • Unpause a paused instance:
      minikube unpause
    • Halt the cluster:
      minikube stop
    • Start the cluster:
      minikube start
    • Delete all of the minikube clusters:
      minikube delete --all