DevOps.com

Where the world meets DevOps

  • Latest
    • Articles
    • Features
    • Most Read
    • News
    • News Releases
  • Topics
    • AI
    • Continuous Delivery
    • Continuous Testing
    • Cloud
    • Culture
    • DevSecOps
    • Enterprise DevOps
    • Leadership Suite
    • DevOps Practice
    • ROELBOB
    • DevOps Toolbox
    • IT as Code
  • DevOps Chats
  • Webinars
    • Upcoming
    • On-Demand Webinars
  • Library
  • Events
    • Virtual Summits
    • Conferences
  • Sponsored Communities
    • CloudBees
    • IT as Code
  • Related Sites
    • MediaOps
    • Container Journal
    • Security Boulevard
    • SweetCode.io
    • Digital Anarchist
    • DevOps TV on YouTube
    • DevOps Chat on SoundCloud
    • DevOps Connect
    • DevOps Dozen
  • Media Kit
  • Follow Us
    • Twitter
    • Google News
    • LinkedIn
    • Facebook
    • DevOps TV on YouTube
    • Email
MENUMENU
  • AI
    • AI, machine learning

      A Buyer’s Guide to AI and Machine Learning

      AIOps

      DevOps and AIOps: Better Together

      Datical Liquibase

      IBM Launches Ambitious AIOps Initiative

      Moogsoft

      Moogsoft Expands Reach of AIOps Platform

      AIOps 2020

      AIOps 2020: IT Talent Is the Game-Changer

  • Cloud
    • Cloud native

      Cloud-Native Security and Performance: Two Sides of the Same Coin

      Rubrik

      Rubrik Looks to Meld Data Management and DevOps

      Cloud Native Security

      How to Secure the Intangible — Cloud Native Security in the New Age

      OpenStack Ussuri

      OpenStack Delivers Ussuri Update

      Rubrik

      DevOps as a Service: Migrating Your Entire DevOps Stack to the Cloud

  • Continuous Delivery
    • SDM

      CloudBees Extends SDM Service Reach

      New Relic

      Report Finds Much Room for CD Improvement

      SDM’s Holistic Approach

      How SDM’s Holistic Approach Connects Organizations and Streamlines Delivery Processes

      CD Foundation

      CD Foundation Serves Up Tekton Pipelines Beta

      GitLab Features - Core Open Source Platform

      GitLab Shifts 18 Features Into Core Open Source Platform

  • Continuous Testing
    • Shift-Right Testing - TestOps

      Shift-Right Testing: The Emergence of TestOps

      What Developers Should Take Away from the Iowa Caucus App Debacle

      What Developers Should Take Away from the Iowa Caucus App Debacle

      survey testing

      Survey Sees Little Progress in Drive to Shift Testing Left

      DevOps Software Testing

      DevOps Places Software Testing in the Crosshairs

      testing

      DevOps Chats: Enterprise Continuous Testing With a Shift-Right Mindset

  • DevSecOps
    • GitLab platform

      GitLab Releases Massive Update to CI/CD Platform

      security

      The Best Approach to Help Developers Build Security into the Pipeline

      appsec

      5 Ways to Detect Application Security Vulnerabilities Sooner to Reduce Costs and Risk

      Cloud native

      Cloud-Native Security and Performance: Two Sides of the Same Coin

      Cloud Native Security

      How to Secure the Intangible — Cloud Native Security in the New Age

  • Leadership Suite
    • Enterprise IT teams

      Need for Increased Training — Strained Budgets Strain Enterprise IT Teams

      COVID Impact

      Coronavirus Impact: Enterprises Must Focus on What Works

      IT budgets

      Despite Downturn, Enterprise IT Budgets Remain Intact

      Employment in the Age of Automation

      Metropolis Now: The Two Worlds of Employment in the Age of Automation

      Digital Resiliency Wins

      The Way Forward: Digital Resiliency Wins

  • Practices
    • SlackOps

      CTO.ai Launches SlackOps Tool for DevOps

      GitLab platform

      GitLab Releases Massive Update to CI/CD Platform

      SDM

      CloudBees Extends SDM Service Reach

      DataOps and DevOps

      DataOps and DevOps: A Match Made in Heaven

      Software velocity, continuous improvement

      Increasing Software Velocity While Maintaining Quality and Efficiency

  • ROELBOB
    • growth-v-sustainability

      Growth vs. Sustainability

      domain-driven-develop

      Domain Driven Development

      power-of-math

      The Power of Math

      career-development-in-trying-times

      Career Development in Trying Times

      Existence-n-choice

      Existence and Choice

  • Toolbox
    • SlackOps

      CTO.ai Launches SlackOps Tool for DevOps

      GitLab platform

      GitLab Releases Massive Update to CI/CD Platform

      SDM

      CloudBees Extends SDM Service Reach

      management tools

      5 Reasons Your Legacy IT Management Tools Are Holding You Back

      Datical Liquibase

      Datical Embraces Liquibase Identity

  • IT as Code
  • More Topics
    • Application Performance Management/Monitoring
    • Culture
    • Enterprise DevOps

