kubernetes – Can we read k8 container logs using a sidecar container and without using kubectl?

Background: So we are using third-party software (SASViya) that has multiple deployments, cronjob, stateful sets, and finally the pod templates which is responsible for creating new pods whenever a user requests it. We just get the docker image and details on how to confirm it and run it and other modifications we do based on requirement.

Problem: With this complete setup we are already putting so much load on the kube api-server so it’s a big no for us to use again ‘kubectl logs’ cmd for each deployment or pods. Another problem is that we have no option to make any changes to the 3rd party app to divert its logs to a specified path.

Query: Do we have any option where I can add a sidecar container that is responsible to read the main container logs? Both container will be inside same pod so is it not possible to simply read the main container logs? If it’s possible then I can divert it to a shared location and then push it to splunk. Or maybe the best way to use kubectl logs which will put extremely low load on kube api-server?

Read more here: Source link