Skip to content

Promisified TCP-socket based Readiness and Liveness probe endpoints for Kubernettes apps

License

Notifications You must be signed in to change notification settings

EwaRvr/Kubernetes-tcp-readiness-probe

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Kubernetes-tcp-readiness-probe

There is plenty of information available on the internet that indicates that you SHOULD have readiness and liveness probes to monitor the state of your kubernetes pods. However, most code samples available focus on using express, and creating http endpoints. If you don't want to add an express dependency (and the potential additional attack vector on your app), it is fairly easy to use TCP instead. But there is not much information or an (reference) implementation out there exactly how to do that.

This library is to resolve that.

Usage:

const probe = require('./Kubernetes-tcp-readiness-probe');
probe.start()
  .then(()=>{
    //start up your application
  })
  .then(()=>probe.ready());

Alternatively, you can specify your own ports and/or logger. (Note, the valuesdisplayed below are the default values)

const probe = require('./Kubernetes-tcp-readiness-probe');
probe.start({port:7070,logger:console})
  .then(()=>{
    //start up your application
  })
  .then(()=>probe.ready({port:7071,logger:console}));

For completeness, the corresponding yaml could look like:

    readinessProbe:
      tcpSocket:
        port:7071
      initialDelaySeconds: 5
      periodSeconds: 10
      timeoutSeconds: 3
      successThreshold: 1
      failureThreshold: 5
    livenessProbe:
      tcpSocket:
        port:7070
      initialDelaySeconds: 15
      periodSeconds: 20
      timeoutSeconds: 3
      successThreshold: 1
      failureThreshold: 5

About

Promisified TCP-socket based Readiness and Liveness probe endpoints for Kubernettes apps

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published