From f09cc4831db2b732c80fafbe4da86bd9bf009e1a Mon Sep 17 00:00:00 2001 From: Rahul Zamre Date: Tue, 28 May 2024 12:26:44 +0100 Subject: [PATCH] Revert "Feature 11010: Use of upstream helm charts for Prometheus and Grafana in OSM installation." This reverts commit abf6770c2ec33d6ae0b1fb93be1093081abb5a9f. Change-Id: Ic179fe5475d7a75286bcc10f7694a9e9ef19817b Signed-off-by: Rahul Zamre --- installers/helm/osm/Chart.yaml | 8 - installers/helm/osm/templates/NOTES.txt | 3 + installers/helm/osm/templates/_helpers.tpl | 3 + .../grafana/grafana-clusterrole.yaml | 34 +++ .../grafana/grafana-clusterrolebinding.yaml | 32 +++ .../templates/grafana/grafana-configmap.yaml | 33 +++ .../grafana-dashboard-provider-configmap.yaml | 42 ++++ .../grafana/grafana-datasource-configmap.yaml | 40 +++ .../templates/grafana/grafana-deployment.yaml | 157 ++++++++++++ .../osm/templates/grafana/grafana-secret.yaml | 28 +++ .../templates/grafana/grafana-service.yaml | 35 +++ .../grafana/grafana-serviceaccount.yaml | 24 ++ .../osm/templates/mon/mon-deployment.yaml | 7 +- .../prometheus-alertingrules-configmap.yaml | 37 +++ .../prometheus/prometheus-configmap.yaml | 30 +++ .../prometheus/prometheus-prom-configmap.yaml | 87 +++++++ .../prometheus-recordingrules-configmap.yaml | 43 ++++ .../prometheus/prometheus-service.yaml | 34 +++ .../prometheus/prometheus-statefulset.yaml | 141 +++++++++++ installers/helm/osm/values.yaml | 232 +----------------- jenkins/ci-pipelines/ci_stage_3.groovy | 6 +- 21 files changed, 814 insertions(+), 242 deletions(-) create mode 100644 installers/helm/osm/templates/grafana/grafana-clusterrole.yaml create mode 100644 installers/helm/osm/templates/grafana/grafana-clusterrolebinding.yaml create mode 100644 installers/helm/osm/templates/grafana/grafana-configmap.yaml create mode 100644 installers/helm/osm/templates/grafana/grafana-dashboard-provider-configmap.yaml create mode 100644 installers/helm/osm/templates/grafana/grafana-datasource-configmap.yaml create mode 100644 installers/helm/osm/templates/grafana/grafana-deployment.yaml create mode 100644 installers/helm/osm/templates/grafana/grafana-secret.yaml create mode 100644 installers/helm/osm/templates/grafana/grafana-service.yaml create mode 100644 installers/helm/osm/templates/grafana/grafana-serviceaccount.yaml create mode 100644 installers/helm/osm/templates/prometheus/prometheus-alertingrules-configmap.yaml create mode 100644 installers/helm/osm/templates/prometheus/prometheus-configmap.yaml create mode 100644 installers/helm/osm/templates/prometheus/prometheus-prom-configmap.yaml create mode 100644 installers/helm/osm/templates/prometheus/prometheus-recordingrules-configmap.yaml create mode 100644 installers/helm/osm/templates/prometheus/prometheus-service.yaml create mode 100644 installers/helm/osm/templates/prometheus/prometheus-statefulset.yaml diff --git a/installers/helm/osm/Chart.yaml b/installers/helm/osm/Chart.yaml index 0b169544..346986de 100644 --- a/installers/helm/osm/Chart.yaml +++ b/installers/helm/osm/Chart.yaml @@ -34,14 +34,6 @@ dependencies: # repository: "https://charts.bitnami.com/bitnami" # version: "12.1.3" # condition: zookeeper.enabled -- name: grafana - repository: "https://grafana.github.io/helm-charts" - version: 7.3.0 - condition: grafana.enabled -- name: prometheus - repository: "https://prometheus-community.github.io/helm-charts" - version: 25.11.0 - condition: prometheus.enabled # - name: mongodb # repository: "https://charts.bitnami.com/bitnami" # version: "13.9.4" diff --git a/installers/helm/osm/templates/NOTES.txt b/installers/helm/osm/templates/NOTES.txt index 45e18217..eef0be8f 100644 --- a/installers/helm/osm/templates/NOTES.txt +++ b/installers/helm/osm/templates/NOTES.txt @@ -28,6 +28,7 @@ export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} nbi --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}") echo http://$SERVICE_IP:{{ .Values.nbi.service.port }} {{- end }} +<<<<<<< HEAD {{- else }} export OSM_GUI_URL=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.rules[0].host}" ingress ngui-ingress) echo "OSM UI: $OSM_GUI_URL" @@ -36,3 +37,5 @@ {{- end }} 2. Get Grafana credentials for admin user using below command. kubectl -n {{ .Release.Namespace }} get secret grafana -o jsonpath="{.data.admin-password}" | base64 --decode ; echo +======= +>>>>>>> e34e722 (Revert "Feature 11010: Use of upstream helm charts for Prometheus and Grafana in OSM installation.") diff --git a/installers/helm/osm/templates/_helpers.tpl b/installers/helm/osm/templates/_helpers.tpl index 337073fe..cd8ca4fe 100644 --- a/installers/helm/osm/templates/_helpers.tpl +++ b/installers/helm/osm/templates/_helpers.tpl @@ -109,3 +109,6 @@ Create the name of the images to be used {{ define "osm.keystone.image" -}} {{ printf "%s:%s" (.Values.keystone.image.repository | default (printf "%s/keystone" (.Values.global.image.repositoryBase))) (.Values.keystone.image.tag | default .Values.global.image.tag) }} {{- end }} +{{ define "osm.prometheus.image" -}} +{{ printf "%s:%s" (.Values.prometheus.sidecarImage.repository | default (printf "%s/prometheus" (.Values.global.image.repositoryBase))) (.Values.prometheus.sidecarImage.tag | default .Values.global.image.tag) }} +{{- end }} diff --git a/installers/helm/osm/templates/grafana/grafana-clusterrole.yaml b/installers/helm/osm/templates/grafana/grafana-clusterrole.yaml new file mode 100644 index 00000000..1e2753a9 --- /dev/null +++ b/installers/helm/osm/templates/grafana/grafana-clusterrole.yaml @@ -0,0 +1,34 @@ +{{- if .Values.grafana.enabled -}} +####################################################################################### +# Copyright ETSI Contributors and Others. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. +# See the License for the specific language governing permissions and +# limitations under the License. +####################################################################################### +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRole +metadata: + labels: + app: grafana + name: grafana-clusterrole +rules: +- apiGroups: + - "" + resources: + - configmaps + - secrets + verbs: + - get + - watch + - list +{{- end -}} \ No newline at end of file diff --git a/installers/helm/osm/templates/grafana/grafana-clusterrolebinding.yaml b/installers/helm/osm/templates/grafana/grafana-clusterrolebinding.yaml new file mode 100644 index 00000000..46669bf2 --- /dev/null +++ b/installers/helm/osm/templates/grafana/grafana-clusterrolebinding.yaml @@ -0,0 +1,32 @@ +{{- if .Values.grafana.enabled -}} +####################################################################################### +# Copyright ETSI Contributors and Others. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. +# See the License for the specific language governing permissions and +# limitations under the License. +####################################################################################### +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRoleBinding +metadata: + labels: + app: grafana + name: grafana-clusterrolebinding +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: ClusterRole + name: grafana-clusterrole +subjects: +- kind: ServiceAccount + name: grafana + namespace: {{ .Release.Namespace }} +{{- end -}} \ No newline at end of file diff --git a/installers/helm/osm/templates/grafana/grafana-configmap.yaml b/installers/helm/osm/templates/grafana/grafana-configmap.yaml new file mode 100644 index 00000000..7d4653b2 --- /dev/null +++ b/installers/helm/osm/templates/grafana/grafana-configmap.yaml @@ -0,0 +1,33 @@ +{{- if .Values.grafana.enabled -}} +####################################################################################### +# Copyright ETSI Contributors and Others. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. +# See the License for the specific language governing permissions and +# limitations under the License. +####################################################################################### +apiVersion: v1 +data: + grafana.ini: | + [log] + mode = console + [paths] + data = /var/lib/grafana/data + logs = /var/log/grafana + plugins = /var/lib/grafana/plugins + provisioning = /etc/grafana/provisioning +kind: ConfigMap +metadata: + labels: + app: grafana + name: grafana +{{- end -}} \ No newline at end of file diff --git a/installers/helm/osm/templates/grafana/grafana-dashboard-provider-configmap.yaml b/installers/helm/osm/templates/grafana/grafana-dashboard-provider-configmap.yaml new file mode 100644 index 00000000..68dc91b8 --- /dev/null +++ b/installers/helm/osm/templates/grafana/grafana-dashboard-provider-configmap.yaml @@ -0,0 +1,42 @@ +{{- if .Values.grafana.enabled -}} +####################################################################################### +# Copyright ETSI Contributors and Others. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. +# See the License for the specific language governing permissions and +# limitations under the License. +####################################################################################### +apiVersion: v1 +data: + provider.yaml: |- + apiVersion: 1 + providers: + - name: 'Kubernetes Cluster' + orgId: 1 + folder: 'Kubernetes Cluster' + type: file + disableDeletion: false + options: + path: '/tmp/dashboards/Kubernetes Cluster' + - name: 'Open Source MANO' + orgId: 1 + folder: 'Open Source MANO' + type: file + disableDeletion: false + options: + path: '/tmp/dashboards/Open Source MANO' +kind: ConfigMap +metadata: + labels: + app: grafana + name: grafana-dashboard-provider +{{- end -}} \ No newline at end of file diff --git a/installers/helm/osm/templates/grafana/grafana-datasource-configmap.yaml b/installers/helm/osm/templates/grafana/grafana-datasource-configmap.yaml new file mode 100644 index 00000000..ac07a36c --- /dev/null +++ b/installers/helm/osm/templates/grafana/grafana-datasource-configmap.yaml @@ -0,0 +1,40 @@ +{{- if .Values.grafana.enabled -}} +####################################################################################### +# Copyright ETSI Contributors and Others. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. +# See the License for the specific language governing permissions and +# limitations under the License. +####################################################################################### +apiVersion: v1 +kind: ConfigMap +metadata: + labels: + grafana_datasource: "1" + name: grafana-datasource +data: + datasource.yaml: |- + apiVersion: 1 + datasources: + - name: osm_prometheus + type: prometheus + url: http://prometheus:9090 + access: proxy + allowUiUpdates: true + isDefault: true + - name: Prometheus + type: prometheus + url: http://osm-monitoring-kube-promet-prometheus.monitoring:9090 + access: proxy + allowUiUpdates: true + isDefault: false +{{- end -}} \ No newline at end of file diff --git a/installers/helm/osm/templates/grafana/grafana-deployment.yaml b/installers/helm/osm/templates/grafana/grafana-deployment.yaml new file mode 100644 index 00000000..c39f4e81 --- /dev/null +++ b/installers/helm/osm/templates/grafana/grafana-deployment.yaml @@ -0,0 +1,157 @@ +{{- if .Values.grafana.enabled -}} +####################################################################################### +# Copyright ETSI Contributors and Others. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. +# See the License for the specific language governing permissions and +# limitations under the License. +####################################################################################### +apiVersion: apps/v1 +kind: Deployment +metadata: + labels: + app: grafana + name: grafana +spec: + replicas: 1 + selector: + matchLabels: + app: grafana + template: + metadata: + labels: + app: grafana + spec: + containers: + - env: + - name: LABEL + value: grafana_dashboard + - name: FOLDER + value: "/tmp/dashboards/Kubernetes Cluster" + - name: RESOURCE + value: both + - name: NAMESPACE + value: monitoring + image: kiwigrid/k8s-sidecar:1.15.6 + imagePullPolicy: IfNotPresent + name: grafana-sc-dashboard + resources: {} + terminationMessagePath: /dev/termination-log + terminationMessagePolicy: File + volumeMounts: + - mountPath: "/tmp/dashboards/Kubernetes Cluster" + name: sc-dashboard-volume-k8s + - mountPath: "/tmp/dashboards/Open Source MANO" + name: sc-dashboard-volume-osm + - env: + - name: GF_SECURITY_ADMIN_USER + valueFrom: + secretKeyRef: + key: admin-user + name: grafana + - name: GF_SECURITY_ADMIN_PASSWORD + valueFrom: + secretKeyRef: + key: admin-password + name: grafana + image: grafana/grafana:10.1.2 + imagePullPolicy: IfNotPresent + livenessProbe: + failureThreshold: 10 + httpGet: + path: /api/health + port: 3000 + scheme: HTTP + initialDelaySeconds: 60 + periodSeconds: 10 + successThreshold: 1 + timeoutSeconds: 30 + name: grafana + ports: + - containerPort: 80 + name: service + protocol: TCP + - containerPort: 3000 + name: grafana + protocol: TCP + readinessProbe: + failureThreshold: 3 + httpGet: + path: /api/health + port: 3000 + scheme: HTTP + periodSeconds: 10 + successThreshold: 1 + timeoutSeconds: 1 + resources: {} + terminationMessagePath: /dev/termination-log + terminationMessagePolicy: File + volumeMounts: + - mountPath: /etc/grafana/grafana.ini + name: config + subPath: grafana.ini + - mountPath: /var/lib/grafana + name: storage + - mountPath: "/tmp/dashboards/Kubernetes Cluster" + name: sc-dashboard-volume-k8s + - mountPath: "/tmp/dashboards/Open Source MANO" + name: sc-dashboard-volume-osm + - mountPath: /etc/grafana/provisioning/dashboards/sc-dashboardproviders.yaml + name: sc-dashboard-provider + subPath: provider.yaml + - mountPath: /etc/grafana/provisioning/datasources + name: sc-datasources-volume + dnsPolicy: ClusterFirst + initContainers: + - env: + - name: METHOD + value: LIST + - name: LABEL + value: grafana_datasource + - name: FOLDER + value: /etc/grafana/provisioning/datasources + - name: RESOURCE + value: both + image: kiwigrid/k8s-sidecar:1.15.6 + imagePullPolicy: IfNotPresent + name: grafana-sc-datasources + resources: {} + terminationMessagePath: /dev/termination-log + terminationMessagePolicy: File + volumeMounts: + - mountPath: /etc/grafana/provisioning/datasources + name: sc-datasources-volume + restartPolicy: Always + schedulerName: default-scheduler + securityContext: + {{- toYaml .Values.global.podSecurityContext | nindent 8 }} + serviceAccount: grafana + serviceAccountName: grafana + terminationGracePeriodSeconds: 30 + volumes: + - configMap: + defaultMode: 420 + name: grafana + name: config + - emptyDir: {} + name: storage + - emptyDir: {} + name: sc-dashboard-volume-k8s + - emptyDir: {} + name: sc-dashboard-volume-osm + - configMap: + defaultMode: 420 + name: grafana-dashboard-provider + name: sc-dashboard-provider + - emptyDir: {} + name: sc-datasources-volume +{{- end -}} diff --git a/installers/helm/osm/templates/grafana/grafana-secret.yaml b/installers/helm/osm/templates/grafana/grafana-secret.yaml new file mode 100644 index 00000000..fd240e60 --- /dev/null +++ b/installers/helm/osm/templates/grafana/grafana-secret.yaml @@ -0,0 +1,28 @@ +{{- if .Values.grafana.enabled -}} +####################################################################################### +# Copyright ETSI Contributors and Others. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. +# See the License for the specific language governing permissions and +# limitations under the License. +####################################################################################### +apiVersion: v1 +data: + admin-password: YWRtaW4= + admin-user: YWRtaW4= +kind: Secret +metadata: + labels: + app: grafana + name: grafana +type: Opaque +{{- end -}} \ No newline at end of file diff --git a/installers/helm/osm/templates/grafana/grafana-service.yaml b/installers/helm/osm/templates/grafana/grafana-service.yaml new file mode 100644 index 00000000..6adee4b1 --- /dev/null +++ b/installers/helm/osm/templates/grafana/grafana-service.yaml @@ -0,0 +1,35 @@ +{{- if .Values.grafana.enabled -}} +####################################################################################### +# Copyright ETSI Contributors and Others. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. +# See the License for the specific language governing permissions and +# limitations under the License. +####################################################################################### +apiVersion: v1 +kind: Service +metadata: + labels: + app: grafana + name: grafana +spec: + ports: + - name: service + nodePort: 3000 + port: 3000 + protocol: TCP + targetPort: 3000 + selector: + app: grafana + sessionAffinity: None + type: NodePort +{{- end -}} \ No newline at end of file diff --git a/installers/helm/osm/templates/grafana/grafana-serviceaccount.yaml b/installers/helm/osm/templates/grafana/grafana-serviceaccount.yaml new file mode 100644 index 00000000..63ea5156 --- /dev/null +++ b/installers/helm/osm/templates/grafana/grafana-serviceaccount.yaml @@ -0,0 +1,24 @@ +{{- if .Values.grafana.enabled -}} +####################################################################################### +# Copyright ETSI Contributors and Others. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. +# See the License for the specific language governing permissions and +# limitations under the License. +####################################################################################### +apiVersion: v1 +kind: ServiceAccount +metadata: + labels: + app: grafana + name: grafana +{{- end -}} \ No newline at end of file diff --git a/installers/helm/osm/templates/mon/mon-deployment.yaml b/installers/helm/osm/templates/mon/mon-deployment.yaml index 4fcbd587..04bb6b25 100644 --- a/installers/helm/osm/templates/mon/mon-deployment.yaml +++ b/installers/helm/osm/templates/mon/mon-deployment.yaml @@ -78,11 +78,6 @@ spec: {{- end }} {{- if or .Values.vca.enabled .Values.mon.useOsmSecret }} env: - - name: OSMMON_GRAFANA_PASSWORD - valueFrom: - secretKeyRef: - name: grafana - key: admin-password {{- if .Values.vca.enabled }} - name: OSMMON_VCA_HOST valueFrom: @@ -120,4 +115,4 @@ spec: tolerations: {{- toYaml . | nindent 8 }} {{- end }} -{{- end }} +{{- end }} \ No newline at end of file diff --git a/installers/helm/osm/templates/prometheus/prometheus-alertingrules-configmap.yaml b/installers/helm/osm/templates/prometheus/prometheus-alertingrules-configmap.yaml new file mode 100644 index 00000000..b4f26794 --- /dev/null +++ b/installers/helm/osm/templates/prometheus/prometheus-alertingrules-configmap.yaml @@ -0,0 +1,37 @@ +{{- if not .Values.global.oldServiceAssurance -}} +{{- if .Values.prometheus.enabled -}} +####################################################################################### +# Copyright ETSI Contributors and Others. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. +# See the License for the specific language governing permissions and +# limitations under the License. +####################################################################################### +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ include "osm.fullname" . }}-prometheus-alertingrules-configmap + labels: + {{- include "osm.labels" . | nindent 4 }} +data: + osm_alert_rules.yml: | + groups: + - name: osm_alert_rules + rules: + - alert: vdu_down + expr: vm_status_extended != 1 + for: 3m + annotations: + summary: "VDU {{ "{{" }} $labels.vm_id }} in VIM {{ "{{" }} $labels.vim_id }} is down" + description: "VDU {{ "{{" }} $labels.vm_id }} in VIM {{ "{{" }} $labels.vim_id }} has been down for more than 3 minutes. NS instance id is {{ "{{" }} $labels.ns_id }}" +{{- end }} +{{- end }} \ No newline at end of file diff --git a/installers/helm/osm/templates/prometheus/prometheus-configmap.yaml b/installers/helm/osm/templates/prometheus/prometheus-configmap.yaml new file mode 100644 index 00000000..b213e22e --- /dev/null +++ b/installers/helm/osm/templates/prometheus/prometheus-configmap.yaml @@ -0,0 +1,30 @@ +{{- if .Values.prometheus.enabled -}} +####################################################################################### +# Copyright ETSI Contributors and Others. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. +# See the License for the specific language governing permissions and +# limitations under the License. +####################################################################################### +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ include "osm.fullname" . }}-prometheus-configmap + labels: + {{- include "osm.labels" . | nindent 4 }} +data: + MONGODB_URL: "mongodb://mongodb-k8s:27017/?replicaSet=rs0" + PROMETHEUS_CONFIG_FILE: "/etc/prometheus/prometheus.yml" + PROMETHEUS_BASE_CONFIG_FILE: "/etc/prometheus_base/prometheus.yml" + TARGET_DATABASE: "osm" + PROMETHEUS_URL: "http://prometheus:9090" +{{- end }} \ No newline at end of file diff --git a/installers/helm/osm/templates/prometheus/prometheus-prom-configmap.yaml b/installers/helm/osm/templates/prometheus/prometheus-prom-configmap.yaml new file mode 100644 index 00000000..18fef224 --- /dev/null +++ b/installers/helm/osm/templates/prometheus/prometheus-prom-configmap.yaml @@ -0,0 +1,87 @@ +{{- if .Values.prometheus.enabled -}} +####################################################################################### +# Copyright ETSI Contributors and Others. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. +# See the License for the specific language governing permissions and +# limitations under the License. +####################################################################################### +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ include "osm.fullname" . }}-prometheus-prom-configmap + labels: + {{- include "osm.labels" . | nindent 4 }} +data: + prometheus.yml: | + # Copyright 2018 The Prometheus Authors + # Copyright 2018 Whitestack + # Copyright 2018 Telefonica Investigacion y Desarrollo, S.A.U. + # + # Licensed under the Apache License, Version 2.0 (the "License"); + # you may not use this file except in compliance with the License. + # You may obtain a copy of the License at + # + # http://www.apache.org/licenses/LICENSE-2.0 + # + # Unless required by applicable law or agreed to in writing, software + # distributed under the License is distributed on an "AS IS" BASIS, + # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + # See the License for the specific language governing permissions and + # limitations under the License. + + # my global config + global: + scrape_interval: 15s # Set the scrape interval to every 15 seconds. Default is every 1 minute. + evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is every 1 minute. + # scrape_timeout is set to the global default (10s). + + # Alertmanager configuration + alerting: + alertmanagers: + - static_configs: + - targets: +{{- if .Values.global.oldServiceAssurance }} + # - alertmanager:9093 +{{- else }} + - alertmanager:9093 +{{- end }} + # Load rules once and periodically evaluate them according to the global 'evaluation_interval'. +{{- if .Values.global.oldServiceAssurance }} + rule_files: + # - "first_rules.yml" + # - "second_rules.yml" +{{- else }} + rule_files: + - "osm_metric_rules.yml" + - "osm_alert_rules.yml" +{{- end }} + # A scrape configuration containing exactly one endpoint to scrape: + # Here it's Prometheus itself. + scrape_configs: + - job_name: 'mon_exporter' + static_configs: + - targets: ['mon:8000'] +{{- if .Values.global.oldServiceAssurance }} + # Add here other external targets, e.g. a pushgateway + # - job_name: 'pushgateway' + # static_configs: + # - targets: ['prometheus-pushgateway:9091'] +{{- else }} + - job_name: pushgateway + honor_labels: true + scrape_interval: 30s + static_configs: + - targets: + - pushgateway-prometheus-pushgateway:9091 +{{- end }} +{{- end }} \ No newline at end of file diff --git a/installers/helm/osm/templates/prometheus/prometheus-recordingrules-configmap.yaml b/installers/helm/osm/templates/prometheus/prometheus-recordingrules-configmap.yaml new file mode 100644 index 00000000..c314d86e --- /dev/null +++ b/installers/helm/osm/templates/prometheus/prometheus-recordingrules-configmap.yaml @@ -0,0 +1,43 @@ +{{- if not .Values.global.oldServiceAssurance -}} +{{- if .Values.prometheus.enabled -}} +####################################################################################### +# Copyright ETSI Contributors and Others. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. +# See the License for the specific language governing permissions and +# limitations under the License. +####################################################################################### +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ include "osm.fullname" . }}-prometheus-recordingrules-configmap + labels: + {{- include "osm.labels" . | nindent 4 }} +data: + osm_metric_rules.yml: | + groups: + - name: osm_metric_rules + rules: + - record: vm_status_extended + expr: (last_over_time(vm_status[1m]) * on (vm_id, vim_id) group_left(ns_id, vnf_id, vdu_id, project_id, job, vdu_name, vnf_member_index) last_over_time(ns_topology[1m])) or (last_over_time(ns_topology[1m]) * -1) + labels: + job: osm_prometheus + - record: vnf_status + expr: (0 * (count (vm_status_extended==0) by (ns_id, vnf_id)>=0)) or (min by (ns_id, vnf_id) (vm_status_extended)) + labels: + job: osm_prometheus + - record: ns_status + expr: (0 * (count (vm_status_extended==0) by (ns_id)>=0)) or (min by (ns_id) (vm_status_extended)) + labels: + job: osm_prometheus +{{- end }} +{{- end }} \ No newline at end of file diff --git a/installers/helm/osm/templates/prometheus/prometheus-service.yaml b/installers/helm/osm/templates/prometheus/prometheus-service.yaml new file mode 100644 index 00000000..99eef4a2 --- /dev/null +++ b/installers/helm/osm/templates/prometheus/prometheus-service.yaml @@ -0,0 +1,34 @@ +{{- if .Values.prometheus.enabled -}} +####################################################################################### +# Copyright ETSI Contributors and Others. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. +# See the License for the specific language governing permissions and +# limitations under the License. +####################################################################################### +apiVersion: v1 +kind: Service +metadata: + name: prometheus + labels: + {{- include "osm.labels" . | nindent 4 }} +spec: + type: {{ .Values.prometheus.service.type }} + ports: + - nodePort: {{ .Values.prometheus.service.nodePort }} + port: 9090 + targetPort: 9090 + protocol: TCP + selector: + app.kubernetes.io/component: prometheus + {{- include "osm.selectorLabels" . | nindent 4 }} +{{- end }} \ No newline at end of file diff --git a/installers/helm/osm/templates/prometheus/prometheus-statefulset.yaml b/installers/helm/osm/templates/prometheus/prometheus-statefulset.yaml new file mode 100644 index 00000000..96f22813 --- /dev/null +++ b/installers/helm/osm/templates/prometheus/prometheus-statefulset.yaml @@ -0,0 +1,141 @@ +{{- if .Values.prometheus.enabled -}} +####################################################################################### +# Copyright ETSI Contributors and Others. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. +# See the License for the specific language governing permissions and +# limitations under the License. +####################################################################################### +apiVersion: apps/v1 +kind: StatefulSet +metadata: + name: prometheus + labels: + {{- include "osm.labels" . | nindent 4 }} +spec: + replicas: {{ .Values.prometheus.replicaCount | default .Values.global.replicaCount }} + serviceName: prometheus + selector: + matchLabels: + app.kubernetes.io/component: prometheus + {{- include "osm.selectorLabels" . | nindent 6 }} + template: + metadata: + {{- with .Values.global.podAnnotations }} + annotations: + {{- toYaml . | nindent 8 }} + {{- end }} + labels: + app.kubernetes.io/component: prometheus + {{- include "osm.selectorLabels" . | nindent 8 }} + spec: + {{- with .Values.global.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + serviceAccountName: {{ include "osm.serviceAccountName" . }} + initContainers: + - name: prometheus-init-config + image: busybox + command: ["/bin/sh", "-c"] +{{- if .Values.global.oldServiceAssurance }} + args: ['if [ ! -f "/etc/prometheus/prometheus.yml" ]; then cp /config/prometheus.yml /etc/prometheus; fi'] +{{- else }} + args: ['if [ ! -f "/etc/prometheus/prometheus.yml" ]; then cp /config/prometheus.yml /etc/prometheus; fi; cp /config/osm_metric_rules.yml /config/osm_alert_rules.yml /etc/prometheus'] +{{- end }} + volumeMounts: + - name: prom-config + mountPath: /etc/prometheus + - name: prom-config-base + mountPath: /config + containers: + - name: prometheus + securityContext: + # readOnlyRootFilesystem: true + allowPrivilegeEscalation: false + # runAsNonRoot: true + image: prom/prometheus:v2.47.0 + imagePullPolicy: {{ .Values.global.image.pullPolicy }} + args: + - --config.file=/etc/prometheus/prometheus.yml + - --web.enable-lifecycle + ports: + - containerPort: 9090 + protocol: TCP + volumeMounts: + - name: prom-config + mountPath: /etc/prometheus + - name: prom-db + mountPath: /prometheus + resources: + limits: + memory: 1024Mi + requests: + memory: 128Mi + - name: prometheus-config-sidecar + securityContext: + # readOnlyRootFilesystem: true + allowPrivilegeEscalation: false + # runAsNonRoot: true + image: {{ include "osm.prometheus.image" . }} + imagePullPolicy: {{ .Values.global.image.pullPolicy }} + volumeMounts: + - name: prom-config + mountPath: /etc/prometheus + - name: prom-config-base + mountPath: /etc/prometheus_base + resources: + limits: + memory: 1024Mi + requests: + memory: 128Mi + envFrom: + - configMapRef: + name: {{ include "osm.fullname" . }}-prometheus-configmap + {{- with .Values.global.nodeSelector }} + nodeSelector: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.global.affinity }} + affinity: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.global.tolerations }} + tolerations: + {{- toYaml . | nindent 8 }} + {{- end }} + volumes: + - name: prom-db + emptyDir: {} + - name: prom-config + emptyDir: {} + - name: prom-config-base + projected: + sources: + - configMap: + name: {{ include "osm.fullname" . }}-prometheus-prom-configmap + items: + - key: prometheus.yml + path: prometheus.yml +{{- if not .Values.global.oldServiceAssurance }} + - configMap: + name: {{ include "osm.fullname" . }}-prometheus-recordingrules-configmap + items: + - key: osm_metric_rules.yml + path: osm_metric_rules.yml + - configMap: + name: {{ include "osm.fullname" . }}-prometheus-alertingrules-configmap + items: + - key: osm_alert_rules.yml + path: osm_alert_rules.yml +{{- end }} +{{- end }} diff --git a/installers/helm/osm/values.yaml b/installers/helm/osm/values.yaml index 1575136b..0391a4fb 100644 --- a/installers/helm/osm/values.yaml +++ b/installers/helm/osm/values.yaml @@ -278,231 +278,13 @@ pol: prometheus: enabled: true - configmapReload: - prometheus: - enabled: true - prometheus-node-exporter: - enabled: false - kube-state-metrics: - enabled: false - server: - extraFlags: - - web.enable-lifecycle - statefulSet: - enabled: true - configPath: /etc/prometheus/prometheus.yml - fullnameOverride: "prometheus" - service: - servicePort: 9090 - # type: NodePort - # nodePort: 9091 - ingress: - enabled: true - ingressClassName: nginx - # hosts: - # - prometheus..nip.io - sidecarContainers: - prometheus-config-sidecar: - securityContext: - # readOnlyRootFilesystem: true - allowPrivilegeEscalation: false - # runAsNonRoot: true - image: opensourcemano/prometheus:testing-daily - imagePullPolicy: IfNotPresent - command: ["/bin/sh", "-c"] - args: ["sleep 50; python -u ./app.py"] - volumeMounts: - - name: prom-config - mountPath: /etc/prometheus - - name: prom-config-base - mountPath: /etc/prometheus_base - resources: - limits: - memory: 1024Mi - requests: - memory: 128Mi - envFrom: - - configMapRef: - name: osm-prometheus-sidecar-configmap - extraInitContainers: - - name: prometheus-init-config - image: busybox - command: ["/bin/sh", "-c"] - #args: [' sleep 100000 '] - args: ['if [ ! -f "/etc/prometheus/prometheus.yml" ]; then cp /config/prometheus.yml /etc/prometheus; fi; cp /config/osm_metric_rules.yml /config/osm_alert_rules.yml /etc/prometheus'] - volumeMounts: - - name: prom-config - mountPath: /etc/prometheus - - name: prom-config-base - mountPath: /config - extraVolumeMounts: - - name: prom-config - mountPath: /etc/prometheus - extraVolumes: - - name: prom-config - emptyDir: {} - - name: prom-config-base - projected: - sources: - - configMap: - name: osm-prom-configmap - items: - - key: prometheus.yml - path: prometheus.yml - - configMap: - name: osm-prometheus-recordingrules-configmap - items: - - key: osm_metric_rules.yml - path: osm_metric_rules.yml - - configMap: - name: osm-prometheus-alertingrules-configmap - items: - - key: osm_alert_rules.yml - path: osm_alert_rules.yml - extraManifests: - - | - apiVersion: v1 - kind: ConfigMap - metadata: - name: osm-prometheus-alertingrules-configmap - data: - osm_alert_rules.yml: | - groups: - - name: osm_alert_rules - rules: - - alert: vdu_down - expr: vm_status_extended != 1 - for: 3m - annotations: - summary: "VDU {{ "{{" }} $labels.vm_id }} in VIM {{ "{{" }} $labels.vim_id }} is down" - description: "VDU {{ "{{" }} $labels.vm_id }} in VIM {{ "{{" }} $labels.vim_id }} has been down for more than 3 minutes. NS instance id is {{ "{{" }} $labels.ns_id }}" - - | - apiVersion: v1 - kind: ConfigMap - metadata: - name: osm-prometheus-recordingrules-configmap - data: - osm_metric_rules.yml: | - groups: - - name: osm_metric_rules - rules: - - record: vm_status_extended - expr: (last_over_time(vm_status[1m]) * on (vm_id, vim_id) group_left(ns_id, vnf_id, vdu_id, project_id, job, vdu_name, vnf_member_index) last_over_time(ns_topology[1m])) or (last_over_time(ns_topology[1m]) * -1) - labels: - job: osm_prometheus - - record: vnf_status - expr: (0 * (count (vm_status_extended==0) by (ns_id, vnf_id)>=0)) or (min by (ns_id, vnf_id) (vm_status_extended)) - labels: - job: osm_prometheus - - record: ns_status - expr: (0 * (count (vm_status_extended==0) by (ns_id)>=0)) or (min by (ns_id) (vm_status_extended)) - labels: - job: osm_prometheus - - | - apiVersion: v1 - kind: ConfigMap - metadata: - name: osm-prometheus-sidecar-configmap - data: - MONGODB_URL: "mongodb://mongodb-k8s:27017/?replicaSet=rs0" - PROMETHEUS_CONFIG_FILE: "/etc/prometheus/prometheus.yml" - PROMETHEUS_BASE_CONFIG_FILE: "/etc/prometheus_base/prometheus.yml" - TARGET_DATABASE: "osm" - PROMETHEUS_URL: "http://prometheus:9090" - - | - apiVersion: v1 - kind: ConfigMap - metadata: - name: osm-prom-configmap - data: - prometheus.yml: | - global: - scrape_interval: 15s # Set the scrape interval to every 15 seconds. Default is every 1 minute. - evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is every 1 minute. - # scrape_timeout is set to the global default (10s). - # Alertmanager configuration - alerting: - alertmanagers: - - static_configs: - - targets: - - alertmanager:9093 - rule_files: - - "osm_metric_rules.yml" - - "osm_alert_rules.yml" - scrape_configs: - - job_name: 'mon_exporter' - static_configs: - - targets: ['mon:8000'] - - job_name: pushgateway - honor_labels: true - scrape_interval: 30s - static_configs: - - targets: - - pushgateway-prometheus-pushgateway:9091 - - job_name: prometheus - static_configs: - - targets: - - localhost:9090 - - job_name: node - static_configs: - - targets: ['prometheus-node-exporter:9100'] - alertmanager: - enabled: true - fullnameOverride: "alertmanager" - extraArgs: - log.level: debug - # service: - # type: NodePort - # nodePort: 9093 - # port: 9093 - # ingress: - # enabled: True - # className: nginx - # hosts: - # - host: localhost - # paths: - # - path: / - # pathType: ImplementationSpecific - # tls: [] - config: - receivers: - - name: default-receiver - - name: vdu-webhook - webhook_configs: - - url: http://webhook-translator:9998/vdu_down - - name: scaleout-webhook - webhook_configs: - - url: http://webhook-translator:9998/scaleout_vdu - - name: scalein-webhook - webhook_configs: - - url: http://webhook-translator:9998/scalein_vdu - - name: alarm-webhook - webhook_configs: - - url: http://webhook-translator:9998/vdu_alarm - route: - group_wait: 10s - group_interval: 2m - receiver: default-receiver - routes: - - receiver: vdu-webhook - repeat_interval: 15m - matchers: - - alertname = "vdu_down" - - receiver: 'scaleout-webhook' - repeat_interval: 5m - matchers: - - alertname =~ "^scaleout_.*" - - receiver: 'scalein-webhook' - repeat_interval: 5m - matchers: - - alertname =~ "^scalein_.*" - - receiver: 'alarm-webhook' - repeat_interval: 5m - matchers: - - alertname =~ "^vdu_alarm_.*" - prometheus-pushgateway: - fullnameOverride: "pushgateway-prometheus-pushgateway" - + service: + type: NodePort + nodePort: 9091 + # replicaCount: 1 + sidecarImage: {} + # repository: opensourcemano/ro + # tag: "testing-daily" ro: enabled: true # logLevel: DEBUG diff --git a/jenkins/ci-pipelines/ci_stage_3.groovy b/jenkins/ci-pipelines/ci_stage_3.groovy index 13476508..b9e528f2 100644 --- a/jenkins/ci-pipelines/ci_stage_3.groovy +++ b/jenkins/ci-pipelines/ci_stage_3.groovy @@ -593,9 +593,9 @@ node("${params.NODE}") { ${osm_installation_options} """ } - prometheusHostname = "prometheus.${IP_ADDRESS}.nip.io" - prometheusPort = 80 - osmHostname = "nbi.${IP_ADDRESS}.nip.io:443" + prometheusHostname = IP_ADDRESS + prometheusPort = 9091 + osmHostname = IP_ADDRESS } } // stage("Install") /////////////////////////////////////////////////////////////////////////////////////// -- 2.25.1