diff --git a/charts/prometurbo/.helmignore b/charts/prometurbo/.helmignore new file mode 100644 index 0000000..50af031 --- /dev/null +++ b/charts/prometurbo/.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/charts/prometurbo/Chart.yaml b/charts/prometurbo/Chart.yaml new file mode 100644 index 0000000..1c8b658 --- /dev/null +++ b/charts/prometurbo/Chart.yaml @@ -0,0 +1,8 @@ +apiVersion: v1 +appVersion: "8.0" +description: A Helm chart for Turbonomic prometurbo metric server and data ingestion framework probe +name: prometurbo +version: 1.0.0 +sources: + - https://github.com/turbonomic/prometurbo + - https://github.com/turbonomic/data-ingestion-framework diff --git a/charts/prometurbo/templates/_helpers.tpl b/charts/prometurbo/templates/_helpers.tpl new file mode 100644 index 0000000..3bef876 --- /dev/null +++ b/charts/prometurbo/templates/_helpers.tpl @@ -0,0 +1,32 @@ +{{/* vim: set filetype=mustache: */}} +{{/* +Expand the name of the chart. +*/}} +{{- define "prometurbo.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 "prometurbo.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 "prometurbo.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} +{{- end -}} diff --git a/charts/prometurbo/templates/configmap-prometurbo.yaml b/charts/prometurbo/templates/configmap-prometurbo.yaml new file mode 100644 index 0000000..85b381d --- /dev/null +++ b/charts/prometurbo/templates/configmap-prometurbo.yaml @@ -0,0 +1,67 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: prometurbo-config-{{ .Release.Name }} +data: + {{- if or .Values.servers .Values.exporters }} + prometheus.config: |- + {{- if .Values.servers }} + # This configuration defines the Prometheus servers and metrics to scrape. + # This configuration is deprecated. Please use PrometheusServerConfig CR to configure servers. + # [Schema] + # server + # url: string # `yaml:"url"` + # username: string # `yaml:"username"` + # password: string # `yaml:"password"` + # clusterId: string # `yaml:"clusterId"` + # bearerToken: string # `yaml:"bearerToken"` + # exporters: [ string ] #`yaml:"exporters"` + servers: + {{ toYaml .Values.servers | indent 6 }} + {{- end }} + {{- if .Values.exporters }} + # This configuration is deprecated. Please use PrometheusQueryMappings CR to configure exporters. + # [Schema] + # exporter: + # type: string # `yaml:"type"` + # hostedOnVM: bool # `yaml:"hostedOnVM,omitempty"` + # metrics: [ metrics ] # `yaml:"metrics"` + # attributes: map[string] ValueMapping # `yaml:"attributes"` + # metrics: + # type: string # `yaml:"type"` + # queries: map[string]string # `yaml:"queries"` + # ValueMapping: + # label: string # `yaml:"label"` + # matches: string # `yaml:"matches,omitempty"` + # as: string # `yaml:"as,omitempty"` + # isIdentifier: bool # `yaml:"isIdentifier"` + exporters: + {{ toYaml .Values.exporters | indent 6 }} + {{- end }} +{{- end }} + + businessapp.config: |- + # This configuration defines business applications and their associated business transactions + # and dependent services. + # + # [Schema] + # businessApplications: [ businessApplication ] + # businessApplication: + # name: string # The name of the business application. Required. + # from: string # The discovering source (target URL) of the business application. Required. + # transactions: [ transaction ] # A list of business transactions. Optional. + # services: [ string ] # A list of services that the business application depends on. Required. + # transaction: + # name: string # The display name of the transaction. Optional. + # path: string # The request path of a business transaction. Required. + # dependOn: [ string ] # The list of services that the business transaction depends on. Required. + businessApplications: +{{- if .Values.businessApplications }} +{{ toYaml .Values.businessApplications | indent 6 }} +{{- end }} + turbo-autoreload.config: |- + { + "logging": { + "level": {{ .Values.logging.level }} + } + } diff --git a/charts/prometurbo/templates/configmap-turbodif.yaml b/charts/prometurbo/templates/configmap-turbodif.yaml new file mode 100644 index 0000000..45d921c --- /dev/null +++ b/charts/prometurbo/templates/configmap-turbodif.yaml @@ -0,0 +1,34 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: turbodif-config-{{ .Release.Name }} +data: + turbodif-config.json: |- + { + "communicationConfig": { + "serverMeta": { + "version": "{{ .Values.serverMeta.version }}", + "turboServer": "{{ .Values.serverMeta.turboServer }}" + }, + "restAPIConfig": { + "opsManagerUserName": "{{ .Values.restAPIConfig.opsManagerUserName }}", + "opsManagerPassword": "{{ .Values.restAPIConfig.opsManagerPassword }}" + }, + "sdkProtocolConfig": { + "registrationTimeoutSec": {{ .Values.sdkProtocolConfig.registrationTimeoutSec }}, + "restartOnRegistrationTimeout": {{ .Values.sdkProtocolConfig.restartOnRegistrationTimeout }} + } + {{- if and .Values.targetName .Values.targetAddress }} + }, + "targetConfig": { + "targetName": "{{ .Values.targetName }}", + "targetAddress": "{{ .Values.targetAddress }}" + } + {{- end }} + } + turbo-autoreload.config: |- + { + "logging": { + "level": {{ .Values.logging.level }} + } + } diff --git a/charts/prometurbo/templates/deployment.yaml b/charts/prometurbo/templates/deployment.yaml new file mode 100644 index 0000000..66a65c2 --- /dev/null +++ b/charts/prometurbo/templates/deployment.yaml @@ -0,0 +1,81 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "prometurbo.fullname" . }} + labels: + app.kubernetes.io/name: {{ include "prometurbo.name" . }} + helm.sh/chart: {{ include "prometurbo.chart" . }} + app.kubernetes.io/instance: {{ .Release.Name }} + app.kubernetes.io/managed-by: {{ .Release.Service }} +spec: + replicas: {{ .Values.replicaCount }} + selector: + matchLabels: + app.kubernetes.io/name: {{ include "prometurbo.name" . }} + app.kubernetes.io/instance: {{ .Release.Name }} + template: + metadata: + annotations: + {{- with .Values.annotations }} + {{- toYaml . | nindent 8 }} + {{- end }} + labels: + app.kubernetes.io/name: {{ include "prometurbo.name" . }} + app.kubernetes.io/instance: {{ .Release.Name }} + spec: + serviceAccountName: {{ .Values.serviceAccountName }} +{{- if .Values.image.imagePullSecret }} + imagePullSecrets: + - name: {{ .Values.image.imagePullSecret }} +{{- end }} + containers: + - name: {{ .Chart.Name }} + image: {{ .Values.image.prometurboRepository }}:{{ .Values.image.prometurboTag }} + imagePullPolicy: {{ .Values.image.pullPolicy }} + args: + - --v={{ .Values.args.logginglevel }} + resources: +{{ toYaml .Values.resources | indent 12 }} + ports: + - containerPort: 8081 + volumeMounts: + - name: prometurbo-config + mountPath: /etc/prometurbo + readOnly: true + - name: turbodif + image: {{ .Values.image.turbodifRepository }}:{{ .Values.image.turbodifTag }} + imagePullPolicy: {{ .Values.image.pullPolicy }} + env: + - name: "TURBODIF_TARGET_TYPE_OVERWRITE" + value: "Prometheus" + args: + - --v={{ .Values.args.logginglevel }} +{{- if .Values.args.ignoreCommodityIfPresent }} + - --ignoreCommodityIfPresent=true +{{- end }} + resources: +{{ toYaml .Values.resources | indent 12 }} + volumeMounts: + - name: turbodif-config + mountPath: /etc/turbodif + readOnly: true + - name: turbonomic-credentials-volume + mountPath: /etc/turbonomic-credentials + readOnly: true + - name: varlog + mountPath: /var/log + volumes: + - name: prometurbo-config + configMap: + name: prometurbo-config-{{ .Release.Name }} + - name: turbodif-config + configMap: + name: turbodif-config-{{ .Release.Name }} + - name: turbonomic-credentials-volume + secret: + defaultMode: 420 + optional: true + secretName: {{ .Values.restAPIConfig.turbonomicCredentialsSecretName | quote }} + - name: varlog + emptyDir: {} + restartPolicy: Always diff --git a/charts/prometurbo/templates/serviceaccount.yaml b/charts/prometurbo/templates/serviceaccount.yaml new file mode 100644 index 0000000..7adeb0e --- /dev/null +++ b/charts/prometurbo/templates/serviceaccount.yaml @@ -0,0 +1,56 @@ +apiVersion: v1 +kind: ServiceAccount +metadata: + name: {{ .Values.serviceAccountName }} +{{- if eq .Values.roleName "prometurbo" }} +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRole +metadata: + name: {{ .Values.roleName }}-{{ .Release.Name }}-{{ .Release.Namespace }} +rules: + - apiGroups: + - "" + resources: + - services + - secrets + verbs: + - get + - list + - watch + - apiGroups: + - metrics.turbonomic.io + resources: + - prometheusquerymappings + - prometheusserverconfigs + verbs: + - get + - list + - watch + - patch + - update +{{- end }} +--- +kind: ClusterRoleBinding +# For OpenShift 3.4-3.7 use apiVersion: v1 +# For kubernetes 1.9 use rbac.authorization.k8s.io/v1 +# For kubernetes 1.8 use rbac.authorization.k8s.io/v1beta1 +apiVersion: rbac.authorization.k8s.io/v1 +metadata: + name: {{ .Values.roleBinding }}-{{ .Release.Name }}-{{ .Release.Namespace }} +subjects: + - kind: ServiceAccount + name: {{ .Values.serviceAccountName }} + namespace: {{ .Release.Namespace }} +roleRef: + # User creating this resource must have permissions to add this policy to the SA + kind: ClusterRole + # accepted values cluster-reader disc and monitoring. + {{- if eq .Values.roleName "prometurbo"}} + name: {{ .Values.roleName }}-{{ .Release.Name }}-{{ .Release.Namespace }} + {{- else }} + name: {{ .Values.roleName }} + {{- end }} + # For OpenShift v3.4 remove apiGroup line + apiGroup: rbac.authorization.k8s.io + diff --git a/charts/prometurbo/values.yaml b/charts/prometurbo/values.yaml new file mode 100644 index 0000000..048fcbe --- /dev/null +++ b/charts/prometurbo/values.yaml @@ -0,0 +1,106 @@ +# Default values for prometurbo. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +replicaCount: 1 + +# Replace the image with desired version:8.7.5 or snapshot version:8.7.5-SNAPSHOT from icr.io +image: + prometurboRepository: icr.io/cpopen/turbonomic/prometurbo + prometurboTag: 8.14.2 + turbodifRepository: icr.io/cpopen/turbonomic/turbodif + turbodifTag: 8.14.2 + pullPolicy: IfNotPresent + +# Specify the name of the serviceaccount +serviceAccountName: "prometurbo" + +# Specify 'prometurbo' role. A cluster role with this name will be created during deployment +# If using a role name other than the pre-defined role names, cluster role will not be created. This role should be +# existing in the cluster and should have the necessary permissions required for prometurbo to work accurately. +roleName: "prometurbo" + +# Specify the name of clusterrolebinding +roleBinding: "prometurbo-binding" + +# nameOverride: "" +# fullnameOverride: "" + +# Turbonomic server version and address +serverMeta: + version: 8.3 + turboServer: https://Turbo_server_URL + +# Turbonomic server api user and password +# The opsManagerUserName requires Turbo administrator role +restAPIConfig: + turbonomicCredentialsSecretName: "turbonomic-credentials" + opsManagerUserName: Turbo_username + opsManagerPassword: Turbo_password + +sdkProtocolConfig: + registrationTimeoutSec: 300 + restartOnRegistrationTimeout: false + +# Specify a UNIQUE target name +targetName: Cluster_name +# Specify metric endpoint from Prometurbo +targetAddress: http://127.0.0.1:8081/metrics + +# Logging level. Changing this value does not require restart of Prometurbo but takes about 1 minute to take effect +logging: + level: 2 + +args: + # logging level + logginglevel: 2 + # When set to true, ignore merging a commodity if a commodity of the same type already exists + ignoreCommodityIfPresent: false + +resources: {} + +# Configure business applications here +# [Schema] +# businessApplications: [ businessApplication ] +# businessApplication: +# name: string # The name of the business application. Required. +# from: string # The discovering source (target URL) of the business application. Required. +# transactions: [ transaction ] # A list of business transactions. Optional. +# services: [ string ] # A list of services that the business application depends on. Required. +# transaction: +# name: string # The display name of the transaction. Optional. +# path: string # The request path of a business transaction. Required. +# dependOn: [ string ] # The list of services that the business transaction depends on. Required. +businessApplications: + +# Configure server config here. +# This configuration is deprecated. Please use PrometheusServerConfig CR to configure servers. +# [Schema] +# servers: [ server1 ] +servers: +# server1: +# url: string # Metric server url +# username: string # +# password: string # +# clusterId: string # k8s cluster id +# bearerToken: string # +# exporters: [ string ] # list of names of configured exporter + +# Configure exporter config here. +# This configuration is deprecated. Please use PrometheusQueryMappings CR to configure exporters. +# [Schema] +# exporters: [ exporter-foo ] +exporters: +# exporter-foo: +# type: string # `yaml:"type"` +# hostedOnVM: bool # `yaml:"hostedOnVM,omitempty"` +# metrics: [ metrics ] # `yaml:"metrics"` +# attributes: map[string] ValueMapping # `yaml:"attributes"` +# metrics: +# type: string # resource for which the query to the metric server is made +# queries: map[string]string # map of query strings to the resource attribute type such as 'used', 'capacity' +# ValueMapping: +# label: string # `yaml:"label"` +# matches: string # `yaml:"matches,omitempty"` +# as: string # `yaml:"as,omitempty"` +# isIdentifier: bool # `yaml:"isIdentifier"`