AETHER-1585 Chart for edge-maintenance-agent
Change-Id: Ic5166bfca3eccbb6725befbda386aba99e25ddb9
diff --git a/monitoring/edge-maintenance-agent/templates/NOTES.txt b/monitoring/edge-maintenance-agent/templates/NOTES.txt
new file mode 100644
index 0000000..5448714
--- /dev/null
+++ b/monitoring/edge-maintenance-agent/templates/NOTES.txt
@@ -0,0 +1,20 @@
+{{/*
+Copyright 2020-present Open Networking Foundation
+SPDX-License-Identifier: LicenseRef-ONF-Member-Only-1.0
+*/}}
+
+1. Get the application URL by running these commands:
+{{- if contains "NodePort" .Values.service.type }}
+ export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "edge-maintenance-agent.fullname" . }})
+ export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}")
+ echo http://$NODE_IP:$NODE_PORT
+{{- else if contains "LoadBalancer" .Values.service.type }}
+ NOTE: It may take a few minutes for the LoadBalancer IP to be available.
+ You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "edge-maintenance-agent.fullname" . }}'
+ export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "edge-maintenance-agent.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}")
+ echo http://$SERVICE_IP:{{ .Values.service.port }}
+{{- else if contains "ClusterIP" .Values.service.type }}
+ export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "edge-maintenance-agent.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
+ echo "Visit http://127.0.0.1:8080 to use your application"
+ kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:8080
+{{- end }}
diff --git a/monitoring/edge-maintenance-agent/templates/_helpers.tpl b/monitoring/edge-maintenance-agent/templates/_helpers.tpl
new file mode 100644
index 0000000..e61f5fe
--- /dev/null
+++ b/monitoring/edge-maintenance-agent/templates/_helpers.tpl
@@ -0,0 +1,57 @@
+{{/*
+Copyright 2020-present Open Networking Foundation
+SPDX-License-Identifier: LicenseRef-ONF-Member-Only-1.0
+*/}}
+
+{{/* vim: set filetype=mustache: */}}
+{{/*
+Expand the name of the chart.
+*/}}
+{{- define "edge-maintenance-agent.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 "edge-maintenance-agent.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 "edge-maintenance-agent.chart" -}}
+{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
+{{- end }}
+
+{{/*
+Common labels
+*/}}
+{{- define "edge-maintenance-agent.labels" -}}
+helm.sh/chart: {{ include "edge-maintenance-agent.chart" . }}
+{{ include "edge-maintenance-agent.selectorLabels" . }}
+{{- if .Chart.AppVersion }}
+app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
+{{- end }}
+app.kubernetes.io/managed-by: {{ .Release.Service }}
+{{- end }}
+
+{{/*
+Selector labels
+*/}}
+{{- define "edge-maintenance-agent.selectorLabels" -}}
+app.kubernetes.io/name: {{ include "edge-maintenance-agent.name" . }}
+app.kubernetes.io/instance: {{ .Release.Name }}
+{{- end }}
diff --git a/monitoring/edge-maintenance-agent/templates/deployment.yaml b/monitoring/edge-maintenance-agent/templates/deployment.yaml
new file mode 100644
index 0000000..f555add
--- /dev/null
+++ b/monitoring/edge-maintenance-agent/templates/deployment.yaml
@@ -0,0 +1,67 @@
+# Copyright 2020-present Open Networking Foundation
+# SPDX-License-Identifier: LicenseRef-ONF-Member-Only-1.0
+
+apiVersion: apps/v1
+kind: Deployment
+metadata:
+ name: {{ include "edge-maintenance-agent.fullname" . }}
+ labels:
+ {{- include "edge-maintenance-agent.labels" . | nindent 4 }}
+spec:
+ replicas: {{ .Values.replicaCount }}
+ selector:
+ matchLabels:
+ {{- include "edge-maintenance-agent.selectorLabels" . | nindent 6 }}
+ template:
+ metadata:
+ {{- with .Values.podAnnotations }}
+ annotations:
+ {{- toYaml . | nindent 8 }}
+ {{- end }}
+ labels:
+ {{- include "edge-maintenance-agent.selectorLabels" . | nindent 8 }}
+ spec:
+ {{- with .Values.imagePullSecrets }}
+ imagePullSecrets:
+ {{- toYaml . | nindent 8 }}
+ {{- end }}
+ 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 }}
+ ports:
+ - name: http
+ containerPort: 8080
+ protocol: TCP
+ command: ["python", "edge_maintenance_agent.py"]
+ env:
+ - name: AETHER_EDGE_STATUS_URL
+ value: "{{ .Values.edgeMonitoringServerURL }}/{{ .Values.edgeName }}"
+ livenessProbe:
+ httpGet:
+ path: /healthz
+ port: http
+ initialDelaySeconds: 3
+ periodSeconds: 3
+ readinessProbe:
+ httpGet:
+ path: /metrics
+ port: http
+ resources:
+ {{- toYaml .Values.resources | nindent 12 }}
+ {{- with .Values.nodeSelector }}
+ nodeSelector:
+ {{- toYaml . | nindent 8 }}
+ {{- end }}
+ {{- with .Values.affinity }}
+ affinity:
+ {{- toYaml . | nindent 8 }}
+ {{- end }}
+ {{- with .Values.tolerations }}
+ tolerations:
+ {{- toYaml . | nindent 8 }}
+ {{- end }}
diff --git a/monitoring/edge-maintenance-agent/templates/prometheusrule.yaml b/monitoring/edge-maintenance-agent/templates/prometheusrule.yaml
new file mode 100644
index 0000000..fa5ee0d
--- /dev/null
+++ b/monitoring/edge-maintenance-agent/templates/prometheusrule.yaml
@@ -0,0 +1,22 @@
+# Copyright 2020-present Open Networking Foundation
+# SPDX-License-Identifier: LicenseRef-ONF-Member-Only-1.0
+
+{{- if .Values.prometheus.enabled }}
+apiVersion: monitoring.coreos.com/v1
+kind: PrometheusRule
+metadata:
+ name: {{ include "edge-maintenance-agent.fullname" . }}
+ labels:
+ {{- include "edge-maintenance-agent.labels" . | nindent 4 }}
+spec:
+ groups:
+ - name: ace-maintenance.rules
+ rules:
+ - alert: ScheduledDowntime
+ annotations:
+ message: The cluster is undergoing scheduled maintenance.
+ expr: aetheredge_in_maintenance_window > 0
+ for: 1m
+ labels:
+ severity: info
+{{- end }}
diff --git a/monitoring/edge-maintenance-agent/templates/service.yaml b/monitoring/edge-maintenance-agent/templates/service.yaml
new file mode 100644
index 0000000..ab7e925
--- /dev/null
+++ b/monitoring/edge-maintenance-agent/templates/service.yaml
@@ -0,0 +1,18 @@
+# Copyright 2020-present Open Networking Foundation
+# SPDX-License-Identifier: LicenseRef-ONF-Member-Only-1.0
+
+apiVersion: v1
+kind: Service
+metadata:
+ name: {{ include "edge-maintenance-agent.fullname" . }}
+ labels:
+ {{- include "edge-maintenance-agent.labels" . | nindent 4 }}
+spec:
+ type: {{ .Values.service.type }}
+ ports:
+ - port: {{ .Values.service.port }}
+ targetPort: 8080
+ protocol: TCP
+ name: http
+ selector:
+ {{- include "edge-maintenance-agent.selectorLabels" . | nindent 4 }}
diff --git a/monitoring/edge-maintenance-agent/templates/servicemonitor.yaml b/monitoring/edge-maintenance-agent/templates/servicemonitor.yaml
new file mode 100644
index 0000000..465480b
--- /dev/null
+++ b/monitoring/edge-maintenance-agent/templates/servicemonitor.yaml
@@ -0,0 +1,19 @@
+{{/*
+# Copyright 2020-present Open Networking Foundation
+
+# SPDX-License-Identifier: LicenseRef-ONF-Member-Only-1.0
+*/}}
+{{- if .Values.prometheus.enabled }}
+---
+apiVersion: monitoring.coreos.com/v1
+kind: ServiceMonitor
+metadata:
+ name: edge-maintenance-agent
+spec:
+ endpoints:
+ - path: /metrics
+ port: http
+ selector:
+ matchLabels:
+ {{- include "edge-maintenance-agent.selectorLabels" . | nindent 6 }}
+{{- end }}