Container execution checks utility for use with InitContainers/readiness/liveness probes (proposal)
Opened this issue · 0 comments
Handling initialization is typically shown with simple commands such as 'wget' or 'cat' and is rather straightforward.
However, for non trivial conditionals this can get hairy.
A contrived example
Consider an InitContainer that succeeds when a service responds with 3 DNS endpoints.
At first glance it is a simple nslookup servicename -ge 3
one liner. That is until you happen to use an image that doesn't bundle nslookup so you'd getent hosts servicename -ge 3
instead.
Writing bash one liners is suboptimal
- What utilities can one safely rely on for the one-liner munging?
- No sane style guide
- Maintainability
In reality past the simple one liner people should (and do) reach for the scripting language of their choice. However, now you went from a tiny busybox InitContainer to a 300MB container that bundles python to avoid writing a little bash.
The executing checks do belong in the project yaml/json file instead of being baked into some one-off image on the side. Most of these checks for most projects probably fall into two dozen or some common patterns.
So I purpose a utility in the spirit of bc.
apiVersion: v1
kind: Pod
metadata:
name: nginx
annotations:
pod.alpha.kubernetes.io/init-containers: '[
{
"name": "install",
"image": "busybox",
"command": ["k", "service", "name", "at least", "3"]
}
]'
To be written in Go, with a small core, and extensible (so users can add custom checks via a volume).