COMAC-18: Grafana-via-Prometheus for M-CORD CDN monitoring
Change-Id: I230a8bbfd866ca4e784dbd24f28943596cc70239
diff --git a/mcord/mcord-cdn-monitoring/templates/NOTES.txt b/mcord/mcord-cdn-monitoring/templates/NOTES.txt
new file mode 100644
index 0000000..ae4cf08
--- /dev/null
+++ b/mcord/mcord-cdn-monitoring/templates/NOTES.txt
@@ -0,0 +1,47 @@
+Thank you for installing {{ .Chart.Name }}.
+
+This chart is for CDN monitoring in M-CORD demo scenarios.
+To show CDN traffic of CDN server, this chart deploys cAdvisor, Grafana, and Prometheus.
+
+You can determine which components will be installed by values.yaml.
+
+{{- if .Values.cadvisor.enabled }}
+
+
+- cAdvisor
+
+You can now access cAdvisor at: <node-ip>:{{ .Values.cadvisor.nodePort }}
+Prometheus will collect data through this cAdvisor at: <node-ip>:{{ .Values.cadvisor.nodePort }}/metrics
+
+
+{{- end }}
+
+
+{{- if .Values.grafana.enabled }}
+
+
+- Grafana
+
+You can now access Grafana at: <{{ .Values.grafana.node_selector }}-ip>:{{ .Values.grafana.nodePort }}
+using:
+
+username: {{ .Values.grafana.adminUser}}
+password: {{ .Values.grafana.adminPassword}}
+
+We use configs/cdn_metrics.json in default to create dashboards.
+If you want to monitor other CDN servers which have different container names, you should modify the json file or create your own json files.
+
+
+{{- end}}
+
+
+{{- if .Values.prometheus.enabled }}
+
+
+- Prometheus
+
+You can now access Prometheus at: <{{ .Values.prometheus.node_selector }}-ip>:{{ .Values.prometheus.nodePort }}
+If you want to show CDN traffics by Grafana, Grafana should select this Prometheus as data source.
+
+
+{{- end }}
diff --git a/mcord/mcord-cdn-monitoring/templates/cadvisor-ds.yaml b/mcord/mcord-cdn-monitoring/templates/cadvisor-ds.yaml
new file mode 100644
index 0000000..5ebe2e8
--- /dev/null
+++ b/mcord/mcord-cdn-monitoring/templates/cadvisor-ds.yaml
@@ -0,0 +1,74 @@
+---
+# Copyright 2018-present Open Networking Foundation
+#
+# 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.
+
+{{- if .Values.cadvisor.enabled }}
+
+apiVersion: apps/v1
+kind: DaemonSet
+metadata:
+ name: cadvisor-ds
+ annotations:
+ seccomp.security.alpha.kubernetes.io/pod: 'docker/default'
+spec:
+ selector:
+ matchLabels:
+ name: cadvisor
+ template:
+ metadata:
+ labels:
+ name: cadvisor
+ spec:
+ hostNetwork: true
+ containers:
+ - name: cadvisor
+ image: {{ .Values.cadvisor.image }}
+ args:
+ - --port={{ .Values.cadvisor.nodePort }}
+ volumeMounts:
+ - name: rootfs
+ mountPath: /rootfs
+ readOnly: true
+ - name: var-run
+ mountPath: /var/run
+ readOnly: true
+ - name: sys
+ mountPath: /sys
+ readOnly: true
+ - name: docker
+ mountPath: /var/lib/docker
+ readOnly: true
+ - name: disk
+ mountPath: /dev/disk
+ readOnly: true
+ automountServiceAccountToken: false
+ terminationGracePeriodSeconds: 30
+ volumes:
+ - name: rootfs
+ hostPath:
+ path: /
+ - name: var-run
+ hostPath:
+ path: /var/run
+ - name: sys
+ hostPath:
+ path: /sys
+ - name: docker
+ hostPath:
+ path: /var/lib/docker
+ - name: disk
+ hostPath:
+ path: /dev/disk
+
+{{- end }}
diff --git a/mcord/mcord-cdn-monitoring/templates/grafana-cfg.yaml b/mcord/mcord-cdn-monitoring/templates/grafana-cfg.yaml
new file mode 100644
index 0000000..dc76aef
--- /dev/null
+++ b/mcord/mcord-cdn-monitoring/templates/grafana-cfg.yaml
@@ -0,0 +1,78 @@
+---
+# Copyright 2018-present Open Networking Foundation
+#
+# 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.
+
+{{- if .Values.grafana.enabled }}
+
+apiVersion: v1
+kind: ConfigMap
+metadata:
+ name: grafana-config
+data:
+ grafana.ini: |
+{{ .Files.Get "configs/grafana.ini" | indent 4 }}
+ ldap.toml: |
+{{ .Files.Get "configs/ldap.toml" | indent 4 }}
+
+---
+
+apiVersion: v1
+kind: ConfigMap
+metadata:
+ name: grafana-dashs
+ labels:
+ grafana_dashboard: "1"
+data:
+ cdn_metrics.json: |
+{{ .Files.Get "configs/cdn-metrics.json" | indent 4 }}
+
+---
+
+apiVersion: v1
+kind: ConfigMap
+metadata:
+ name: grafana-dash-provider
+ labels:
+ grafana_dashboard: "1"
+data:
+ dashboard.yaml: |
+ apiVersion: 1
+
+ providers:
+ - name: 'default'
+ orgId: 1
+ folder: ''
+ type: file
+ disableDeletion: false
+ updateIntervalSeconds: 3
+ options:
+ path: /etc/grafana/dashboards
+---
+
+apiVersion: v1
+kind: ConfigMap
+metadata:
+ name: grafana-datasources-provider
+data:
+ prometheus-datasource.yaml: |
+ datasources:
+ - access: 'proxy'
+ editable: true
+ is_default: true
+ name: 'prom'
+ org_id: 1
+ type: 'prometheus'
+ url: http://{{ .Values.prometheus_host }}:{{ .Values.prometheus.nodePort }}
+
+{{- end }}
\ No newline at end of file
diff --git a/mcord/mcord-cdn-monitoring/templates/grafana-rc.yaml b/mcord/mcord-cdn-monitoring/templates/grafana-rc.yaml
new file mode 100644
index 0000000..ef9c5b7
--- /dev/null
+++ b/mcord/mcord-cdn-monitoring/templates/grafana-rc.yaml
@@ -0,0 +1,67 @@
+---
+# Copyright 2018-present Open Networking Foundation
+#
+# 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.
+
+{{- if .Values.grafana.enabled }}
+
+apiVersion: v1
+kind: ReplicationController
+metadata:
+ name: grafana-cdn-rc
+spec:
+ replicas: 1
+ selector:
+ app: grafana-cdn
+ template:
+ metadata:
+ name: grafana-cdn
+ labels:
+ app: grafana-cdn
+ spec:
+ nodeSelector:
+ kubernetes.io/hostname: {{ .Values.grafana.node_selector }}
+ containers:
+ - name: grafana
+ image: {{ .Values.grafana.image }}
+ env:
+ - name: ADMIN_USER
+ value: {{ .Values.grafana.adminUser }}
+ - name: ADMIN_PASS
+ value: {{ .Values.grafana.adminPassword }}
+ ports:
+ - containerPort: 3000
+ volumeMounts:
+ - mountPath: /etc/grafana/
+ name: grafana-volume
+ - mountPath: /etc/grafana/dashboards
+ name: grafana-dashboards
+ - mountPath: /etc/grafana/provisioning/dashboards
+ name: dashboards-provider
+ - mountPath: /etc/grafana/provisioning/datasources
+ name: datasources-provider
+ volumes:
+ - name: grafana-volume
+ configMap:
+ name: grafana-config
+ - name: grafana-dashboards
+ configMap:
+ name: grafana-dashs
+ - name: dashboards-provider
+ configMap:
+ name: grafana-dash-provider
+ - name: datasources-provider
+ configMap:
+ name: grafana-datasources-provider
+
+{{- end }}
diff --git a/mcord/mcord-cdn-monitoring/templates/grafana-svc.yaml b/mcord/mcord-cdn-monitoring/templates/grafana-svc.yaml
new file mode 100644
index 0000000..3f09093
--- /dev/null
+++ b/mcord/mcord-cdn-monitoring/templates/grafana-svc.yaml
@@ -0,0 +1,33 @@
+---
+# Copyright 2018-present Open Networking Foundation
+#
+# 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.
+
+{{- if .Values.grafana.enabled }}
+
+apiVersion: v1
+kind: Service
+metadata:
+ name: grafana-cdn-service
+spec:
+ selector:
+ app: grafana-cdn
+ type: NodePort
+ ports:
+ - name: grafana
+ port: 3000
+ protocol: TCP
+ targetPort: 3000
+ nodePort: {{ .Values.grafana.nodePort }}
+
+{{- end }}
\ No newline at end of file
diff --git a/mcord/mcord-cdn-monitoring/templates/prometheus-cfg.yaml b/mcord/mcord-cdn-monitoring/templates/prometheus-cfg.yaml
new file mode 100644
index 0000000..158fce1
--- /dev/null
+++ b/mcord/mcord-cdn-monitoring/templates/prometheus-cfg.yaml
@@ -0,0 +1,40 @@
+---
+# Copyright 2018-present Open Networking Foundation
+#
+# 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.
+
+{{- if .Values.prometheus.enabled }}
+
+apiVersion: v1
+kind: ConfigMap
+metadata:
+ name: prometheus-config
+data:
+ prometheus.yml: |
+ global:
+ scrape_interval: {{ .Values.prometheus.interval }} # By default, scrape targets every 15 seconds.
+ evaluation_interval: {{ .Values.prometheus.interval }} # By default, scrape targets every 15 seconds.
+ # scrape_timeout is set to the global default (10s).
+
+ external_labels:
+ monitor: 'monitoring'
+
+ scrape_configs:
+ - job_name: 'prometheus'
+ static_configs:
+ - targets: ['{{ .Values.prometheus_host }}:{{ .Values.prometheus.nodePort }}']
+ - job_name: 'kube-metrics'
+ static_configs:
+ - targets: ['{{ .Values.cdn_remote_host }}:{{ .Values.cadvisor.nodePort }}', '{{ .Values.cdn_local_host }}:{{ .Values.cadvisor.nodePort }}']
+
+{{- end }}
\ No newline at end of file
diff --git a/mcord/mcord-cdn-monitoring/templates/prometheus-rc.yaml b/mcord/mcord-cdn-monitoring/templates/prometheus-rc.yaml
new file mode 100644
index 0000000..818c582
--- /dev/null
+++ b/mcord/mcord-cdn-monitoring/templates/prometheus-rc.yaml
@@ -0,0 +1,49 @@
+---
+# Copyright 2018-present Open Networking Foundation
+#
+# 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.
+
+{{- if .Values.prometheus.enabled }}
+
+apiVersion: v1
+kind: ReplicationController
+metadata:
+ name: prometheus-cdn-rc
+spec:
+ replicas: 1
+ selector:
+ app: prometheus-cdn
+ template:
+ metadata:
+ name: prometheus-cdn
+ labels:
+ app: prometheus-cdn
+ spec:
+ nodeSelector:
+ kubernetes.io/hostname: {{ .Values.prometheus.node_selector }}
+ containers:
+ - args:
+ - --config.file=/etc/prometheus/config_out/prometheus.yml
+ name: prometheus
+ image: {{ .Values.prometheus.image }}
+ ports:
+ - containerPort: 9090
+ volumeMounts:
+ - mountPath: /etc/prometheus/config_out
+ name: prometheus-volume
+ volumes:
+ - name: prometheus-volume
+ configMap:
+ name: prometheus-config
+
+{{- end }}
\ No newline at end of file
diff --git a/mcord/mcord-cdn-monitoring/templates/prometheus-svc.yaml b/mcord/mcord-cdn-monitoring/templates/prometheus-svc.yaml
new file mode 100644
index 0000000..b9ebf6c
--- /dev/null
+++ b/mcord/mcord-cdn-monitoring/templates/prometheus-svc.yaml
@@ -0,0 +1,33 @@
+---
+# Copyright 2018-present Open Networking Foundation
+#
+# 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.
+
+{{- if .Values.prometheus.enabled }}
+
+apiVersion: v1
+kind: Service
+metadata:
+ name: prometheus-cdn-service
+spec:
+ selector:
+ app: prometheus-cdn
+ type: NodePort
+ ports:
+ - name: prometheus
+ nodePort: {{ .Values.prometheus.nodePort }}
+ port: 9090
+ protocol: TCP
+ targetPort: 9090
+
+{{- end }}
\ No newline at end of file