Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
dmepham committed Mar 13, 2024
1 parent bb4070a commit d0fd44f
Show file tree
Hide file tree
Showing 7 changed files with 153 additions and 0 deletions.
23 changes: 23 additions & 0 deletions stable/cloudzero-prometheus-agent/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# 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
*.orig
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/
11 changes: 11 additions & 0 deletions stable/cloudzero-prometheus-agent/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
apiVersion: v2
name: cloudzero-prometheus-agent
description: A wrapper chart around Prometheus for running in agent mode.
type: application
version: 0.0.1
appVersion: "v2.50.1"
dependencies:
- name: prometheus
version: "25.17.*"
repository: https://prometheus-community.github.io/helm-charts
condition: prometheus.enabled
Binary file not shown.
Empty file.
75 changes: 75 additions & 0 deletions stable/cloudzero-prometheus-agent/templates/cm.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: {{.Release.Name}}-{{.Values.prometheus.server.configMapOverrideName}}
namespace: default
data:
prometheus.yml: |-
global:
scrape_interval: 60s
scrape_configs:
- job_name: 'cz-kubernetes-nodes'
kubernetes_sd_configs:
- role: node
relabel_configs:
- action: labelmap
regex: __meta_kubernetes_node_label_(.+)
- source_labels: [__meta_kubernetes_node_name]
action: replace
target_label: node
- source_labels: [__address__]
target_label: __address__
regex: (.*)
replacement: $1:9100
- action: labelmap
regex: __meta_kubernetes_node_label_(.+)
- source_labels: [__meta_kubernetes_node_name]
action: replace
target_label: kubernetes_node_name
metrics_path: /metrics
honor_labels: true
scheme: http
params:
format: ['prometheus']
- job_name: 'cz-kubernetes-pods'
kubernetes_sd_configs:
- role: pod
relabel_configs:
- source_labels: [__meta_kubernetes_pod_container_name]
action: keep
regex: '.*'
target_label: container
- source_labels: [__meta_kubernetes_pod_annotation_prometheus_io_path]
action: replace
target_label: __metrics_path__
regex: (.+)
replacement: $1
- source_labels: [__meta_kubernetes_pod_annotation_prometheus_io_port]
action: replace
target_label: __address__
regex: (.+)
replacement: ${1}
- action: labelmap
regex: __meta_kubernetes_pod_label_(.+)
metrics_path: /metrics
honor_labels: true
scheme: http
params:
format: ['prometheus']
remote_write:
- url: 'https://{{ .Values.cloudzeroHost }}/v1/container-metrics?cluster_name={{.Values.cluster_name}}&cloud_account_id={{.Values.cloud_account_id}}'
authorization:
{{- if .Values.credentials.useSecret }}
credentials_file: /etc/config/cz-api-key
{{- else if .Values.api_key }}
credentials: '{{ .Values.api_key }}'
{{- else }}
{{- fail "api_key must be provided if API key is not provided by an existing secret" }}
{{- end }}
write_relabel_configs:
- source_labels: [__name__]
regex: "^(container_cpu_usage_seconds_total|container_memory_working_set_bytes|container_network_receive_bytes_total|container_network_transmit_bytes_total|kube_node_status_capacity|kube_pod_container_resource_limits|kube_pod_container_resource_requests|kube_pod_labels|kube_pod_info|node_dmi_info|kube_node_info)$"
action: keep
metadata_config:
send: false
13 changes: 13 additions & 0 deletions stable/cloudzero-prometheus-agent/templates/secret.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{{- if and .Values.credentials.useSecret .Values.credentials.createSecret -}}
{{- if not .Values.api_key }}
{{- fail "api_key must be provided if API key is not provided by an existing secret" }}
{{- end }}
---
apiVersion: v1
kind: Secret
metadata:
name: {{ .Values.credentials.secretName }}
namespace: {{ .Release.Namespace }}
data:
cz-api-key: {{ .Values.api_key | b64enc | quote }}
{{- end }}
31 changes: 31 additions & 0 deletions stable/cloudzero-prometheus-agent/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
cloudzeroHost: api.cloudzero.com

credentials:
useSecret: true
createSecret: true
# useSecret: false
# createSecret: false
secretName: &secretName cz-api-key


prometheus:
enabled: true
alertmanager:
enabled: false
serverFiles:
prometheus.yml:
rule_files:
server:
configMapOverrideName: configuration
defaultFlagsOverride:
- --config.file=/etc/config/prometheus.yml
- --web.enable-lifecycle
- --web.console.libraries=/etc/prometheus/console_libraries
- --web.console.templates=/etc/prometheus/consoles
- --enable-feature=agent
extraSecretMounts:
- name: *secretName
mountPath: /etc/config/
subPath: ""
secretName: *secretName
readOnly: true

0 comments on commit d0fd44f

Please sign in to comment.