From 7cb9c0b9e9ee87f962c1a678471f24b14b02ec85 Mon Sep 17 00:00:00 2001 From: Rajamohan Raj Date: Tue, 17 Mar 2020 20:57:50 +0000 Subject: Added the new plugin_collection_v2 script. The script calls the major creation APIs in v2 starting from project api, composite app, composite profile, generic placement intent & deployment intent. This should be used every time we need to test the Instantiation code. Also added the helm charts for composite app consisting of collectd and prometheus. Issue-ID: MULTICLOUD-1035 Signed-off-by: Rajamohan Raj Change-Id: I95237c234cca674dd54f4ef7527083b5cf3e0a55 --- kud/tests/vnfs/comp-app/collection/.helmignore | 22 ++++++ .../collection/app1/helm/collectd/.helmignore | 21 ++++++ .../collection/app1/helm/collectd/Chart.yaml | 19 +++++ .../app1/helm/collectd/resources/collectd.conf | 44 ++++++++++++ .../app1/helm/collectd/templates/NOTES.txt | 34 +++++++++ .../app1/helm/collectd/templates/_helpers.tpl | 25 +++++++ .../app1/helm/collectd/templates/configmap.yaml | 26 +++++++ .../app1/helm/collectd/templates/daemonset.yaml | 84 ++++++++++++++++++++++ .../app1/helm/collectd/templates/service.yaml | 32 +++++++++ .../collection/app1/helm/collectd/values.yaml | 78 ++++++++++++++++++++ .../comp-app/collection/app1/profile/manifest.yaml | 4 ++ .../collection/app1/profile/override_values.yaml | 9 +++ .../collection/app2/helm/prometheus/.helmignore | 22 ++++++ .../collection/app2/helm/prometheus/Chart.yaml | 5 ++ .../app2/helm/prometheus/templates/NOTES.txt | 15 ++++ .../app2/helm/prometheus/templates/_helpers.tpl | 57 +++++++++++++++ .../app2/helm/prometheus/templates/prometheus.yaml | 19 +++++ .../app2/helm/prometheus/templates/role.yaml | 21 ++++++ .../helm/prometheus/templates/rolebinding.yaml | 17 +++++ .../app2/helm/prometheus/templates/service.yaml | 38 ++++++++++ .../helm/prometheus/templates/serviceaccount.yaml | 11 +++ .../helm/prometheus/templates/servicemonitor.yaml | 30 ++++++++ .../collection/app2/helm/prometheus/values.yaml | 69 ++++++++++++++++++ .../comp-app/collection/app2/profile/manifest.yaml | 4 ++ .../collection/app2/profile/override_values.yaml | 6 ++ 25 files changed, 712 insertions(+) create mode 100644 kud/tests/vnfs/comp-app/collection/.helmignore create mode 100644 kud/tests/vnfs/comp-app/collection/app1/helm/collectd/.helmignore create mode 100644 kud/tests/vnfs/comp-app/collection/app1/helm/collectd/Chart.yaml create mode 100644 kud/tests/vnfs/comp-app/collection/app1/helm/collectd/resources/collectd.conf create mode 100644 kud/tests/vnfs/comp-app/collection/app1/helm/collectd/templates/NOTES.txt create mode 100644 kud/tests/vnfs/comp-app/collection/app1/helm/collectd/templates/_helpers.tpl create mode 100644 kud/tests/vnfs/comp-app/collection/app1/helm/collectd/templates/configmap.yaml create mode 100644 kud/tests/vnfs/comp-app/collection/app1/helm/collectd/templates/daemonset.yaml create mode 100644 kud/tests/vnfs/comp-app/collection/app1/helm/collectd/templates/service.yaml create mode 100644 kud/tests/vnfs/comp-app/collection/app1/helm/collectd/values.yaml create mode 100644 kud/tests/vnfs/comp-app/collection/app1/profile/manifest.yaml create mode 100644 kud/tests/vnfs/comp-app/collection/app1/profile/override_values.yaml create mode 100644 kud/tests/vnfs/comp-app/collection/app2/helm/prometheus/.helmignore create mode 100644 kud/tests/vnfs/comp-app/collection/app2/helm/prometheus/Chart.yaml create mode 100644 kud/tests/vnfs/comp-app/collection/app2/helm/prometheus/templates/NOTES.txt create mode 100644 kud/tests/vnfs/comp-app/collection/app2/helm/prometheus/templates/_helpers.tpl create mode 100644 kud/tests/vnfs/comp-app/collection/app2/helm/prometheus/templates/prometheus.yaml create mode 100644 kud/tests/vnfs/comp-app/collection/app2/helm/prometheus/templates/role.yaml create mode 100644 kud/tests/vnfs/comp-app/collection/app2/helm/prometheus/templates/rolebinding.yaml create mode 100644 kud/tests/vnfs/comp-app/collection/app2/helm/prometheus/templates/service.yaml create mode 100644 kud/tests/vnfs/comp-app/collection/app2/helm/prometheus/templates/serviceaccount.yaml create mode 100644 kud/tests/vnfs/comp-app/collection/app2/helm/prometheus/templates/servicemonitor.yaml create mode 100644 kud/tests/vnfs/comp-app/collection/app2/helm/prometheus/values.yaml create mode 100644 kud/tests/vnfs/comp-app/collection/app2/profile/manifest.yaml create mode 100644 kud/tests/vnfs/comp-app/collection/app2/profile/override_values.yaml (limited to 'kud/tests/vnfs/comp-app/collection') diff --git a/kud/tests/vnfs/comp-app/collection/.helmignore b/kud/tests/vnfs/comp-app/collection/.helmignore new file mode 100644 index 00000000..50af0317 --- /dev/null +++ b/kud/tests/vnfs/comp-app/collection/.helmignore @@ -0,0 +1,22 @@ +# 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 +*~ +# Various IDEs +.project +.idea/ +*.tmproj +.vscode/ diff --git a/kud/tests/vnfs/comp-app/collection/app1/helm/collectd/.helmignore b/kud/tests/vnfs/comp-app/collection/app1/helm/collectd/.helmignore new file mode 100644 index 00000000..f0c13194 --- /dev/null +++ b/kud/tests/vnfs/comp-app/collection/app1/helm/collectd/.helmignore @@ -0,0 +1,21 @@ +# 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 +*~ +# Various IDEs +.project +.idea/ +*.tmproj diff --git a/kud/tests/vnfs/comp-app/collection/app1/helm/collectd/Chart.yaml b/kud/tests/vnfs/comp-app/collection/app1/helm/collectd/Chart.yaml new file mode 100644 index 00000000..fcdcfde9 --- /dev/null +++ b/kud/tests/vnfs/comp-app/collection/app1/helm/collectd/Chart.yaml @@ -0,0 +1,19 @@ +# Copyright 2019 Intel Corporation, Inc +# +# 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 +appVersion: "7.1.0" +description: Collectd Helm Chart +name: collectd +version: 0.2.0 diff --git a/kud/tests/vnfs/comp-app/collection/app1/helm/collectd/resources/collectd.conf b/kud/tests/vnfs/comp-app/collection/app1/helm/collectd/resources/collectd.conf new file mode 100644 index 00000000..b023b320 --- /dev/null +++ b/kud/tests/vnfs/comp-app/collection/app1/helm/collectd/resources/collectd.conf @@ -0,0 +1,44 @@ +FQDNLookup false +LoadPlugin cpu +LoadPlugin memory +LoadPlugin cpufreq +LoadPlugin disk +LoadPlugin ethstat +LoadPlugin ipc +LoadPlugin ipmi +LoadPlugin load +LoadPlugin numa +LoadPlugin processes +LoadPlugin df +LoadPlugin turbostat +LoadPlugin uptime +LoadPlugin contextswitch +LoadPlugin irq +LoadPlugin df +LoadPlugin swap +LoadPlugin write_prometheus + +LoadPlugin logfile + + LogLevel info + File "/var/log/collectd.log" + Timestamp true + PrintSeverity false + + + Interval 5 + ReportByState false + ReportByCpu false + + + + Interval 30 + ValuesAbsolute false + ValuesPercentage true + + + + Port "{{ .Values.collectd_prometheus.service.targetPort }}" + + +#Last line (collectd requires ā€˜\nā€™ at the last line) diff --git a/kud/tests/vnfs/comp-app/collection/app1/helm/collectd/templates/NOTES.txt b/kud/tests/vnfs/comp-app/collection/app1/helm/collectd/templates/NOTES.txt new file mode 100644 index 00000000..06ca128b --- /dev/null +++ b/kud/tests/vnfs/comp-app/collection/app1/helm/collectd/templates/NOTES.txt @@ -0,0 +1,34 @@ +# Copyright (c) 2019 Intel Corporation. +# +# 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. + + +1. Get the application URL by running these commands: +{{- if .Values.ingress.enabled }} +{{- range .Values.ingress.hosts }} + http://{{ . }} +{{- end }} +{{- else if contains "NodePort" .Values.collectd_prometheus.service.type }} + NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "name" . }}) + NODE_IPS=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[*].status.addresses[0].address}") + visit http://NODE_IP:NODE_PORT +{{- else if contains "LoadBalancer" .Values.collectd_prometheus.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 svc -w {{ include "name" . }}' + export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ template "name" . }} -o jsonpath='{.status.loadBalancer.ingress[0].ip}') + echo http://$SERVICE_IP:{{ .Values.service.externalPort }} +{{- else if contains "ClusterIP" .Values.collectd_prometheus.service.type }} + CLUSTER_NODE_IPS=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[*].status.addresses[0].address}") + CLUSTER_NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].port}" services {{ include "name" . }}) + visit http://CLUSTER_NODE_IP:CLUSTER_NODE_PORT +{{- end }} diff --git a/kud/tests/vnfs/comp-app/collection/app1/helm/collectd/templates/_helpers.tpl b/kud/tests/vnfs/comp-app/collection/app1/helm/collectd/templates/_helpers.tpl new file mode 100644 index 00000000..b5e98086 --- /dev/null +++ b/kud/tests/vnfs/comp-app/collection/app1/helm/collectd/templates/_helpers.tpl @@ -0,0 +1,25 @@ +{{/* vim: set filetype=mustache: */}} +{{/* +Expand the name of the chart. +*/}} +{{- define "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). +*/}} +{{- define "fullname" -}} +{{- $name := default .Chart.Name .Values.nameOverride -}} +{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}} +{{- end -}} + +{{/* Workaround for https://github.com/helm/helm/issues/3117 */}} +{{- define "rangeskipempty" -}} +{{- range $key, $value := . }} +{{- if $value }} +{{ $key }}: {{ $value }} +{{- end }} +{{- end }} +{{- end }} \ No newline at end of file diff --git a/kud/tests/vnfs/comp-app/collection/app1/helm/collectd/templates/configmap.yaml b/kud/tests/vnfs/comp-app/collection/app1/helm/collectd/templates/configmap.yaml new file mode 100644 index 00000000..26d0fb5d --- /dev/null +++ b/kud/tests/vnfs/comp-app/collection/app1/helm/collectd/templates/configmap.yaml @@ -0,0 +1,26 @@ +{{/* +# Copyright 2019 Intel Corporation, Inc +# +# 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: {{ template "fullname" . }}-config + labels: + app: {{ template "name" . }} + chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }} + release: {{ .Release.Name }} +data: + {{- tpl (.Files.Glob "resources/*").AsConfig . | nindent 2 }} diff --git a/kud/tests/vnfs/comp-app/collection/app1/helm/collectd/templates/daemonset.yaml b/kud/tests/vnfs/comp-app/collection/app1/helm/collectd/templates/daemonset.yaml new file mode 100644 index 00000000..bc686381 --- /dev/null +++ b/kud/tests/vnfs/comp-app/collection/app1/helm/collectd/templates/daemonset.yaml @@ -0,0 +1,84 @@ +{{/* +# Copyright 2019 Intel Corporation, Inc +# +# 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: extensions/v1beta1 +kind: DaemonSet +metadata: + name: {{ template "fullname" . }} + annotations: + checksum/config: {{ include (print $.Template.BasePath "/configmap.yaml") . | sha256sum }} + labels: + app: {{ template "name" . }} + chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }} + release: {{ .Release.Name }} +spec: + replicas: {{ .Values.replicaCount }} + updateStrategy: + type: RollingUpdate + template: + metadata: + labels: + app: {{ template "name" . }} + collector: collectd + release: {{ .Release.Name }} + spec: + hostNetwork: true + {{- if .Values.serviceAccountName }} + serviceAccountName: {{ .Values.serviceAccountName }} + {{- end }} +{{- if .Values.tolerations }} + tolerations: +{{ toYaml .Values.tolerations | trim | indent 8 }} +{{- end }} +{{- if .Values.nodeSelector }} + nodeSelector: +{{ toYaml .Values.nodeSelector | trim | indent 8 }} +{{- end }} + containers: + - name: {{ .Chart.Name }} + image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + securityContext: + allowPrivilegeEscalation: true + privileged: true +{{- if .Values.env }} + env: +{{ toYaml .Values.env | trim | indent 10 }} +{{- end }} +{{- if .Values.command }} + command: +{{ toYaml .Values.command | trim | indent 10 }} +{{- end }} +{{- if .Values.args }} + args: +{{ toYaml .Values.args | trim | indent 10 }} +{{- end }} + volumeMounts: + - name: {{ template "fullname" . }}-config + mountPath: {{ .Values.configMountPath }} +{{- if .Values.volumeMounts }} +{{ toYaml .Values.volumeMounts | trim | indent 10 }} +{{- end }} + resources: +{{- toYaml .Values.resources | trim | indent 12}} + volumes: + - name: {{ template "fullname" . }}-config + configMap: + name: {{ template "fullname" . }}-config + defaultMode: 0744 +{{- if .Values.volumeMounts }} +{{ toYaml .Values.volumes | indent 6 }} +{{- end }} diff --git a/kud/tests/vnfs/comp-app/collection/app1/helm/collectd/templates/service.yaml b/kud/tests/vnfs/comp-app/collection/app1/helm/collectd/templates/service.yaml new file mode 100644 index 00000000..7571715d --- /dev/null +++ b/kud/tests/vnfs/comp-app/collection/app1/helm/collectd/templates/service.yaml @@ -0,0 +1,32 @@ +{{/* +# Copyright 2019 Intel Corporation, Inc +# +# 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: collectd + labels: + app: collectd + release: {{ .Release.Name }} +spec: + ports: + - name: collectd-prometheus + port: {{ .Values.collectd_prometheus.service.port }} + protocol: TCP + targetPort: {{ .Values.collectd_prometheus.service.targetPort }} + selector: +{{ include "rangeskipempty" .Values.collectd_prometheus.service.selector | indent 4 }} + type: ClusterIP diff --git a/kud/tests/vnfs/comp-app/collection/app1/helm/collectd/values.yaml b/kud/tests/vnfs/comp-app/collection/app1/helm/collectd/values.yaml new file mode 100644 index 00000000..41d63cbf --- /dev/null +++ b/kud/tests/vnfs/comp-app/collection/app1/helm/collectd/values.yaml @@ -0,0 +1,78 @@ +# Default values for collectd. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. +ingress: + enabled: false +image: + repository: opnfv/barometer-collectd + tag: latest + pullPolicy: IfNotPresent +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 + + +#serviceAccountName: cmk-serviceaccount + +# Uncomment the following tolerations and/or nodeSelector to select the node collectd to be deployed +#tolerations: +# - operator: "Exists" +#nodeSelector: +# vcmts: "true" + +# Uncomment the following to set environment, command and args for the collectd container +#env: +#- name: CMK_PROC_FS +# value: "/host/proc" +#command: +#- "/bin/bash" +#- "-c" +#args: [ "/opt/bin/cmk isolate --conf-dir=/etc/cmk --pool=infra /script/collectd.sh" ] + +# all the files under the directory resource will be mount into the directory specified by 'configMountPath' inside the container. +# Besides that, users can specify any mount by using the 'volumeMounts' and 'volumes'. +configMountPath: /opt/collectd/etc +volumeMounts: +- name: proc + mountPath: /mnt/proc + readOnly: true +- name: root + mountPath: /hostfs + readOnly: true +- name: etc + mountPath: /mnt/etc + readOnly: true +- name: run + mountPath: /var/run/docker.sock + +volumes: +- name: proc + hostPath: + path: /proc +- name: root + hostPath: + path: / +- name: etc + hostPath: + path: /etc +- name: run + hostPath: + path: /var/run/docker.sock + +collectd_prometheus: + service: + type: ClusterIP + name: collectd + port: 9103 + targetPort: 9103 + selector: + app: collectd + collector: collectd diff --git a/kud/tests/vnfs/comp-app/collection/app1/profile/manifest.yaml b/kud/tests/vnfs/comp-app/collection/app1/profile/manifest.yaml new file mode 100644 index 00000000..4d381d02 --- /dev/null +++ b/kud/tests/vnfs/comp-app/collection/app1/profile/manifest.yaml @@ -0,0 +1,4 @@ +--- +version: v1 +type: + values: "override_values.yaml" diff --git a/kud/tests/vnfs/comp-app/collection/app1/profile/override_values.yaml b/kud/tests/vnfs/comp-app/collection/app1/profile/override_values.yaml new file mode 100644 index 00000000..304ae5de --- /dev/null +++ b/kud/tests/vnfs/comp-app/collection/app1/profile/override_values.yaml @@ -0,0 +1,9 @@ +collectd_prometheus: + service: + type: ClusterIP + name: collectd-override + port: 9103 + targetPort: 9103 + selector: + app: collectd + collector: collectd \ No newline at end of file diff --git a/kud/tests/vnfs/comp-app/collection/app2/helm/prometheus/.helmignore b/kud/tests/vnfs/comp-app/collection/app2/helm/prometheus/.helmignore new file mode 100644 index 00000000..50af0317 --- /dev/null +++ b/kud/tests/vnfs/comp-app/collection/app2/helm/prometheus/.helmignore @@ -0,0 +1,22 @@ +# 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 +*~ +# Various IDEs +.project +.idea/ +*.tmproj +.vscode/ diff --git a/kud/tests/vnfs/comp-app/collection/app2/helm/prometheus/Chart.yaml b/kud/tests/vnfs/comp-app/collection/app2/helm/prometheus/Chart.yaml new file mode 100644 index 00000000..6e7ddfbc --- /dev/null +++ b/kud/tests/vnfs/comp-app/collection/app2/helm/prometheus/Chart.yaml @@ -0,0 +1,5 @@ +apiVersion: v1 +appVersion: "1.0" +description: Prometheus instance with remote storage integrations. +name: prometheus +version: 0.1.0 diff --git a/kud/tests/vnfs/comp-app/collection/app2/helm/prometheus/templates/NOTES.txt b/kud/tests/vnfs/comp-app/collection/app2/helm/prometheus/templates/NOTES.txt new file mode 100644 index 00000000..f8882883 --- /dev/null +++ b/kud/tests/vnfs/comp-app/collection/app2/helm/prometheus/templates/NOTES.txt @@ -0,0 +1,15 @@ +1. Get the application URL by running these commands: +{{ if contains "NodePort" .Values.prometheus.service.type }} + export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "prometheus.fullname" . }}-prometheus) + 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.prometheus.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 svc -w {{ include "prometheus.fullname" . }}' + export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "prometheus.fullname" . }} -o jsonpath='{.status.loadBalancer.ingress[0].ip}') + echo http://$SERVICE_IP:{{ .Values.service.port }} +{{- else if contains "ClusterIP" .Values.prometheus.service.type }} + export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "prometheus.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}") + echo "Visit http://127.0.0.1:9090 to use your application" + kubectl port-forward $POD_NAME 9090:80 +{{- end }} diff --git a/kud/tests/vnfs/comp-app/collection/app2/helm/prometheus/templates/_helpers.tpl b/kud/tests/vnfs/comp-app/collection/app2/helm/prometheus/templates/_helpers.tpl new file mode 100644 index 00000000..17b7e7bd --- /dev/null +++ b/kud/tests/vnfs/comp-app/collection/app2/helm/prometheus/templates/_helpers.tpl @@ -0,0 +1,57 @@ +{{/* vim: set filetype=mustache: */}} +{{/* +Expand the name of the chart. +*/}} +{{- define "prometheus.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 "prometheus.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 "prometheus.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} +{{- end -}} + +{{/* Create chart name and version as used by the chart label. */}} +{{- define "prometheus.chartref" -}} +{{- replace "+" "_" .Chart.Version | printf "%s-%s" .Chart.Name -}} +{{- end }} + +{{/* Generate basic labels */}} +{{- define "prometheus.labels" }} +chart: {{ template "prometheus.chartref" . }} +release: {{ .Release.Name | quote }} +heritage: {{ .Release.Service | quote }} +{{- if .Values.commonLabels}} +{{ toYaml .Values.commonLabels }} +{{- end }} +{{- end }} + + +{{/* Create the name of prometheus service account to use */}} +{{- define "prometheus.serviceAccountName" -}} +{{- if .Values.prometheus.serviceAccount.create -}} + {{ default (include "prometheus.fullname" .) .Values.prometheus.serviceAccount.name }} +{{- else -}} + {{ default "default" .Values.prometheus.serviceAccount.name }} +{{- end -}} +{{- end -}} \ No newline at end of file diff --git a/kud/tests/vnfs/comp-app/collection/app2/helm/prometheus/templates/prometheus.yaml b/kud/tests/vnfs/comp-app/collection/app2/helm/prometheus/templates/prometheus.yaml new file mode 100644 index 00000000..53494920 --- /dev/null +++ b/kud/tests/vnfs/comp-app/collection/app2/helm/prometheus/templates/prometheus.yaml @@ -0,0 +1,19 @@ +apiVersion: monitoring.coreos.com/v1 +kind: Prometheus +metadata: + name: {{ template "prometheus.fullname" . }}-prometheus + labels: + app: {{ template "prometheus.name" . }}-prometheus + "helm.sh/hook": post-install + "helm.sh/hook-weight": "2" +spec: + serviceAccountName: {{ template "prometheus.serviceAccountName" . }} + serviceMonitorSelector: + matchLabels: + app: {{ template "prometheus.name" . }}-prometheus + release: {{ .Release.Name }} + serviceMonitorNamespaceSelector: + matchNames: + - {{ .Release.Namespace | quote }} + resources: +{{ toYaml .Values.prometheus.resources | indent 4 }} diff --git a/kud/tests/vnfs/comp-app/collection/app2/helm/prometheus/templates/role.yaml b/kud/tests/vnfs/comp-app/collection/app2/helm/prometheus/templates/role.yaml new file mode 100644 index 00000000..dfb932d8 --- /dev/null +++ b/kud/tests/vnfs/comp-app/collection/app2/helm/prometheus/templates/role.yaml @@ -0,0 +1,21 @@ +apiVersion: rbac.authorization.k8s.io/v1 +kind: Role +apiVersion: rbac.authorization.k8s.io/v1 +kind: Role +metadata: + name: {{ template "prometheus.fullname" . }}-prometheus + labels: + app: {{ template "prometheus.name" . }}-prometheus +{{ include "prometheus.labels" . | indent 4 }} +rules: +- apiGroups: + - "" + resources: + - nodes + - services + - endpoints + - pods + verbs: + - get + - list + - watch \ No newline at end of file diff --git a/kud/tests/vnfs/comp-app/collection/app2/helm/prometheus/templates/rolebinding.yaml b/kud/tests/vnfs/comp-app/collection/app2/helm/prometheus/templates/rolebinding.yaml new file mode 100644 index 00000000..04932ee1 --- /dev/null +++ b/kud/tests/vnfs/comp-app/collection/app2/helm/prometheus/templates/rolebinding.yaml @@ -0,0 +1,17 @@ +apiVersion: rbac.authorization.k8s.io/v1 +kind: RoleBinding +apiVersion: rbac.authorization.k8s.io/v1 +kind: RoleBinding +metadata: + name: {{ template "prometheus.fullname" . }}-prometheus + labels: + app: {{ template "prometheus.name" . }}-prometheus +{{ include "prometheus.labels" . | indent 4 }} +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: Role + name: {{ template "prometheus.fullname" . }}-prometheus +subjects: +- kind: ServiceAccount + name: {{ template "prometheus.serviceAccountName" . }} + namespace: {{ .Release.Namespace }} \ No newline at end of file diff --git a/kud/tests/vnfs/comp-app/collection/app2/helm/prometheus/templates/service.yaml b/kud/tests/vnfs/comp-app/collection/app2/helm/prometheus/templates/service.yaml new file mode 100644 index 00000000..0114ed2e --- /dev/null +++ b/kud/tests/vnfs/comp-app/collection/app2/helm/prometheus/templates/service.yaml @@ -0,0 +1,38 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ template "prometheus.fullname" . }}-prometheus + labels: + app: {{ template "prometheus.name" . }}-prometheus +{{- if .Values.prometheus.service.annotations }} + annotations: +{{ toYaml .Values.prometheus.service.annotations | indent 4 }} +{{- end }} +spec: +{{- if .Values.prometheus.service.clusterIP }} + clusterIP: {{ .Values.prometheus.service.clusterIP }} +{{- end }} +{{- if .Values.prometheus.service.externalIPs }} + externalIPs: +{{ toYaml .Values.prometheus.service.externalIPs | indent 4 }} +{{- end }} +{{- if .Values.prometheus.service.loadBalancerIP }} + loadBalancerIP: {{ .Values.prometheus.service.loadBalancerIP }} +{{- end }} +{{- if .Values.prometheus.service.loadBalancerSourceRanges }} + loadBalancerSourceRanges: + {{- range $cidr := .Values.prometheus.service.loadBalancerSourceRanges }} + - {{ $cidr }} + {{- end }} +{{- end }} + ports: + - name: web + {{- if eq .Values.prometheus.service.type "NodePort" }} + nodePort: {{ .Values.global.nodePortPrefix }}{{ .Values.prometheus.service.nodePort }} + {{- end }} + port: 9090 + targetPort: web + selector: + app: prometheus + prometheus: {{ template "prometheus.fullname" . }}-prometheus + type: "{{ .Values.prometheus.service.type }}" diff --git a/kud/tests/vnfs/comp-app/collection/app2/helm/prometheus/templates/serviceaccount.yaml b/kud/tests/vnfs/comp-app/collection/app2/helm/prometheus/templates/serviceaccount.yaml new file mode 100644 index 00000000..82437523 --- /dev/null +++ b/kud/tests/vnfs/comp-app/collection/app2/helm/prometheus/templates/serviceaccount.yaml @@ -0,0 +1,11 @@ +{{- if .Values.prometheus.serviceAccount.create }} +apiVersion: v1 +kind: ServiceAccount +metadata: + name: {{ template "prometheus.serviceAccountName" . }} + labels: + app: {{ template "prometheus.name" . }}-prometheus +{{ include "prometheus.labels" . | indent 4 }} +imagePullSecrets: +{{ toYaml .Values.global.imagePullSecrets | indent 2 }} +{{- end }} diff --git a/kud/tests/vnfs/comp-app/collection/app2/helm/prometheus/templates/servicemonitor.yaml b/kud/tests/vnfs/comp-app/collection/app2/helm/prometheus/templates/servicemonitor.yaml new file mode 100644 index 00000000..ea2b81b6 --- /dev/null +++ b/kud/tests/vnfs/comp-app/collection/app2/helm/prometheus/templates/servicemonitor.yaml @@ -0,0 +1,30 @@ +{{- if .Values.prometheus.additionalServiceMonitors }} +apiVersion: v1 +kind: List +items: +{{- range .Values.prometheus.additionalServiceMonitors }} + - apiVersion: "monitoring.coreos.com/v1" + kind: ServiceMonitor + metadata: + name: {{ .name }} + "helm.sh/hook": post-install + "helm.sh/hook-weight": "1" + labels: + app: {{ template "prometheus.name" $ }}-prometheus +{{ include "prometheus.labels" $ | indent 8 }} + {{- if .additionalLabels }} +{{ toYaml .additionalLabels | indent 8 }} + {{- end }} + spec: + endpoints: +{{ toYaml .endpoints | indent 8 }} + {{- if .jobLabel }} + jobLabel: {{ .jobLabel }} + {{- end }} + namespaceSelector: + matchNames: + - {{ $.Release.Namespace | quote }} + selector: +{{ toYaml .selector | indent 8 }} release: {{ $.Release.Name | quote }} +{{- end }} +{{- end }} diff --git a/kud/tests/vnfs/comp-app/collection/app2/helm/prometheus/values.yaml b/kud/tests/vnfs/comp-app/collection/app2/helm/prometheus/values.yaml new file mode 100644 index 00000000..e35c6735 --- /dev/null +++ b/kud/tests/vnfs/comp-app/collection/app2/helm/prometheus/values.yaml @@ -0,0 +1,69 @@ +## Deploy a Prometheus instance +## +prometheus: + serviceAccount: + create: true + name: "" + additionalServiceMonitors: + - name: service-monitor-collectd + additionalLabels: + collector: collectd + jobLabel: collectd + selector: + matchLabels: + app: collectd + endpoints: + - port: collectd-prometheus + interval: 10s + path: /metrics + - name: service-monitor-node-exporter + additionalLabels: + collector: prometheus-node-exporter + jobLabel: node-exporter + selector: + matchLabels: + app: prometheus-node-exporter + endpoints: + - port: metrics + interval: 30s + - name: service-monitor-cadvisor + additionalLabels: + collector: cadvisor + jobLabel: cadvisor + selector: + matchLabels: + app: cadvisor + endpoints: + - port: cadvisor-prometheus + interval: 10s + path: /metrics + + resources: {} + service: + type: ClusterIP + annotations: {} + labels: {} + clusterIP: "" + + ## To be used with a proxy extraContainer port + targetPort: 9090 + + ## List of IP addresses at which the Prometheus server service is available + ## Ref: https://kubernetes.io/docs/user-guide/services/#external-ips + ## + externalIPs: [] + + ## Port to expose on each node + ## Only used if service.type is 'NodePort' + ## + # nodePort: 90 + + ## Loadbalancer IP + ## Only use if service.type is "loadbalancer" + loadBalancerIP: "" + loadBalancerSourceRanges: [] + ## Service type + ## + #type: NodePort + + sessionAffinity: "" diff --git a/kud/tests/vnfs/comp-app/collection/app2/profile/manifest.yaml b/kud/tests/vnfs/comp-app/collection/app2/profile/manifest.yaml new file mode 100644 index 00000000..4d381d02 --- /dev/null +++ b/kud/tests/vnfs/comp-app/collection/app2/profile/manifest.yaml @@ -0,0 +1,4 @@ +--- +version: v1 +type: + values: "override_values.yaml" diff --git a/kud/tests/vnfs/comp-app/collection/app2/profile/override_values.yaml b/kud/tests/vnfs/comp-app/collection/app2/profile/override_values.yaml new file mode 100644 index 00000000..6743ac5b --- /dev/null +++ b/kud/tests/vnfs/comp-app/collection/app2/profile/override_values.yaml @@ -0,0 +1,6 @@ +service: + type: ClusterIP + name: Prometheus + annotations: {} + labels: {} + clusterIP: "" \ No newline at end of file -- cgit 1.2.3-korg