Followers

Kubernetes - Side Car Container

  Side Car Container (In a multi-container Pod) It is a helper container for the primary container (the container that runs the application)...

 Side Car Container (In a multi-container Pod)

It is a helper container for the primary container (the container that runs the application) in a Pod.

It is not a part of the main traffic or API of main functionality.

It is usually running asynchronously.

Common use cases are logging, monitoring, synchronization of files, etc.

Example

Access logs from logfile in main container using sidecar

In this example we will set up the multi-container pod, wherein one of the pods will contain the primary application while the second pod would contain a sidecar container. The main application will write the logs into a log file, and the sidecar container will continuously read this log file and send the output to STDOUT. Now you may configure some logging agent to send these logs to a central log server.

Following YAML file will create a multi-container Pod:

[root@controller ~]# cat example-1.yaml

  - name: sidecar
    image: busybox
    args:
     - /bin/sh
     - -c
     - tail -fn+1 /var/log/myapp.log
    volumeMounts:
    - name: log
      mountPath: /var/log

Let us create this Pod:

[root@controller ~]# kubectl create -f example-1.yaml
pod/sidecar-pod-1 created

Check if both the containers of our pod have started:

[root@controller ~]# kubectl get pods
NAME            READY   STATUS    RESTARTS   AGE
sidecar-pod-1   2/2     Running   0          54s

Now we can verify that the logs written to our primary container i.e. application is being read by our sidecar container:
Kubernetes sidecar container usage & examples


COMMENTS

Name

Ansible,6,AWS,1,Azure DevOps,1,Containerization with docker,2,DevOps,2,Docker Quiz,1,Docker Swarm,1,DockerCompose,1,ELK,2,git,2,Jira,1,Kubernetes,1,Kubernetes Quiz,5,SAST DAST Security Testing,1,SonarQube,3,Splunk,2,vagrant kubernetes,1,YAML Basics,1,
ltr
item
DevOpsWorld: Kubernetes - Side Car Container
Kubernetes - Side Car Container
https://www.golinuxcloud.com/wp-content/uploads/1235.jpg
DevOpsWorld
https://www.devopsworld.co.in/2022/09/kubernetes-side-car-container.html
https://www.devopsworld.co.in/
https://www.devopsworld.co.in/
https://www.devopsworld.co.in/2022/09/kubernetes-side-car-container.html
true
5997357714110665304
UTF-8
Loaded All Posts Not found any posts VIEW ALL Readmore Reply Cancel reply Delete By Home PAGES POSTS View All RECOMMENDED FOR YOU LABEL ARCHIVE SEARCH ALL POSTS Not found any post match with your request Back Home Sunday Monday Tuesday Wednesday Thursday Friday Saturday Sun Mon Tue Wed Thu Fri Sat January February March April May June July August September October November December Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec just now 1 minute ago $$1$$ minutes ago 1 hour ago $$1$$ hours ago Yesterday $$1$$ days ago $$1$$ weeks ago more than 5 weeks ago Followers Follow THIS PREMIUM CONTENT IS LOCKED STEP 1: Share to a social network STEP 2: Click the link on your social network Copy All Code Select All Code All codes were copied to your clipboard Can not copy the codes / texts, please press [CTRL]+[C] (or CMD+C with Mac) to copy Table of Content