Skip to content
This repository has been archived by the owner on Aug 31, 2022. It is now read-only.

helm chart and udp sink added #112

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,16 @@ receivers:
timeout_seconds:
```

# Udp

It could be used to send json logs to logstash
```yaml
receivers:
- name: "my-udp"
udp:
host:
```

# Pipe

pipe output directly into some file descriptor
Expand Down Expand Up @@ -431,3 +441,8 @@ receivers:
object: "{{ .Namespace }}"

```

### Planned Receivers

- Splunk
- Redis
4 changes: 4 additions & 0 deletions config.example.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ route:
# This route allows dumping all events because it has no fields to match and no drop rules.
- match:
- receiver: "dump"
- receiver: "syslog"
# This starts another route, drops all the events in *test* namespaces and Normal events
# for capturing critical events
- drop:
Expand All @@ -27,6 +28,9 @@ receivers:
hosts:
- "http://localhost:9200"
indexFormat: "kube-events-{2006-01-02}"
- name: "syslog"
udp:
host: "localhost:514"
- name: "alert"
opsgenie:
apiKey: ""
Expand Down
23 changes: 23 additions & 0 deletions deploy/kubernetes-event-exporter/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*.orig
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/
24 changes: 24 additions & 0 deletions deploy/kubernetes-event-exporter/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
apiVersion: v2
name: kubernetes-event-exporter
description: A Helm chart for Kubernetes

# A chart can be either an 'application' or a 'library' chart.
#
# Application charts are a collection of templates that can be packaged into versioned archives
# to be deployed.
#
# Library charts provide useful utilities or functions for the chart developer. They're included as
# a dependency of application charts to inject those utilities and functions into the rendering
# pipeline. Library charts do not define any templates and therefore cannot be deployed.
type: application

# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.1.0

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
# It is recommended to use it with quotes.
appVersion: "1.16.0"
1 change: 1 addition & 0 deletions deploy/kubernetes-event-exporter/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Event exporter is running!
17 changes: 17 additions & 0 deletions deploy/kubernetes-event-exporter/templates/_config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{{- define "config.yaml"}}
{{- if .Values.configOverride }}
{{- toYaml .Values.configOverride }}
{{- else }}
logLevel: {{ .Values.config.log.level}}
logFormat: {{ .Values.config.log.format}}
route:
routes:
{{- range .Values.config.routes }}
- {{- toYaml . | nindent 6}}
{{- end }}
receivers:
{{- range .Values.config.receivers }}
- {{- toYaml . | nindent 6}}
{{- end }}
{{- end }}
{{- end }}
62 changes: 62 additions & 0 deletions deploy/kubernetes-event-exporter/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "kubernetes-event-exporter.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Create a default fully qualified app name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
If release name contains chart name it will be used as a full name.
*/}}
{{- define "kubernetes-event-exporter.fullname" -}}
{{- if .Values.fullnameOverride }}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- $name := default .Chart.Name .Values.nameOverride }}
{{- if contains $name .Release.Name }}
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
{{- end }}
{{- end }}
{{- end }}