Home » Blogs » Containers » Decoding the Self-Healing Kubernetes

SDM

Decoding the Self-Healing Kubernetes

Ashish SharmaBy Ashish Sharma on May 12, 2020 Leave a Comment

A business application that fails to operate 24/7 would be considered inefficient in the market. The idea is that applications run uninterrupted, irrespective of a technical glitch, feature update or a natural disaster. In today’s heterogeneous environment where infrastructure is intricately layered, a continuous workflow of application is possible via self-healing.   

Related Posts
  • Decoding the Self-Healing Kubernetes
  • Platform9’s Managed Kubernetes Solution Adds ‘Arbitrage’ Capabilities to Dynamically Run Nodes in a Cluster on Amazon EC2 Spot Instances
  • Portworx and HPE Release New Solution for Rapid Deployment of Containerized Applications on HPE Synergy
    Related Categories
  • Blogs
  • Containers
  • DevOps Practice
  • Doin' DevOps
    Related Topics
  • containers
  • kubernetes
  • liveness probe
  • NGINX
  • self-healing applications
  • self-healing Kubernetes
Show more
Show less

Kubernetes, which is a container orchestration tool, facilitates the smooth working of the application by abstracting machines physically. Moreover, the pods and containers in Kubernetes can self-heal.

In the Avengers movie, Captain America asked Bruce Banner to get angry so he could transform into The Hulk. Bruce replied, “That’s my secret Captain. I’m always angry.” You must have understood the analogy here. Let’s simplify: Kubernetes will self-heal organically, whenever the system is affected. 

Kubernetes’s self-healing property ensures that the clusters always function at the optimal state. Kubernetes can effectively self-detect two types of objects—podstatus and container status. Kubernetes’s orchestration capabilities can monitor and replace unhealthy containers as per the desired configuration. Likewise, Kubernetes can fix pods, which are the smallest units encompassing single or multiple containers. 

The Three Container States Include

  1. Waiting: created but not running. A container, which is in a waiting stage, will still run operations such as pulling images or applying secrets, etc. To check the waiting pod status, use the following command:
    Checking waiting status
    Along with this state, a message and reason about the state are displayed to provide more information.
    Waiting before entering running stage
  2. Running Pods: containers that are running without issues. The following command is executed before the pod enters the running state:
    postStart
    Running pods will display the time of the entrance of the container.
    Time of entrance of the container
  3. Terminated Pods: a container that fails or completes its execution. The following command is executed before the pod is moved to terminated:
    prestop
    Terminated pods will display the time of the entrance of the container.
    Terminated pod - time of entrance

Kubernetes’ Self-Healing Concepts – Pod’s Phase, Probes and Restart Policy

The pod phase in Kubernetes offers insight into the pod’s placement. We can have: 

  • Pending Pods–created but not running.
  • Running Pods–runs all the containers.
  • Succeeded Pods–successfully completed container lifecycle.
  • Failed Pods–minimum one container failed and all containers terminated.
  • Unknown Pods.

Kubernetes execute liveness and readiness probes for the pods to check if they function as per the desired state. The liveness probe will check a container for its running status. If a container fails the probe, Kubernetes will terminate it and create a new container in accordance with the restart policy. The readiness probe will check a container for its service request serving capabilities. If a container fails the probe, then Kubernetes will remove the IP address of the related pod. 

Liveness probe example:

Liveness probe example

The probes include:

  • ExecAction–to execute commands in containers.
  • TCPSocketAction–to implement a TCP check w.r.t to the IP address of a container.
  • HTTPGetAction–to implement a HTTP Get check w.r.t to the IP address of a container.

Each probe gives one of three results:

  • Success: The container passed the diagnostic.
  • Failure: The container failed the diagnostic.
  • Unknown: The diagnostic failed, so no action should be taken.

Demo Description of Self-Healing Kubernetes

We need to set the code replication to trigger the self-healing capability of Kubernetes. 

Let’s see an example of the Nginx file:

Nginx example

In the above code, we see that the total number of pods across the cluster must be four.

Next, let’s deploy the file.

kubectl apply nginx-deployment-sample

Let’s list the pods, using:

kubectl get pods -1 app=nginx

Here is the output:

output_nginx-deployment-test

As you see above, we have created four pods. 

Now, let’s delete one of the pods.

deleting a pod

The pod is now deleted. We get the following output:

pod deleted

Let’s list the pods again.

get pods

We get the following output:

Output: 4 pods

We have four pods again, despite deleting one. Kubernetes has self-healed to create a new node and maintain the count to four.

Conclusion

Kubernetes can self-heal applications and containers, but what about healing itself when the nodes are down? For Kubernetes to continue self-healing, it needs a dedicated set of infrastructure, with access to self-healing nodes all the time. The infrastructure must be driven by automation and powered by predictive analytics to preempt and fix issues beforehand. The bottom line is that at any given point in time, the infrastructure nodes should maintain the required count for uninterrupted services.