Skip to content
Init container used to quickly check your service dependencies
Makefile Shell Dockerfile
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
Dockerfile
LICENSE
Makefile
README.md
package.json
precheck.sh

README.md

service-precheck

Simple init container that ensures upstream services are ready before starting the primary container of a pod. This implementation is largely based on Alibaba's blog post on how to solve service dependencies in Kubernetes.

Alibaba Cloud's Blog Post

In order to use this container to precheck services, your upstream systems should have liveness and readiness probes configured.

Status

GitHub Image Layers Image Version

Getting Started

Try out the container using a quick docker run command:

$ docker run -it --rm mjpitz/service-precheck google.com amazon.com
[google.com] checking for a dns entry
Server:		192.168.65.1
Address:	192.168.65.1#53

Non-authoritative answer:
Name:	google.com
Address: 172.217.9.142

[amazon.com] checking for a dns entry
Server:		192.168.65.1
Address:	192.168.65.1#53

Non-authoritative answer:
Name:	amazon.com
Address: 176.32.103.205
Name:	amazon.com
Address: 176.32.98.166
Name:	amazon.com
Address: 205.251.242.103

Or try it within a Kubernetes cluster:

$ kubectl run -it --restart=Never --image mjpitz/service-precheck precheck -- kubernetes google.com amazon.com
$ kubectl logs -f precheck
[kubernetes] checking for a dns entry
Server:		10.43.0.10
Address:	10.43.0.10#53

Name:	kubernetes.default.svc.cluster.local
Address: 10.43.0.1

[google.com] checking for a dns entry
Server:		10.43.0.10
Address:	10.43.0.10#53

Non-authoritative answer:
Name:	google.com
Address: 216.58.194.78

[amazon.com] checking for a dns entry
Server:		10.43.0.10
Address:	10.43.0.10#53

Non-authoritative answer:
Name:	amazon.com
Address: 205.251.242.103
Name:	amazon.com
Address: 176.32.103.205
Name:	amazon.com
Address: 176.32.98.166
$ kubectl delete pod precheck

Once you've tried it out, you can add it to your deployment configuration:

    spec:
      initContainers:
      - name: service-precheck
        image: mjpitz/service-precheck:latest
        imagePullPolicy: IfNotPresent
        args:
        - "kubernetes"
        - "google.com"
        - "amazon.com"

More to come later.

You can’t perform that action at this time.