Reputation: 151
I have a kubernetes manifest file which has 2 containers. Main container is collecting data at a certain time period and other (logstash) container reading logs for the main container and shipping it to the ELK stack. Once the main container completed its job, what is the best way to gracefully signal or shutdown the logstash container?
Upvotes: 1
Views: 4234
Reputation: 5541
Currently, there is no way to explicitly mark a container as "Sidecar" (though there is a long-lasting KEP to implement it).
It means that the best you can do is to define Container Lifecycle Hook with the command to gracefully shutdown your sidecar container. Something like:
containers:
- name: logstash-container
image: logstash-image
- name: your-main-container
image: your-main-container-image
lifecycle:
preStop:
exec:
command: ["/bin/sh", "-c", "gracefully terminate logstash"]done"]
Upvotes: 2