Nov 4, 11:29

initContainer and rabbit mq checks in k8s pod

Sometimes you need to implement ordered loading for the pods. Say, launch rabbit mq container first, than your app container. This could be done using initContainer concept.

Put this into values.yaml of your helm chart definition

rabbit:
  host: rabbit

and this to the app deployment.yaml definition

initContainers:
        - name: check-rabbit-ready
          image: public.ecr.aws/runecast/busybox:1.33.1
          command: ['sh', '-c', 'until nc -vz {{ .Values.rabbit.host }} 5672; do echo "Waiting for rabbit service"; sleep 2; done;']
Share