Skip to content

A simple kubernetes controller which ensures proper termination of sidecar containers

Notifications You must be signed in to change notification settings

limgit/k8s-sidecar-controller

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

K8S Sidecar Controller

A simple kubernetes controller which ensures proper termination of sidecar containers

Tested on

  • go v1.17
  • Kubernetes 1.19

Usage

  1. Deploy this controller. See How to deploy
  2. Add an annotation to pods which have sidecar containers. Annotation format is limgit/sidecars: <sidecar>,<container>,<name>
# Example pod configuration.
# After `main` container finishes,
# the sidecar controller will send SIGTERM to `sidecar` container
apiVersion: v1
kind: Pod
metadata:
  name: busybox-sleep
  namespace: default
  annotations:
    limgit/sidecars: sidecar
spec:
  containers:
  - name: sidecar
    image: busybox
    args:
    - sleep
    - "1000000"
  - name: main
    image: busybox
    args:
    - sleep
    - "20"
  1. Tada! This controller will clean up sidecar containers if every containers but sidecar containers are completed!

How to deploy

  1. Build docker image with Dockefile
  2. Push docker image to image repository
  3. In deployment.yaml, set correct image tag for Deployment resource
  4. kubectl apply -f deployment.yaml

About

A simple kubernetes controller which ensures proper termination of sidecar containers

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published