echo container image:tag (URI) in kubernetes readinessProbe or livenessProbe

9/10/2018

I have many versions and tags of containers used by Deployment in k8s (and hence many log groups).
It would be nice if i could display the container URI and tag in a readinessProbe or livenessProbe which then flows to persisted logging.

Basically so that I know my Pod whose logs I am viewing is running on the correct image.

I thought of simply echoing it as a container variable, so i thought of setting the container image URI as a container variable in the Pod manifest.

The docs at k8s EnvVarSource says it only supports certain fields for fieldRef, importantly, it doesn't support grabbing the spec.containers image field.

Anyone has any smart ideas how I might achieve this in other ways?
Or when/if does the kubernetes team support this?

UPDATE:
i found that doing echo under readinessProbe.exec.command works (the Pod is Ready status) but the echo output does not flow to the logs.
Only the application (server) output appear in the logs in my logging backend (CloudWatch).

-- cryanbhu
kubernetes
kubernetes-health-check

0 Answers