Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/yisaer/sidecar-inject-server
a simple sidecar-inject server in kubernetes
https://github.com/yisaer/sidecar-inject-server
kubernetes mutatingadmissionwebhook sidecar-inject webhook
Last synced: 21 days ago
JSON representation
a simple sidecar-inject server in kubernetes
- Host: GitHub
- URL: https://github.com/yisaer/sidecar-inject-server
- Owner: Yisaer
- License: apache-2.0
- Created: 2019-07-13T09:30:43.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2019-07-13T10:05:33.000Z (over 5 years ago)
- Last Synced: 2024-10-15T23:35:00.907Z (2 months ago)
- Topics: kubernetes, mutatingadmissionwebhook, sidecar-inject, webhook
- Language: Go
- Size: 23.4 KB
- Stars: 0
- Watchers: 1
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# README
Sidecar-Inject is a simple server to inject containers into Pod By `Sidecar` which defined by `CRD`
It's easy to use and also offer container selector ability.
## Prerequisites
Kubernetes 1.9.0 or above with the `admissionregistration.k8s.io/v1beta1` API enabled. Verify that by the following command:
```
kubectl api-versions | grep admissionregistration.k8s.io/v1beta1
```
The result should be:
```
admissionregistration.k8s.io/v1beta1
```In addition, the `MutatingAdmissionWebhook` admission controllers should be added and listed in the correct order in the admission-control flag of kube-apiserver.
## Build Image
`Sidecar-inject` is managed by `go mod`
run `build.sh` to build docker image
## How to Install
you can install sidecar-inject by `Helm`
First install `sidecar-inejct-init`
```yaml
helm install install/helm/sidecar-inject-init --name sidecar-init --namespace sidecar-system
```Then install `sidecar-inject-server`
```yaml
helm install install/helm/sidecar-inject-server --name sidecar-server --namespace sidecar-system --values install/helm/sidecar-inject-server/values.yaml
```## How to test
Label the `namespace` and create a `deployment` to test sidecar-inject-server
```
kubectl label namespace sidecar-system sidecar-injector=enabled
kubectl apply -f example/
```
And Here is the result
```
$ kubectl get sidecar
NAME CREATED AT
test-sidecarset 55m
test-sidecarset-2 55m$ kubectl get pod
NAME READY STATUS RESTARTS AGE
sidecar-server-sidecar-inject-server-6b9dff7dd6-7b5nq 1/1 Running 0 39m
sleep-578649fc85-xcg2r 3/3 Running 0 20s
```## Sidecar
`Sidecar` is defined by `CRD`. It shows which containers developers want to inject Into Pod When they are creating by `containers`
and it also offer the selector condition ability by `selector`Here is one example for `Sidecar`. All Pods will be injected Containers defined in `containers` if their annotations contain `app` key and its value is `sidecar1`
```yaml
apiVersion: yisaer.github.io/v1alpha1
kind: Sidecar
metadata:
name: test-sidecarset
spec:
selector:
matchLabels:
app: sidecar1
containers:
- name: sidecar1
image: centos:7
command: ["sleep", "999d"]
- name: sidecar2
image: centos:7
command: ["sleep", "999d"]
```