https://github.com/kubesphere/logsidecar-injector
A MutatingAdmissionWebhook that adds a sidecar to your pod. This sidecar is just for forwarding file log on the volume.
https://github.com/kubesphere/logsidecar-injector
Last synced: 2 months ago
JSON representation
A MutatingAdmissionWebhook that adds a sidecar to your pod. This sidecar is just for forwarding file log on the volume.
- Host: GitHub
- URL: https://github.com/kubesphere/logsidecar-injector
- Owner: kubesphere
- License: apache-2.0
- Created: 2019-08-20T03:22:49.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2024-01-29T12:33:21.000Z (over 1 year ago)
- Last Synced: 2024-04-13T21:43:10.614Z (about 1 year ago)
- Language: Go
- Size: 103 KB
- Stars: 25
- Watchers: 5
- Forks: 11
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Logsidecar-injector
Logsidecar-injector is a Kubernetes mutating webhook server that adds a sidecar to your pod. This sidecar is just to forward logs from files on volumes to stdout.
# Install
To quickly install the logsidecar injector inside a cluster, just run the following command:
```bash
kubectl apply -f https://raw.githubusercontent.com/kubesphere/logsidecar-injector/master/config/bundle.yaml
```
> Note: it is default to install into the namespace `kubesphere-logging-system`# Usage
Suppose you want to inject the log sidecar into your workloads in the namespace `default`:- Firstly add a label to the namespace:
```bash
kubectl label ns default logging.kubesphere.io/logsidecar-injection=enabled
```- Then add an annotation to pod template of your workload:
```yaml
spec:
template:
metadata:
annotations:
logging.kubesphere.io/logsidecar-config: 'VALUE'
```
> Note: the `VALUE` is a json string which has format as follows:
> ```json
> {
> "containerLogConfigs": {
> "$containername": {
> "$volumename": [
> "$relativepath"
> ]
> }
> }
> }
> ```
> `relativepath` is relative path to mountpath within container `containername` at which volume `volumename` was mounted.- Optionally customize your configuration of filebeat in sidecar container:
Add `logging.kubesphere.io/logsidecar-filebeat-config-jsonpatch` annotation to pod template of your workload. The value of this annotation is a [jsonpatch](http://jsonpatch.com/) string. Logsidecar-injector will generate a new configuration based on default filebeat configuration and this patch, then apply it to the injected sidecar container for your specified workload pod. Here is an example:
```yaml
spec:
template:
metadata:
annotations:
logging.kubesphere.io/logsidecar-filebeat-config-jsonpatch: '[{"op":"replace","path":"/filebeat.inputs/0/tail_file","value":true}]'
```