AETHER-1585 Chart for edge-maintenance-agent
Change-Id: Ic5166bfca3eccbb6725befbda386aba99e25ddb9
diff --git a/monitoring/edge-maintenance-agent/.helmignore b/monitoring/edge-maintenance-agent/.helmignore
new file mode 100644
index 0000000..17fdbc0
--- /dev/null
+++ b/monitoring/edge-maintenance-agent/.helmignore
@@ -0,0 +1,26 @@
+# Copyright 2020-present Open Networking Foundation
+# SPDX-License-Identifier: LicenseRef-ONF-Member-Only-1.0
+
+# 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/
diff --git a/monitoring/edge-maintenance-agent/Chart.yaml b/monitoring/edge-maintenance-agent/Chart.yaml
new file mode 100644
index 0000000..c91dbd0
--- /dev/null
+++ b/monitoring/edge-maintenance-agent/Chart.yaml
@@ -0,0 +1,16 @@
+# Copyright 2020-present Open Networking Foundation
+# SPDX-License-Identifier: LicenseRef-ONF-Member-Only-1.0
+
+apiVersion: v1
+name: edge-maintenance-agent
+description: A Helm chart for deploying Aether's edge maintenance agent
+
+# 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.
+appVersion: 0.6.0
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 }}
diff --git a/monitoring/edge-maintenance-agent/values.yaml b/monitoring/edge-maintenance-agent/values.yaml
new file mode 100644
index 0000000..55e6a78
--- /dev/null
+++ b/monitoring/edge-maintenance-agent/values.yaml
@@ -0,0 +1,63 @@
+# Copyright 2020-present Open Networking Foundation
+# SPDX-License-Identifier: LicenseRef-ONF-Member-Only-1.0
+
+# Default values for edge-maintenance-agent.
+# This is a YAML-formatted file.
+# Declare variables to be passed into your templates.
+
+replicaCount: 1
+
+image:
+ # The agent is bundled in the edge-monitoring-server image.
+ repository: docker.io/omecproject/edge-monitoring-server
+ pullPolicy: Always
+ # Overrides the image tag whose default is the chart appVersion.
+ tag: ""
+
+# URL of edge monitoring server that monitors maintenance calendar
+edgeMonitoringServerURL: ""
+
+# Name of edge in edge monitoring server output
+edgeName: ""
+
+prometheus:
+ enabled: true
+
+imagePullSecrets: []
+nameOverride: ""
+fullnameOverride: ""
+
+podAnnotations: {}
+
+podSecurityContext: {}
+ # fsGroup: 2000
+
+securityContext: {}
+ # capabilities:
+ # drop:
+ # - ALL
+ # readOnlyRootFilesystem: true
+ # runAsNonRoot: true
+ # runAsUser: 1000
+
+service:
+ type: ClusterIP
+ port: 8080
+
+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: {}