Answer the question
In order to leave comments, you need to log in
How to execute a command in a kubernetes container by condition?
The situation is as follows: there are two interconnected services (pods). The first one, when launched, takes the configuration file from the second service via http.
Periodically, the second service is rebuilt with an updated config, and the first service does not "know" anything about updating until it is restarted / recreated (manually or by http request).
After updating the second service, it is necessary to execute one command once, either restart / delete the first service, or http request.
k8s has init containers, but no post-init containers or anything like that. Readiness and livenessprobe are not suitable, because work constantly. I read about job and cronjob, but I'm not sure what will fit. Maybe someone faced a similar problem?
Deployment of services is carried out using gitlab-ci, it has different groups for each service with its own .gitlab-ci.yml
Answer the question
In order to leave comments, you need to log in
myasnik8352
there is still one https://kubernetes.io/docs/concepts/containers/con...
maybe it will come in handy for someone, added a second container with busybox and wget to deployment.yaml
containers:
- name: service2
image: repo.local/service2:latest
ports:
- containerPort: 80
- name: restart-service1
image: busybox
command: ['sh', '-c', 'wget http://service1/restart; echo waiting for restart service1; sleep 2; tail -f /dev/null;']
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question