DevOps Classroom Series – 09/Sept/2021

K8s Pod contd

  • Refer Here for the nginx pod added
  • Now create a pod
kubectl apply -f nginx-pod.yaml
  • Describe and list your pods
kubectl get pods
kubectl describe pods my-first-pod
  • Using Port-Forwarding:

    • Later, in this series we will learn how to expose a service to the world to access your application (right approach)
    • Now lets try use port-forwarding to access the nginx container running inside a pod
    kubectl port-forward my-first-pod 8080:80
    
    • The above command will forward the port on the loopback address and can be accessed from with in the system using “http://localhost:8080`
    • If we need to access the application with port forwarding from external systems
    kubectl port-forward --address 0.0.0.0 my-first-pod 8080:80
    
  • Refer Here for the jenkins pod manifest

  • Now lets add an alpine pod Refer Here

Health Checks

  • When you run your application as a container in k8s it is automatically kep alive for you using a process health check. The health check simply ensures that the main process of your application is always running, If it isn’t K8s restarts it.
  • How ever in most cases a simple process check is insufficient, For example if your process has deadlocked and is unable to server request, process health check will believe that your application is healthy since the process is still running
  • To address this k8s has introduced health checks for application liveness. Liveness health checks run application-specific logic to verify that application is not just still running but working properly
  • Refer Here for the nginx pod with liveness probe
  • Readiness Probe: K8s makes distinction b/w liveness and readiness. Liveness determines if the application is running properly. Containers that fail liveness checks are restarted.
  • Readiness describes when the container is ready to serve user requests. Containers that fail readiness checks are removed from service load balancers.
  • Combining the readiness and liveness probes help ensure only healthy containers are running with in the cluster.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

About learningthoughtsadmin