so we have two containers running in a pod.. the idea is to have main container doing the job( receiving request) and a secondary container doing a background task of constantly checking the main app network status
i have my deployment file with the secondary container coming up first and then the main container coming after, please check code snippet below https://gist.github.com/dapseen/51bc7e59b96d934938a4afce34c615bb Is it because of the placement of container i.e fund worker coming starting up first that makes it the main app and other container coming up after makes it secondary container.
Is there a special annotation in k8 that can tell cluster or kubernetes the container to make side car?
Question rephrased...
how can i specify that a container should be sidecar
UPDATE
The question came as a result of things i saw in rancher, i am using rancher for Kubernetes management, please check image below
I think rancher takes the first container as the main app and the second to be sidecar.. i cant find documentation to support it . rancher version: 2.2.3
So i later figured this out, unfortunately rancher doc did not explain this..
I clearly understood that sidecar is a design pattern and you clearly gave it a name in your head, it doesnt have anything to do with kubernetes. Initially i was looking for a label or special annotation to label sidecar so rancher UI can pick it up and i can make my changes to it.
I resolve to re-arranging my deployment file and make my main app to be deployed first before the sidecar. I think order is important in selecting sidecar for rancher UI.
Take a look at the image below.
Conclusion, order is important in choosing sidecar in rancher UI
Thanks
Side car is just a design pattern that is upto you to implement. Kubernetes supports the side car pattern but does not implement it for you. Hence there is no option to inform kubernetes to treat a container as the side car.