Task Details:
=============
Task ID : AETHER-2167 : Implement helm charts for deploying prom-label-proxy
Task Link : https://jira.opennetworking.org/browse/AETHER-2167
Features/Root Cause Analysis :
==============================
* config model helm chart for prom label proxy
* prom-label-proxy helm chart
* getting initial config not done deliberatlywq
Unit Test:
=============
* Integration testing with prometheus done
* Integration testing with Grafana pending
Change-Id: I1b94feee56cb7046dd1affb036c3d02585aedcaf
diff --git a/prom-label-proxy/templates/_helpers.tpl b/prom-label-proxy/templates/_helpers.tpl
new file mode 100644
index 0000000..bb3c234
--- /dev/null
+++ b/prom-label-proxy/templates/_helpers.tpl
@@ -0,0 +1,56 @@
+{{/* vim: set filetype=mustache: */}}
+{{/*
+SPDX-FileCopyrightText: 2020-present Open Networking Foundation <info@opennetworking.org>
+SPDX-License-Identifier: LicenseRef-ONF-Member-Only-1.0
+
+Expand the name of the chart.
+*/}}
+{{- define "prom-label-proxy.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 "prom-label-proxy.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 "prom-label-proxy.chart" -}}
+{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
+{{- end -}}
+
+
+{{/*
+Common labels
+*/}}
+{{- define "prom-label-proxy.labels" -}}
+helm.sh/chart: {{ include "prom-label-proxy.chart" . }}
+{{ include "prom-label-proxy.selectorLabels" . }}
+{{- if .Chart.AppVersion }}
+app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
+{{- end }}
+app.kubernetes.io/managed-by: {{ .Release.Service }}
+{{- end -}}
+
+{{/*
+Selector labels
+*/}}
+{{- define "prom-label-proxy.selectorLabels" -}}
+app.kubernetes.io/name: {{ include "prom-label-proxy.name" . }}
+app.kubernetes.io/instance: {{ .Release.Name }}
+{{- end -}}
diff --git a/prom-label-proxy/templates/deployment.yaml b/prom-label-proxy/templates/deployment.yaml
new file mode 100644
index 0000000..3d8cd09
--- /dev/null
+++ b/prom-label-proxy/templates/deployment.yaml
@@ -0,0 +1,85 @@
+# SPDX-FileCopyrightText: 2020-present Open Networking Foundation <info@opennetworking.org>
+#
+# SPDX-License-Identifier: LicenseRef-ONF-Member-Only-1.0
+
+apiVersion: apps/v1
+kind: Deployment
+metadata:
+ name: {{ template "prom-label-proxy.fullname" . }}
+ namespace: {{ .Release.Namespace }}
+ labels:
+ name: {{ template "prom-label-proxy.fullname" . }}
+spec:
+ replicas: {{ .Values.replicaCount }}
+ selector:
+ matchLabels:
+ {{- include "prom-label-proxy.selectorLabels" . | nindent 6 }}
+ template:
+ metadata:
+ labels:
+ name: {{ template "prom-label-proxy.fullname" . }}
+ {{- include "prom-label-proxy.selectorLabels" . | nindent 8 }}
+ spec:
+ {{- with .Values.imagePullSecrets }}
+ imagePullSecrets:
+ {{- toYaml . | nindent 6 }}
+ {{- end }}
+ securityContext:
+ {{- toYaml .Values.podSecurityContext | nindent 8 }}
+ containers:
+ - name: {{ .Chart.Name }}
+ image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
+ imagePullPolicy: {{ .Values.image.pullPolicy }}
+ env:
+ - name: POD_NAMESPACE
+ valueFrom:
+ fieldRef:
+ fieldPath: metadata.namespace
+ - name: POD_NAME
+ valueFrom:
+ fieldRef:
+ fieldPath: metadata.name
+ - name: POD_IP
+ valueFrom:
+ fieldRef:
+ fieldPath: status.podIP
+ - name: NODE_NAME
+ valueFrom:
+ fieldRef:
+ fieldPath: spec.nodeName
+ - name: OIDC_SERVER_URL
+ value: {{ .Values.config.openidc.issuer }}
+ args:
+ [
+ "-label={{ .Values.config.label }}",
+ "-admingroup={{ .Values.config.admingroup }}",
+ "-upstream={{ .Values.config.upstream }}",
+ "-insecure-listen-address=0.0.0.0:{{ .Values.config.http.port }}",
+ "-config_address=$(POD_IP):{{ .Values.config.gnmi.port }}",
+ "-onos_config_url={{ .Values.config.onos_config_url }}",
+ "-key=/etc/prom-label-proxy/certs/tls.key",
+ "-cert=/etc/prom-label-proxy/certs/tls.crt",
+ "-ca=/etc/prom-label-proxy/certs/tls.cacert" ]
+ ports:
+ - name: http
+ containerPort: {{ .Values.config.http.port }}
+ - name: gnmi
+ containerPort: {{ .Values.config.gnmi.port }}
+ readinessProbe:
+ tcpSocket:
+ port: {{ .Values.config.http.port }}
+ initialDelaySeconds: 5
+ periodSeconds: 10
+ livenessProbe:
+ tcpSocket:
+ port: {{ .Values.config.http.port }}
+ initialDelaySeconds: 15
+ periodSeconds: 20
+ volumeMounts:
+ - name: secret
+ mountPath: /etc/prom-label-proxy/certs
+ readOnly: true
+ volumes:
+ - name: secret
+ secret:
+ secretName: {{ template "prom-label-proxy.fullname" . }}-secret
diff --git a/prom-label-proxy/templates/secret.yaml b/prom-label-proxy/templates/secret.yaml
new file mode 100644
index 0000000..0e61df0
--- /dev/null
+++ b/prom-label-proxy/templates/secret.yaml
@@ -0,0 +1,18 @@
+# SPDX-FileCopyrightText: 2020-present Open Networking Foundation <info@opennetworking.org>
+#
+# SPDX-License-Identifier: LicenseRef-ONF-Member-Only-1.0
+
+apiVersion: v1
+kind: Secret
+metadata:
+ name: {{ template "prom-label-proxy.fullname" . }}-secret
+ labels:
+ chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
+ release: "{{ .Release.Name }}"
+ heritage: "{{ .Release.Service }}"
+data:
+ {{ $root := . }}
+ {{ range $path, $bytes := .Files.Glob "files/certs/tls.*" }}
+ {{ base $path }}: '{{ $root.Files.Get $path | b64enc }}'
+ {{ end }}
+type: Opaque
diff --git a/prom-label-proxy/templates/service.yaml b/prom-label-proxy/templates/service.yaml
new file mode 100644
index 0000000..e606dce
--- /dev/null
+++ b/prom-label-proxy/templates/service.yaml
@@ -0,0 +1,24 @@
+# SPDX-FileCopyrightText: 2020-present Open Networking Foundation <info@opennetworking.org>
+#
+# SPDX-License-Identifier: LicenseRef-ONF-Member-Only-1.0
+---
+apiVersion: v1
+kind: Service
+metadata:
+ name: {{ template "prom-label-proxy.fullname" . }}
+ labels:
+ app: {{ template "prom-label-proxy.fullname" . }}
+ chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
+ release: "{{ .Release.Name }}"
+ heritage: "{{ .Release.Service }}"
+ {{- include "prom-label-proxy.labels" . | nindent 4 }}
+spec:
+ type: {{ .Values.service.type }}
+ selector:
+ name: {{ template "prom-label-proxy.fullname" . }}
+ ports:
+ - name: http
+ port: {{ .Values.service.http.port }}
+ - name: gnmi
+ port: {{ .Values.service.gnmi.port }}
+