NAS-121272 / 23.10 / Adds prometheus to charts train (#1072)

* initial prometheus commit

* add prometheus

* add descriptions

* bump common
This commit is contained in:
Stavros Kois
2023-04-12 17:38:57 +03:00
committed by GitHub
parent b3eac7d745
commit 7a6c40bcbc
15 changed files with 506 additions and 0 deletions

View File

@@ -0,0 +1,6 @@
dependencies:
- name: common
repository: file://../../../common
version: 1.0.3
digest: sha256:1a090020cfa582aff29906320874ffe9b543fcc6c2423c281f434514f2653e02
generated: "2023-04-06T18:56:51.017765304+03:00"

View File

@@ -0,0 +1,25 @@
name: prometheus
description: The Prometheus monitoring system and time series database.
annotations:
title: Prometheus
type: application
version: 1.0.0
apiVersion: v2
appVersion: v2.43.0
kubeVersion: '>=1.16.0-0'
maintainers:
- name: truenas
url: https://www.truenas.com/
dependencies:
- name: common
repository: file://../../../common
version: 1.0.3
home: https://prometheus.io
icon: https://avatars.githubusercontent.com/u/3380462
sources:
- https://github.com/prometheus/prometheus
- https://github.com/truenas/charts/tree/master/charts/prometheus
- https://prometheus.io
keywords:
- metrics
- prometheus

View File

@@ -0,0 +1,11 @@
# Prometheus
[Prometheus](https://prometheus.io/) - Monitoring system and time series database.
> When application is installed, a container will be launched with **root** privileges.
> This is required in order to apply the correct permissions to the `prometheus` directories.
> Afterward, the `prometheus` container will run as a **non**-root user (Default: `568`).
> Also an empty configuration file will be created.
The configuration file is located at `/config/prometheus.yml` inside the container.
Data is stored at `/data` inside the container.

View File

@@ -0,0 +1,11 @@
# Prometheus
[Prometheus](https://prometheus.io/) - Monitoring system and time series database.
> When application is installed, a container will be launched with **root** privileges.
> This is required in order to apply the correct permissions to the `prometheus` directories.
> Afterward, the `prometheus` container will run as a **non**-root user (Default: `568`).
> Also an empty configuration file will be created.
The configuration file is located at `/config/prometheus.yml` inside the container.
Data is stored at `/data` inside the container.

View File

@@ -0,0 +1,7 @@
prometheusStorage:
data:
type: hostPath
hostPath: /mnt/{{ .Release.Name }}/data
config:
type: hostPath
hostPath: /mnt/{{ .Release.Name }}/config

View File

@@ -0,0 +1,4 @@
icon_url: https://avatars.githubusercontent.com/u/3380462
categories:
- metrics
- prometheus

View File

@@ -0,0 +1,239 @@
groups:
- name: Prometheus Configuration
description: Configure Prometheus
- name: User and Group Configuration
description: Configure User and Group for Prometheus
- name: Network Configuration
description: Configure Network for Prometheus
- name: Storage Configuration
description: Configure Storage for Prometheus
- name: Resources Configuration
description: Configure Resources for Prometheus
portals:
web_portal:
protocols:
- "$kubernetes-resource_configmap_portal_protocol"
host:
- "$kubernetes-resource_configmap_portal_host"
ports:
- "$kubernetes-resource_configmap_portal_port"
path: "$kubernetes-resource_configmap_portal_path"
questions:
- variable: prometheusConfig
label: ""
group: Prometheus Configuration
schema:
type: dict
attrs:
- variable: retentionTime
label: Retention Time
description: The time to retain data for. Use the format 15d, 6w, 10y, etc.
schema:
type: string
default: "15d"
required: true
- variable: retentionSize
label: Retention Size
description: The size to retain data for. Use the format 100MB, 10GB, etc.
schema:
type: string
default: ""
- variable: walCompression
label: WAL Compression
description: Compress the time series database write-ahead log.
schema:
type: boolean
default: true
- variable: additionalArgs
label: Additional Arguments
description: Configure additional arguments for Prometheus.
schema:
type: list
default: []
items:
- variable: arg
label: Argument
schema:
type: string
required: true
default: ""
- variable: additionalEnvs
label: Additional Environment Variables
description: Configure additional environment variables for Prometheus.
schema:
type: list
default: []
items:
- variable: env
label: Environment Variable
schema:
type: dict
attrs:
- variable: name
label: Name
schema:
type: string
required: true
- variable: value
label: Value
schema:
type: string
required: true
- variable: prometheusRunAs
label: ""
group: User and Group Configuration
schema:
type: dict
attrs:
- variable: user
label: User ID
description: The user id that Prometheus will run as.
schema:
type: int
min: 1
default: 568
required: true
- variable: group
label: Group ID
description: The group id that Prometheus will run as.
schema:
type: int
min: 1
default: 568
required: true
- variable: prometheusNetwork
label: ""
group: Network Configuration
schema:
type: dict
attrs:
- variable: apiPort
label: API Port
description: The port for the Prometheus API (And WebUI).
schema:
type: int
default: 30000
min: 9000
max: 65535
required: true
- variable: hostNetwork
label: Host Network
description: |
Bind to the host network. It's recommended to keep this disabled.
schema:
type: boolean
default: false
- variable: prometheusStorage
label: ""
group: Storage Configuration
schema:
type: dict
attrs:
- variable: data
label: Prometheus Data Storage
description: The path to store Prometheus data/metrics.
schema:
type: dict
attrs:
- variable: type
label: Type
description: |
ixVolume: Is dataset created automatically by the system.</br>
Host Path: Is a path that already exists on the system.
schema:
type: string
required: true
default: ixVolume
enum:
- value: hostPath
description: Host Path (Path that already exists on the system)
- value: ixVolume
description: ixVolume (Dataset created automatically by the system)
- variable: datasetName
label: Dataset Name
schema:
type: string
show_if: [["type", "=", "ixVolume"]]
required: true
hidden: true
immutable: true
default: data
$ref:
- "normalize/ixVolume"
- variable: hostPath
label: Host Path
schema:
type: hostpath
show_if: [["type", "=", "hostPath"]]
immutable: true
required: true
- variable: config
label: Prometheus Config Storage
description: The path to store Prometheus config storage.
schema:
type: dict
attrs:
- variable: type
label: Type
description: |
ixVolume: Is dataset created automatically by the system.</br>
Host Path: Is a path that already exists on the system.
schema:
type: string
required: true
default: ixVolume
enum:
- value: hostPath
description: Host Path (Path that already exists on the system)
- value: ixVolume
description: ixVolume (Dataset created automatically by the system)
- variable: datasetName
label: Dataset Name
schema:
type: string
show_if: [["type", "=", "ixVolume"]]
required: true
hidden: true
immutable: true
default: config
$ref:
- "normalize/ixVolume"
- variable: hostPath
label: Host Path
schema:
type: hostpath
show_if: [["type", "=", "hostPath"]]
immutable: true
required: true
- variable: resources
label: ""
group: Resources Configuration
schema:
type: dict
attrs:
- variable: limits
label: Limits
schema:
type: dict
attrs:
- variable: cpu
label: CPU
description: CPU limit for Prometheus.
schema:
type: string
default: 4000m
required: true
- variable: memory
label: Memory
description: Memory limit for Prometheus.
schema:
type: string
default: 8Gi
required: true

View File

@@ -0,0 +1 @@
{{ include "ix.v1.common.lib.chart.notes" $ }}

View File

@@ -0,0 +1,12 @@
{{- define "prometheus.portal" -}}
---
apiVersion: v1
kind: ConfigMap
metadata:
name: portal
data:
path: /
port: {{ .Values.prometheusNetwork.apiPort | quote }}
protocol: http
host: $node_ip
{{- end -}}

View File

@@ -0,0 +1,120 @@
{{- define "prometheus.workload" -}}
workload:
prometheus:
enabled: true
primary: true
type: Deployment
podSpec:
hostNetwork: {{ .Values.prometheusNetwork.hostNetwork }}
containers:
prometheus:
enabled: true
primary: true
imageSelector: image
securityContext:
runAsUser: {{ .Values.prometheusRunAs.user }}
runAsGroup: {{ .Values.prometheusRunAs.group }}
args:
- --web.listen-address=0.0.0.0:{{ .Values.prometheusNetwork.apiPort }}
- --storage.tsdb.path=/data
- --config.file=/config/prometheus.yml
- --storage.tsdb.retention.time={{ .Values.prometheusConfig.retentionTime }}
{{ with .Values.prometheusConfig.retentionSize }}
- --storage.tsdb.retention.size={{ . }}
{{ end }}
{{ if .Values.prometheusConfig.walCompression }}
- --storage.tsdb.wal-compression
{{ end }}
{{ with .Values.prometheusConfig.additionalArgs }}
extraArgs:
{{ range $arg := . }}
- {{ $arg | quote }}
{{ end }}
{{ end }}
{{ with .Values.prometheusConfig.additionalEnvs }}
env:
{{ range $env := . }}
{{ $env.name }}: {{ $env.value }}
{{ end }}
{{ end }}
probes:
liveness:
enabled: true
type: http
port: {{ .Values.prometheusNetwork.apiPort }}
path: /-/healthy
readiness:
enabled: true
type: http
port: {{ .Values.prometheusNetwork.apiPort }}
path: /-/ready
startup:
enabled: true
type: http
port: {{ .Values.prometheusNetwork.apiPort }}
path: /-/ready
initContainers:
{{- include "ix.v1.common.app.permissions" (dict "containerName" "01-permissions"
"UID" .Values.prometheusRunAs.user
"GID" .Values.prometheusRunAs.group
"type" "install") | nindent 8 }}
init-config:
enabled: true
type: init
imageSelector: image
resources:
limits:
cpu: 500m
memory: 256Mi
securityContext:
runAsUser: {{ .Values.prometheusRunAs.user }}
runAsGroup: {{ .Values.prometheusRunAs.group }}
command: sh
args:
- -c
- |
if [ ! -f /config/prometheus.yml ]; then
touch /config/prometheus.yml
fi
{{/* Service */}}
service:
prometheus:
enabled: true
primary: true
type: NodePort
targetSelector: prometheus
ports:
prometheus:
enabled: true
primary: true
port: {{ .Values.prometheusNetwork.apiPort }}
nodePort: {{ .Values.prometheusNetwork.apiPort }}
targetSelector: prometheus
{{/* Persistence */}}
persistence:
data:
enabled: true
type: {{ .Values.prometheusStorage.data.type }}
datasetName: {{ .Values.prometheusStorage.data.datasetName | default "" }}
hostPath: {{ .Values.prometheusStorage.data.hostPath | default "" }}
targetSelector:
prometheus:
prometheus:
mountPath: /data
01-permissions:
mountPath: /mnt/directories/data
config:
enabled: true
type: {{ .Values.prometheusStorage.config.type }}
datasetName: {{ .Values.prometheusStorage.config.datasetName | default "" }}
hostPath: {{ .Values.prometheusStorage.config.hostPath | default "" }}
targetSelector:
prometheus:
prometheus:
mountPath: /config
01-permissions:
mountPath: /mnt/directories/export
init-config:
mountPath: /config
{{- end -}}

View File

@@ -0,0 +1,9 @@
{{- include "ix.v1.common.loader.init" . -}}
{{/* Merge the templates with Values */}}
{{- $_ := mustMergeOverwrite .Values (include "prometheus.workload" $ | fromYaml) -}}
{{/* Create the configmap for portal manually*/}}
{{- include "prometheus.portal" $ -}}
{{- include "ix.v1.common.loader.apply" . -}}

View File

@@ -0,0 +1 @@
{"filename": "values.yaml", "keys": ["image"]}

View File

@@ -0,0 +1,26 @@
#!/usr/bin/python3
import json
import sys
from catalog_update.upgrade_strategy import semantic_versioning
def newer_mapping(image_tags):
key = list(image_tags.keys())[0]
version = semantic_versioning(image_tags[key])
if not version:
return {}
return {
'tags': {key: f'v{version}'},
'app_version': f'v{version}',
}
if __name__ == '__main__':
try:
versions_json = json.loads(sys.stdin.read())
except ValueError:
raise ValueError('Invalid json specified')
print(json.dumps(newer_mapping(versions_json)))

View File

@@ -0,0 +1,34 @@
image:
repository: prom/prometheus
pullPolicy: IfNotPresent
tag: v2.43.0
resources:
limits:
cpu: 4000m
memory: 8Gi
prometheusConfig:
retentionTime: 15d
retentionSize: ""
walCompression: true
additionalEnvs: []
additionalArgs: []
prometheusNetwork:
apiPort: 30000
hostNetwork: false
prometheusRunAs:
user: 568
group: 568
prometheusStorage:
data:
type: ixVolume
hostPath: ''
datasetName: data
config:
type: ixVolume
hostPath: ''
datasetName: config