{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "kubernetes-event-exporter.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Common labels
*/}}
{{- define "kubernetes-event-exporter.labels" -}}
helm.sh/chart: {{ include "kubernetes-event-exporter.chart" . }}
{{ include "kubernetes-event-exporter.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}

{{/*
Selector labels
*/}}
{{- define "kubernetes-event-exporter.selectorLabels" -}}
app.kubernetes.io/name: {{ include "kubernetes-event-exporter.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}

{{/*
Create the name of the service account to use
*/}}
{{- define "kubernetes-event-exporter.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "kubernetes-event-exporter.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}
7 changes: 7 additions & 0 deletions deploy/kubernetes-event-exporter/templates/configmap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: event-exporter-cfg
data:
config.yaml: |
{{ include "config.yaml" . | indent 4}}
56 changes: 56 additions & 0 deletions deploy/kubernetes-event-exporter/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "kubernetes-event-exporter.fullname" . }}
labels:
{{- include "kubernetes-event-exporter.labels" . | nindent 4 }}
spec:
replicas: {{ .Values.replicaCount }}
selector:
matchLabels:
{{- include "kubernetes-event-exporter.selectorLabels" . | nindent 6 }}
template:
metadata:
{{- with .Values.podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "kubernetes-event-exporter.selectorLabels" . | nindent 8 }}
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
serviceAccountName: {{ include "kubernetes-event-exporter.serviceAccountName" . }}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
containers:
- name: {{ .Chart.Name }}
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
args:
- -conf=/data/config.yaml
volumeMounts:
- mountPath: /data
name: cfg
resources:
{{- toYaml .Values.resources | nindent 12 }}
volumes:
- name: cfg
configMap:
name: event-exporter-cfg
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
11 changes: 11 additions & 0 deletions deploy/kubernetes-event-exporter/templates/rbac.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: {{ include "kubernetes-event-exporter.serviceAccountName" . }}
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: view
subjects:
- kind: ServiceAccount
name: {{ include "kubernetes-event-exporter.serviceAccountName" . }}
12 changes: 12 additions & 0 deletions deploy/kubernetes-event-exporter/templates/serviceaccount.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{{- if .Values.serviceAccount.create -}}
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ include "kubernetes-event-exporter.serviceAccountName" . }}
labels:
{{- include "kubernetes-event-exporter.labels" . | nindent 4 }}
{{- with .Values.serviceAccount.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
{{- end }}
67 changes: 67 additions & 0 deletions deploy/kubernetes-event-exporter/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# Default values for kubernetes-event-exporter.
# This is a YAML-formatted file.
# Declare variables to be passed into your templates.

replicaCount: 1

image:
repository: opsgenie/kubernetes-event-exporter
pullPolicy: IfNotPresent
# Overrides the image tag whose default is the chart appVersion.
tag: "0.9"

imagePullSecrets: []
nameOverride: ""
fullnameOverride: ""

serviceAccount:
# Specifies whether a service account should be created
create: true
# Annotations to add to the service account
annotations: {}
# The name of the service account to use.
# If not set and create is true, a name is generated using the fullname template
name: ""

podAnnotations: {}

podSecurityContext: {}
# fsGroup: 2000

securityContext: {}
# capabilities:
# drop:
# - ALL
# readOnlyRootFilesystem: true
# runAsNonRoot: true
# runAsUser: 1000

resources: {}
# We usually recommend not to specify default resources and to leave this as a conscious
# choice for the user. This also increases chances charts run on environments with little
# resources, such as Minikube. If you do want to specify resources, uncomment the following
# lines, adjust them as necessary, and remove the curly braces after 'resources:'.
# limits:
# cpu: 100m
# memory: 128Mi
# requests:
# cpu: 100m
# memory: 128Mi

nodeSelector: {}

tolerations: []

affinity: {}

config:
log:
level: error
format: json
routes:
- match:
- receiver: "dump"
receivers:
- name: "dump"
file:
path: "/dev/stdout"
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ module github.com/opsgenie/kubernetes-event-exporter
go 1.17

require (
cloud.google.com/go v0.60.0 // indirect
cloud.google.com/go/bigquery v1.9.0
cloud.google.com/go/pubsub v1.3.1
github.com/Masterminds/sprig v2.22.0+incompatible
Expand Down
8 changes: 7 additions & 1 deletion pkg/sinks/receiver.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ type ReceiverConfig struct {
Opscenter *OpsCenterConfig `yaml:"opscenter"`
Teams *TeamsConfig `yaml:"teams"`
BigQuery *BigQueryConfig `yaml:"bigquery"`
Udp *UDPConfig `yaml:"udp"`
=======
EventBridge *EventBridgeConfig `yaml:"eventbridge"`
Pipe *PipeConfig `yaml:"pipe"`
}
Expand Down Expand Up @@ -108,7 +110,11 @@ func (r *ReceiverConfig) GetSink() (Sink, error) {
return NewBigQuerySink(r.BigQuery)
}

if r.EventBridge != nil {
if r.Udp != nil{
return NewUDPClient(r.Udp)
}

if r.EventBridge != nil {
return NewEventBridgeSink(r.EventBridge)
}

Expand Down
Loading