Giter Club home page Giter Club logo

k8s-health-check's Introduction

k8s-health-check

This repository provides the small tool check which can change Kubernetes liveness and readiness checks dynamically. This can be helpful when trying to debug a dying pod. First you can mark the pod as unready so no more traffic is routed towards it. Then you can disable the liveness check, so you have all the time you need to attach a debugger without the fear of losing all the valuable runtime information.

Usage

  • check run -type TYPE Run the check for TYPE as follows: If an override is active, directly return the override, otherwise run the command defined in the environment variable TYPE_CHECK (e.g. LIVENESS_CHECK) and return its exit code.
  • check lock -type TYPE -state STATE Set the override for TYPE to STATE.
  • check unlock -type TYPE Deactivate the override for TYPE

TYPE is either liveness or readiness

STATE is either success or failure

Build

If you have Make and Go installed, you should be able to do make build. Verification can be done with make test.

In case you do not want to install Go but you have Docker at hand, you can simply do make docker-build. Check the file permissions of the built artifact afterwards.

Using it in your deployment

Change your k8s deployment YAML such that your probe definition, e.g.

  exec:
  command:
  - cat
  - /tmp/healthy
  initialDelaySeconds: 5
  periodSeconds: 5

becomes

  exec:
    command: [ "check", "run", "-type", "liveness" ]
  initialDelaySeconds: 5
  periodSeconds: 5

and add the following env:

  - name: 'LIVENESS_CHECK'
    value: 'cat /tmp/healthy'

or directly in the Dockerfile: ENV LIVENESS_CHECK "cat /tmp/healthy"

Note that HTTP requests must be converted to using curl, e.g.

      httpGet:
        path: /healthz
        port: 8080
      timeoutSeconds: 1

becomes

  - name: 'LIVENESS_CHECK'
    value: 'curl -m 1 -sf localhost:8080/healthz'

k8s-health-check's People

Contributors

xcq1 avatar foxylion avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.