Skip to content

Commit 6b47d58

Browse files
author
jorikvdwerf
authored
[charts/nri-kube-events] imported (#33)
* [charts/nri-kube-events] imported nri-kube-events from nri-bundle * [charts/nri-kube-events] added maintainer + home to Chart.yaml, added CI test values * [charts/nri-kube-events] CI test
1 parent c302ebc commit 6b47d58

12 files changed

+431
-0
lines changed

charts/nri-kube-events/Chart.yaml

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
apiVersion: v1
2+
appVersion: 1.1.0
3+
description: A Helm chart to deploy the New Relic Kube Events
4+
name: nri-kube-events
5+
version: 1.0.0
6+
engine: gotpl
7+
home: https://docs.newrelic.com/docs/integrations/kubernetes-integration/kubernetes-events/install-kubernetes-events-integration
8+
icon: https://newrelic.com/assets/newrelic/source/NewRelic-logo-square.svg
9+
keywords:
10+
- events
11+
- newrelic
12+
- monitoring
13+
maintainers:
14+
- name: douglascamata
15+
- name: jorikvdwerf

charts/nri-kube-events/README.md

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# nri-kube-events
2+
3+
## Chart Details
4+
5+
This chart will deploy the New Relic Events Routers as a Deployment.
6+
7+
## Configuration
8+
9+
| Parameter | Description | Default |
10+
|------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------|
11+
| `global.cluster` - `cluster` | The cluster name for the Kubernetes cluster. | |
12+
| `global.licenseKey` - `licenseKey` | The [license key](https://docs.newrelic.com/docs/accounts/install-new-relic/account-setup/license-key) for your New Relic Account. This will be preferred configuration option if both `licenseKey` and `customSecret` are specified. | |
13+
| `global.customSecretName` - `customSecretName` | Name of the Secret object where the license key is stored | |
14+
| `global.customSecretLicenseKey` - `customSecretLicenseKey` | Key in the Secret object where the license key is stored. | |
15+
| `agentHTTPTimeout` | The timeout for the events-router to reach the infra-agent | `30s` |
16+
| `sinks.stdout` | When enabled all routed events are also logged. | `false` |
17+
| `nameOverride` | The name that should be used for the deployment. | |
18+
| `image.kubeEvents.repository` | The events-router image name. | `newrelic/nri-kube-events` |
19+
| `image.kubeEvents.tag` | The events-router image tag. | `1.1.0` |
20+
| `image.infraAgent.repository` | The infra-agent image name. | `newrelic/k8s-events-forwarder` |
21+
| `image.infraAgent.tag` | The infra-agent image tag. | `1.11.24` |
22+
| `resources` | A yaml defining the resources for the events-router container. | {} |
23+
| `rbac.create` | Enable Role-based authentication | `true` |
24+
| `serviveAccount.create` | If true, a service account would be created and assigned to the deployment | true |
25+
| `serviveAccount.name` | The service account to assign to the deployment. If `serviveAccount.create` is true then this name will be used when creating the service account | |
26+
| `nodeSelector` | Node label to use for scheduling | `{}` |
27+
| `tolerations` | List of node taints to tolerate (requires Kubernetes >= 1.6) | `[]` |
28+
| `affinity` | Node affinity to use for scheduling | `{}` |
29+
30+
## Example
31+
32+
Make sure you have [added the New Relic chart repository.](../../README.md#installing-charts)
33+
34+
Then, to install this chart, run the following command:
35+
36+
```sh
37+
helm install newrelic/nri-kube-events \
38+
--set licenseKey=<enter_new_relic_license_key> \
39+
--set cluster=my-k8s-cluster
40+
```
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
global:
2+
licenseKey: 1234567890abcdef1234567890abcdef12345678
3+
cluster: test-cluster
4+
5+
sinks:
6+
# Enable the stdout sink to also see all events in the logs.
7+
stdout: true
8+
# The newRelicInfra sink sends all events to New relic.
9+
newRelicInfra: true
+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{{- if (include "nri-kube-events.areValuesValid" .) }}
2+
Your deployment of New Relic Kube Events is complete.
3+
{{- else -}}
4+
##############################################################################
5+
#### ERROR: You did not set a licenseKey and/or cluster name. ####
6+
##############################################################################
7+
8+
This deployment will be incomplete until you get your license key from New Relic.
9+
10+
Then run:
11+
12+
helm upgrade {{ .Release.Name }} \
13+
--set licenseKey=YOUR-KEY-HERE \
14+
--set cluster=YOUR-CLUSTER-NAME \
15+
newrelic/nri-kube-events
16+
{{- end -}}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
{{/* vim: set filetype=mustache: */}}
2+
{{/*
3+
Expand the name of the chart.
4+
*/}}
5+
{{- define "nri-kube-events.name" -}}
6+
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
7+
{{- end -}}
8+
9+
{{/*
10+
Create chart name and version as used by the chart label.
11+
*/}}
12+
{{- define "nri-kube-events.chart" -}}
13+
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
14+
{{- end -}}
15+
16+
{{/*
17+
Create a default fully qualified app name.
18+
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
19+
If release name contains chart name it will be used as a full name.
20+
*/}}
21+
{{- define "nri-kube-events.fullname" -}}
22+
{{- if .Values.fullnameOverride -}}
23+
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}}
24+
{{- else -}}
25+
{{- $name := default .Chart.Name .Values.nameOverride -}}
26+
{{- if contains $name .Release.Name -}}
27+
{{- .Release.Name | trunc 63 | trimSuffix "-" -}}
28+
{{- else -}}
29+
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
30+
{{- end -}}
31+
{{- end -}}
32+
{{- end -}}
33+
34+
{{/*
35+
Common labels
36+
*/}}
37+
{{- define "nri-kube-events.labels" -}}
38+
app: {{ include "nri-kube-events.name" . }}
39+
app.kubernetes.io/name: {{ include "nri-kube-events.name" . }}
40+
helm.sh/chart: {{ include "nri-kube-events.chart" . }}
41+
app.kubernetes.io/instance: {{ .Release.Name }}
42+
{{- if .Chart.AppVersion }}
43+
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
44+
{{- end }}
45+
app.kubernetes.io/managed-by: {{ .Release.Service }}
46+
{{- end -}}
47+
48+
{{/*
49+
Create the name of the service account to use
50+
*/}}
51+
{{- define "nri-kube-events.serviceAccountName" -}}
52+
{{- if .Values.serviceAccount.create -}}
53+
{{ default (include "nri-kube-events.fullname" .) .Values.serviceAccount.name }}
54+
{{- else -}}
55+
{{ default "default" .Values.serviceAccount.name }}
56+
{{- end -}}
57+
{{- end -}}
58+
59+
{{/*
60+
Return the licenseKey
61+
*/}}
62+
{{- define "nri-kube-events.licenseKey" -}}
63+
{{- if .Values.global}}
64+
{{- if .Values.global.licenseKey }}
65+
{{- .Values.global.licenseKey -}}
66+
{{- else -}}
67+
{{- .Values.licenseKey | default "" -}}
68+
{{- end -}}
69+
{{- else -}}
70+
{{- .Values.licenseKey | default "" -}}
71+
{{- end -}}
72+
{{- end -}}
73+
74+
{{/*
75+
Return the cluster
76+
*/}}
77+
{{- define "nri-kube-events.cluster" -}}
78+
{{- if .Values.global -}}
79+
{{- if .Values.global.cluster -}}
80+
{{- .Values.global.cluster -}}
81+
{{- else -}}
82+
{{- .Values.cluster | default "" -}}
83+
{{- end -}}
84+
{{- else -}}
85+
{{- .Values.cluster | default "" -}}
86+
{{- end -}}
87+
{{- end -}}
88+
89+
{{/*
90+
Return the customSecretName
91+
*/}}
92+
{{- define "nri-kube-events.customSecretName" -}}
93+
{{- if .Values.global }}
94+
{{- if .Values.global.customSecretName }}
95+
{{- .Values.global.customSecretName -}}
96+
{{- else -}}
97+
{{- .Values.customSecretName | default "" -}}
98+
{{- end -}}
99+
{{- else -}}
100+
{{- .Values.customSecretName | default "" -}}
101+
{{- end -}}
102+
{{- end -}}
103+
104+
{{/*
105+
Return the customSecretLicenseKey
106+
*/}}
107+
{{- define "nri-kube-events.customSecretLicenseKey" -}}
108+
{{- if .Values.global }}
109+
{{- if .Values.global.customSecretLicenseKey }}
110+
{{- .Values.global.customSecretLicenseKey -}}
111+
{{- else -}}
112+
{{- .Values.customSecretLicenseKey | default "" -}}
113+
{{- end -}}
114+
{{- else -}}
115+
{{- .Values.customSecretLicenseKey | default "" -}}
116+
{{- end -}}
117+
{{- end -}}
118+
119+
{{/*
120+
Returns if the template should render, it checks if the required values
121+
licenseKey and cluster are set.
122+
*/}}
123+
{{- define "nri-kube-events.areValuesValid" -}}
124+
{{- $cluster := include "nri-kube-events.cluster" . -}}
125+
{{- $licenseKey := include "nri-kube-events.licenseKey" . -}}
126+
{{- $customSecretName := include "nri-kube-events.customSecretName" . -}}
127+
{{- $customSecretLicenseKey := include "nri-kube-events.customSecretLicenseKey" . -}}
128+
{{- and (or $licenseKey (and $customSecretName $customSecretLicenseKey)) $cluster}}
129+
{{- end -}}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{{- if .Values.rbac.create }}
2+
apiVersion: rbac.authorization.k8s.io/v1
3+
kind: ClusterRole
4+
metadata:
5+
labels:
6+
{{ include "nri-kube-events.labels" . | indent 4 }}
7+
name: {{ template "nri-kube-events.fullname" . }}
8+
rules:
9+
- apiGroups: [""]
10+
resources: ["events"]
11+
verbs: ["get", "watch", "list"]
12+
{{- end -}}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{{- if .Values.rbac.create }}
2+
apiVersion: rbac.authorization.k8s.io/v1
3+
kind: ClusterRoleBinding
4+
metadata:
5+
labels:
6+
{{ include "nri-kube-events.labels" . | indent 4 }}
7+
name: {{ template "nri-kube-events.fullname" . }}
8+
roleRef:
9+
apiGroup: rbac.authorization.k8s.io
10+
kind: ClusterRole
11+
name: {{ template "nri-kube-events.fullname" . }}
12+
subjects:
13+
- kind: ServiceAccount
14+
name: {{ template "nri-kube-events.fullname" . }}
15+
namespace: {{ .Release.Namespace }}
16+
{{- end -}}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
apiVersion: v1
2+
kind: ConfigMap
3+
data:
4+
config.yaml: |-
5+
sinks:
6+
{{- if .Values.sinks.stdout }}
7+
- name: stdout
8+
{{- end }}
9+
{{- if .Values.sinks.newRelicInfra}}
10+
- name: newRelicInfra
11+
config:
12+
agentEndpoint: http://localhost:8001/v1/data
13+
clusterName: {{ include "nri-kube-events.cluster" . }}
14+
agentHTTPTimeout: {{ .Values.agentHTTPTimeout }}
15+
{{- end }}
16+
metadata:
17+
name: {{ template "nri-kube-events.fullname" . }}-config
18+
namespace: {{ .Release.Namespace }}
19+
labels:
20+
{{ include "nri-kube-events.labels" . | indent 4 }}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
{{- if (include "nri-kube-events.areValuesValid" .) }}
2+
apiVersion: apps/v1
3+
kind: Deployment
4+
metadata:
5+
name: {{ template "nri-kube-events.fullname" . }}
6+
namespace: {{ .Release.Namespace }}
7+
labels:
8+
{{ include "nri-kube-events.labels" . | indent 4 }}
9+
spec:
10+
replicas: 1
11+
selector:
12+
matchLabels:
13+
app.kubernetes.io/name: {{ template "nri-kube-events.name" . }}
14+
template:
15+
metadata:
16+
labels:
17+
{{ include "nri-kube-events.labels" . | indent 8 }}
18+
spec:
19+
containers:
20+
- name: kube-events
21+
image: {{ .Values.image.kubeEvents.repository }}:{{ .Values.image.kubeEvents.tag }}
22+
{{- if .Values.resources }}
23+
resources:
24+
{{ toYaml .Values.resources | indent 12 }}
25+
{{- end }}
26+
imagePullPolicy: IfNotPresent
27+
args: ["-config", "/app/config/config.yaml", "-loglevel", "debug"]
28+
volumeMounts:
29+
- name: config-volume
30+
mountPath: /app/config
31+
- name: infra-agent
32+
image: {{ .Values.image.infraAgent.repository }}:{{ .Values.image.infraAgent.tag }}
33+
securityContext:
34+
privileged: false
35+
runAsUser: 1000 # nri-kube-events
36+
runAsNonRoot: false
37+
allowPrivilegeEscalation: false
38+
readOnlyRootFilesystem: true
39+
ports:
40+
- containerPort: 8001
41+
env:
42+
- name: NRIA_LICENSE_KEY
43+
valueFrom:
44+
secretKeyRef:
45+
{{- if (include "nri-kube-events.licenseKey" .) }}
46+
name: {{ template "nri-kube-events.fullname" . }}-config
47+
key: licenseKey
48+
{{- else }}
49+
name: {{ include "nri-kube-events.customSecretName" . }}
50+
key: {{ include "nri-kube-events.customSecretLicenseKey" . }}
51+
{{- end }}
52+
volumeMounts:
53+
- mountPath: /var/db/newrelic-infra/data
54+
name: tmpfs-data
55+
- mountPath: /var/db/newrelic-infra/user_data
56+
name: tmpfs-user-data
57+
- mountPath: /tmp
58+
name: tmpfs-tmp
59+
serviceAccountName: {{ template "nri-kube-events.serviceAccountName" . }}
60+
volumes:
61+
- name: config-volume
62+
configMap:
63+
name: {{ template "nri-kube-events.fullname" . }}-config
64+
- name: tmpfs-data
65+
emptyDir: {}
66+
- name: tmpfs-user-data
67+
emptyDir: {}
68+
- name: tmpfs-tmp
69+
emptyDir: {}
70+
{{- if .Values.nodeSelector }}
71+
nodeSelector:
72+
{{ toYaml .Values.nodeSelector | indent 8 }}
73+
{{- end }}
74+
{{- if .Values.tolerations }}
75+
tolerations:
76+
{{ toYaml .Values.tolerations | indent 8 }}
77+
{{- end }}
78+
{{- if .Values.affinity }}
79+
affinity:
80+
{{ toYaml .Values.affinity | indent 8 }}
81+
{{- end }}
82+
{{- end }}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{{- $licenseKey := include "nri-kube-events.licenseKey" . -}}
2+
{{- if $licenseKey }}
3+
apiVersion: v1
4+
kind: Secret
5+
metadata:
6+
name: {{ template "nri-kube-events.fullname" . }}-config
7+
namespace: {{ .Release.Namespace }}
8+
labels:
9+
{{ include "nri-kube-events.labels" . | indent 4 }}
10+
type: Opaque
11+
data:
12+
licenseKey: {{ $licenseKey | b64enc }}
13+
{{- end }}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{{- if .Values.serviceAccount.create }}
2+
apiVersion: v1
3+
kind: ServiceAccount
4+
metadata:
5+
labels:
6+
{{ include "nri-kube-events.labels" . | indent 4 }}
7+
name: {{ template "nri-kube-events.serviceAccountName" . }}
8+
namespace: {{ .Release.Namespace }}
9+
{{- end -}}

0 commit comments

Comments
 (0)