Skip to content

Commit e1ae3a0

Browse files
author
jorikvdwerf
authored
[charts/nri-prometheus] imported (#36)
* [charts/nri-prometheus] imported chart * [charts/nri-prometheus] added maintainers & home * [charts/nri-prometheus] added test licenseKey
1 parent 6b47d58 commit e1ae3a0

13 files changed

+425
-0
lines changed

charts/nri-prometheus/.helmignore

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Patterns to ignore when building packages.
2+
# This supports shell glob matching, relative path matching, and
3+
# negation (prefixed with !). Only one pattern per line.
4+
.DS_Store
5+
# Common VCS dirs
6+
.git/
7+
.gitignore
8+
.bzr/
9+
.bzrignore
10+
.hg/
11+
.hgignore
12+
.svn/
13+
# Common backup files
14+
*.swp
15+
*.bak
16+
*.tmp
17+
*~
18+
# Various IDEs
19+
.project
20+
.idea/
21+
*.tmproj
22+
.vscode/

charts/nri-prometheus/Chart.yaml

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
apiVersion: v1
2+
appVersion: 1.3.0
3+
description: A Helm chart to deploy the New Relic Prometheus OpenMetrics integration
4+
name: nri-prometheus
5+
version: 1.0.1
6+
engine: gotpl
7+
home: https://github.com/newrelic/nri-prometheus
8+
icon: https://newrelic.com/assets/newrelic/source/NewRelic-logo-square.svg
9+
keywords:
10+
- prometheus
11+
- newrelic
12+
- monitoring
13+
maintainers:
14+
- name: douglascamata
15+
- name: jorikvdwerf

charts/nri-prometheus/README.md

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# New Relic's Prometheus OpenMetrics Integration
2+
3+
## Chart Details
4+
5+
This chart will deploy the New Relic's Prometheus OpenMetrics Integration.
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+
| `nameOverride` | The name that should be used for the deployment. | |
16+
| `image.repository` | The prometheus openmetrics integration image name. | `newrelic/nri-prometheus` |
17+
| `image.tag` | The prometheus openmetrics integration image tag. | `1.3.0` |
18+
| `resources` | A yaml defining the resources for the events-router container. | {} |
19+
| `rbac.create` | Enable Role-based authentication | `true` |
20+
| `serviveAccount.create` | If true, a service account would be created and assigned to the deployment | true |
21+
| `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 | |
22+
| `nodeSelector` | Node label to use for scheduling | `{}` |
23+
| `tolerations` | List of node taints to tolerate (requires Kubernetes >= 1.6) | `[]` |
24+
| `affinity` | Node affinity to use for scheduling | `{}` |
25+
| `prometheusScrape` | true | Value for `prometheus.io/scrape` label |
26+
27+
## Example
28+
29+
30+
Make sure you have [added the New Relic chart repository.](../../README.md#installing-charts)
31+
32+
Then, to install this chart, run the following command:
33+
34+
```sh
35+
helm install newrelic/nri-prometheus \
36+
--set licenseKey=<enter_new_relic_license_key> \
37+
--set cluster=my-k8s-cluster
38+
```
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
global:
2+
licenseKey: 1234567890abcdef1234567890abcdef12345678
3+
cluster: test-cluster
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{{- if (include "nri-prometheus.areValuesValid" .) }}
2+
Your deployment of the New Relic Prometheus scraper is complete.
3+
{{- else -}}
4+
##############################################################################
5+
#### ERROR: You did not set a licenseKey and/or cluster name. ####
6+
##############################################################################
7+
{{- end -}}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
{{/* vim: set filetype=mustache: */}}
2+
{{/*
3+
Expand the name of the chart.
4+
*/}}
5+
{{- define "nri-prometheus.name" -}}
6+
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
7+
{{- end -}}
8+
9+
{{/*
10+
Create a default fully qualified app name.
11+
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
12+
If release name contains chart name it will be used as a full name.
13+
*/}}
14+
{{- define "nri-prometheus.fullname" -}}
15+
{{- if .Values.fullnameOverride -}}
16+
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}}
17+
{{- else -}}
18+
{{- $name := default .Chart.Name .Values.nameOverride -}}
19+
{{- if contains $name .Release.Name -}}
20+
{{- .Release.Name | trunc 63 | trimSuffix "-" -}}
21+
{{- else -}}
22+
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
23+
{{- end -}}
24+
{{- end -}}
25+
{{- end -}}
26+
27+
{{/*
28+
Create chart name and version as used by the chart label.
29+
*/}}
30+
{{- define "nri-prometheus.chart" -}}
31+
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
32+
{{- end -}}
33+
34+
{{/*
35+
Common labels
36+
*/}}
37+
{{- define "nri-prometheus.labels" -}}
38+
app.kubernetes.io/name: {{ include "nri-prometheus.name" . }}
39+
helm.sh/chart: {{ include "nri-prometheus.chart" . }}
40+
app.kubernetes.io/instance: {{ .Release.Name }}
41+
{{- if .Chart.AppVersion }}
42+
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
43+
{{- end }}
44+
app.kubernetes.io/managed-by: {{ .Release.Service }}
45+
{{- end -}}
46+
47+
{{/*
48+
Create the name of the service account to use
49+
*/}}
50+
{{- define "nri-prometheus.serviceAccountName" -}}
51+
{{- if .Values.serviceAccount.create -}}
52+
{{ default (include "nri-prometheus.name" .) .Values.serviceAccount.name }}
53+
{{- else -}}
54+
{{ default "default" .Values.serviceAccount.name }}
55+
{{- end -}}
56+
{{- end -}}
57+
58+
{{/*
59+
Return the licenseKey
60+
*/}}
61+
{{- define "nri-prometheus.licenseKey" -}}
62+
{{- if .Values.global}}
63+
{{- if .Values.global.licenseKey }}
64+
{{- .Values.global.licenseKey -}}
65+
{{- else -}}
66+
{{- .Values.licenseKey | default "" -}}
67+
{{- end -}}
68+
{{- else -}}
69+
{{- .Values.licenseKey | default "" -}}
70+
{{- end -}}
71+
{{- end -}}
72+
73+
{{/*
74+
Return the cluster
75+
*/}}
76+
{{- define "nri-prometheus.cluster" -}}
77+
{{- if .Values.global -}}
78+
{{- if .Values.global.cluster -}}
79+
{{- .Values.global.cluster -}}
80+
{{- else -}}
81+
{{- .Values.cluster | default "" -}}
82+
{{- end -}}
83+
{{- else -}}
84+
{{- .Values.cluster | default "" -}}
85+
{{- end -}}
86+
{{- end -}}
87+
88+
{{/*
89+
Return the customSecretName
90+
*/}}
91+
{{- define "nri-prometheus.customSecretName" -}}
92+
{{- if .Values.global }}
93+
{{- if .Values.global.customSecretName }}
94+
{{- .Values.global.customSecretName -}}
95+
{{- else -}}
96+
{{- .Values.customSecretName | default "" -}}
97+
{{- end -}}
98+
{{- else -}}
99+
{{- .Values.customSecretName | default "" -}}
100+
{{- end -}}
101+
{{- end -}}
102+
103+
{{/*
104+
Return the customSecretLicenseKey
105+
*/}}
106+
{{- define "nri-prometheus.customSecretLicenseKey" -}}
107+
{{- if .Values.global }}
108+
{{- if .Values.global.customSecretLicenseKey }}
109+
{{- .Values.global.customSecretLicenseKey -}}
110+
{{- else -}}
111+
{{- .Values.customSecretLicenseKey | default "" -}}
112+
{{- end -}}
113+
{{- else -}}
114+
{{- .Values.customSecretLicenseKey | default "" -}}
115+
{{- end -}}
116+
{{- end -}}
117+
118+
{{/*
119+
Returns if the template should render, it checks if the required values
120+
licenseKey and cluster are set.
121+
*/}}
122+
{{- define "nri-prometheus.areValuesValid" -}}
123+
{{- $cluster := include "nri-prometheus.cluster" . -}}
124+
{{- $licenseKey := include "nri-prometheus.licenseKey" . -}}
125+
{{- $customSecretName := include "nri-prometheus.customSecretName" . -}}
126+
{{- $customSecretLicenseKey := include "nri-prometheus.customSecretLicenseKey" . -}}
127+
{{- and (or $licenseKey (and $customSecretName $customSecretLicenseKey)) $cluster}}
128+
{{- end -}}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{{- if .Values.rbac.create }}
2+
apiVersion: rbac.authorization.k8s.io/v1
3+
kind: ClusterRole
4+
metadata:
5+
name: {{ template "nri-prometheus.fullname" . }}
6+
labels:
7+
{{ include "nri-prometheus.labels" . | indent 4 }}
8+
rules:
9+
- apiGroups: [""]
10+
resources:
11+
- "nodes"
12+
- "nodes/metrics"
13+
- "nodes/stats"
14+
- "nodes/proxy"
15+
- "pods"
16+
- "services"
17+
verbs: ["get", "list", "watch"]
18+
- nonResourceURLs:
19+
- /metrics
20+
verbs:
21+
- get
22+
{{- 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+
name: {{ template "nri-prometheus.fullname" . }}
6+
labels:
7+
{{ include "nri-prometheus.labels" . | indent 4 }}
8+
roleRef:
9+
apiGroup: rbac.authorization.k8s.io
10+
kind: ClusterRole
11+
name: {{ template "nri-prometheus.fullname" . }}
12+
subjects:
13+
- kind: ServiceAccount
14+
name: {{ template "nri-prometheus.serviceAccountName" . }}
15+
namespace: {{ .Release.Namespace }}
16+
{{- end -}}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
kind: ConfigMap
2+
metadata:
3+
name: {{ template "nri-prometheus.fullname" . }}-config
4+
namespace: {{ .Release.Namespace }}
5+
labels:
6+
{{ include "nri-prometheus.labels" . | indent 4 }}
7+
apiVersion: v1
8+
data:
9+
config.yaml: |
10+
cluster_name: {{ include "nri-prometheus.cluster" . }}
11+
{{- if .Values.config }}
12+
{{ toYaml .Values.config | indent 4 -}}
13+
{{ end }}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
{{- if (include "nri-prometheus.areValuesValid" .) }}
2+
apiVersion: apps/v1
3+
kind: Deployment
4+
metadata:
5+
name: {{ template "nri-prometheus.fullname" . }}
6+
namespace: {{ .Release.Namespace }}
7+
labels:
8+
{{ include "nri-prometheus.labels" . | indent 4 }}
9+
spec:
10+
replicas: 1
11+
selector:
12+
matchLabels:
13+
app.kubernetes.io/name: {{ include "nri-prometheus.name" . }}
14+
template:
15+
metadata:
16+
labels:
17+
{{ include "nri-prometheus.labels" . | indent 8 }}
18+
spec:
19+
serviceAccountName: {{ template "nri-prometheus.serviceAccountName" . }}
20+
containers:
21+
- name: nri-prometheus
22+
image: {{ .Values.image.repository }}:{{ .Values.image.tag }}
23+
args:
24+
- "--configfile=/etc/nri-prometheus/config.yaml"
25+
ports:
26+
- containerPort: 8080
27+
volumeMounts:
28+
- name: config-volume
29+
mountPath: /etc/nri-prometheus/
30+
env:
31+
- name: "LICENSE_KEY"
32+
valueFrom:
33+
secretKeyRef:
34+
{{- if (include "nri-prometheus.licenseKey" .) }}
35+
name: {{ template "nri-prometheus.fullname" . }}-config
36+
key: licenseKey
37+
{{- else }}
38+
name: {{ include "nri-prometheus.customSecretName" . }}
39+
key: {{ include "nri-prometheus.customSecretLicenseKey" . }}
40+
{{- end }}
41+
- name: "BEARER_TOKEN_FILE"
42+
value: "/var/run/secrets/kubernetes.io/serviceaccount/token"
43+
- name: "CA_FILE"
44+
value: "/var/run/secrets/kubernetes.io/serviceaccount/ca.crt"
45+
{{- if .Values.resources }}
46+
resources:
47+
{{ toYaml .Values.resources | indent 10 }}
48+
{{- end }}
49+
volumes:
50+
- name: config-volume
51+
configMap:
52+
name: {{ template "nri-prometheus.fullname" . }}-config
53+
{{- if $.Values.nodeSelector }}
54+
nodeSelector:
55+
{{ toYaml $.Values.nodeSelector | indent 8 }}
56+
{{- end }}
57+
{{- if .Values.tolerations }}
58+
tolerations:
59+
{{ toYaml .Values.tolerations | indent 8 }}
60+
{{- end }}
61+
{{- if .Values.affinity }}
62+
affinity:
63+
{{ toYaml .Values.affinity | indent 8 }}
64+
{{- end }}
65+
{{- end }}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{{- $licenseKey := include "nri-prometheus.licenseKey" . -}}
2+
{{- if $licenseKey }}
3+
apiVersion: v1
4+
kind: Secret
5+
metadata:
6+
name: {{ template "nri-prometheus.fullname" . }}-config
7+
namespace: {{ .Release.Namespace }}
8+
labels:
9+
{{ include "nri-prometheus.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+
name: {{ template "nri-prometheus.serviceAccountName" . }}
6+
namespace: {{ .Release.Namespace }}
7+
labels:
8+
{{ include "nri-prometheus.labels" . | indent 4 }}
9+
{{- end -}}

0 commit comments

Comments
 (0)