How can I add a readiness probe to an extra container ina Pod template?
I have a Jenkins running in Kubernetes. My agents come with an additional Docker-in-Docker (dind) container. I noticed, that jobs, that immediately run some Docker commands sometimes (most of the time) fail. The reason seems to be, that the Docker daemon in the DIND container is not yet started properly. I tested this by adding a waiting period to one of the jobs. After I did that, they ran successfully.
So what I want to do now is delay the readiness of the agent pod until the Docker daemon is started up properly. For that I need a readiness (or startup) probe. on that additional container.
Here’s the config of my agents in the Helm chart for reference:
agent:
image: my-custom-jnlp-image
tag: 1.2.3
customJenkinsLabels: worker
imagePullSecretName: registry-credentials
runAsUser: jenkins
runAsGroup: jenkins
resources:
# ...
showRawYaml: false
workspaceVolume:
type: EmptyDir
memory: false
envVars:
- name: DOCKER_HOST
value: tcp://localhost:2375
nodeSelector: # schedule agents only on labeled nodes
jenkins-agent: "true"
podName: jenkins-worker
# tolerate nodes with taint dedicated=jenkins:NoSchedule or dedicated=jenkins:PreferNoSchedule
yamlTemplate: |-
apiVersion: v1
kind: Pod
spec:
tolerations:
- key: "dedicated"
operator: "Equal"
value: "jenkins"
additionalContainers:
- sideContainerName: dind
image: my-custom-dind-image
tag: 3.2.1
privileged: true
resources:
# ...
Thanks in advance!