From ef1aaf943e47492091827ab3bdf38097671447a3 Mon Sep 17 00:00:00 2001 From: Anton Petruhin Date: Thu, 18 Jan 2024 19:38:29 +0300 Subject: [PATCH] * coroot v0.27.0 * node-agent v1.17.0 * +coroot-cluster-agent v0.1.0 * -pyroscope --- charts/coroot/Chart.yaml | 10 +- charts/coroot/templates/_helpers.tpl | 31 ++++-- charts/coroot/templates/cluster-agent.yaml | 119 +++++++++++++++++++++ charts/coroot/templates/connect.yaml | 4 - charts/coroot/templates/deployment.yaml | 4 - charts/coroot/values.yaml | 88 ++++++--------- 6 files changed, 175 insertions(+), 81 deletions(-) create mode 100644 charts/coroot/templates/cluster-agent.yaml diff --git a/charts/coroot/Chart.yaml b/charts/coroot/Chart.yaml index ee2e381..65d42f4 100644 --- a/charts/coroot/Chart.yaml +++ b/charts/coroot/Chart.yaml @@ -2,21 +2,17 @@ apiVersion: v2 name: coroot description: A monitoring and troubleshooting tool for microservice architectures. type: application -version: 0.7.6 -appVersion: "0.26.0" +version: 0.8.0 +appVersion: "0.27.0" dependencies: - name: prometheus repository: https://prometheus-community.github.io/helm-charts version: 15.16.* condition: prometheus.enabled - name: node-agent - version: 0.1.53 + version: 0.1.54 repository: https://coroot.github.io/helm-charts condition: node-agent.enabled - - name: pyroscope - repository: https://pyroscope-io.github.io/helm-chart - version: 0.2.* - condition: pyroscope.enabled - name: clickhouse version: 3.1.* repository: https://charts.bitnami.com/bitnami diff --git a/charts/coroot/templates/_helpers.tpl b/charts/coroot/templates/_helpers.tpl index 82fa296..246aa57 100644 --- a/charts/coroot/templates/_helpers.tpl +++ b/charts/coroot/templates/_helpers.tpl @@ -4,6 +4,9 @@ Expand the name of the chart. {{- define "coroot.name" -}} {{- default .Chart.Name .Values.corootCE.nameOverride | trunc 63 | trimSuffix "-" }} {{- end }} +{{- define "coroot.namespace" -}} +{{- .Release.Namespace -}} +{{- end -}} {{/* Create a default fully qualified app name. @@ -78,6 +81,23 @@ app.kubernetes.io/version: {{ .Values.corootConnect.image.tag | quote }} app.kubernetes.io/managed-by: {{ .Release.Service }} {{- end }} +{{/* +Coroot Cluster Agent +*/}} +{{- define "corootClusterAgent.name" -}} +{{- printf "%s-cluster-agent" .Release.Name | trunc 63 | trimSuffix "-" -}} +{{- end -}} +{{- define "corootClusterAgent.selectorLabels" -}} +app.kubernetes.io/name: {{ include "corootClusterAgent.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} +{{- define "corootClusterAgent.labels" -}} +helm.sh/chart: {{ include "coroot.chart" . }} +{{ include "corootClusterAgent.selectorLabels" . }} +app.kubernetes.io/version: {{ .Values.corootClusterAgent.image.tag | quote }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + {{/* Create a fully qualified Prometheus server name in a similar way as prometheus/templates/_helpers.tpl creates "prometheus.server.fullname". @@ -90,17 +110,6 @@ in a similar way as prometheus/templates/_helpers.tpl creates "prometheus.server {{- end -}} {{- end -}} -{{/* -Create a default fully qualified Pyroscope name. -*/}} -{{- define "coroot.pyroscope.fullname" -}} -{{- if .Values.pyroscope.fullnameOverride }} -{{- .Values.pyroscope.fullnameOverride | trunc 63 | trimSuffix "-" }} -{{- else }} -{{- printf "%s-pyroscope" .Release.Name | trunc 63 | trimSuffix "-" }} -{{- end }} -{{- end }} - {{/* Create a default fully qualified Clickhouse name. */}} diff --git a/charts/coroot/templates/cluster-agent.yaml b/charts/coroot/templates/cluster-agent.yaml new file mode 100644 index 0000000..70f8c11 --- /dev/null +++ b/charts/coroot/templates/cluster-agent.yaml @@ -0,0 +1,119 @@ +{{- if .Values.corootClusterAgent.enabled -}} +apiVersion: v1 +kind: ServiceAccount +metadata: + name: {{ include "corootClusterAgent.name" . }} + labels: + {{- include "corootClusterAgent.labels" . | nindent 4 }} + +--- + +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRoleBinding +metadata: + name: {{ include "corootClusterAgent.name" . }} +subjects: + - kind: ServiceAccount + name: {{ include "corootClusterAgent.name" . }} + namespace: {{ include "coroot.namespace" . }} +roleRef: + kind: ClusterRole + name: view + apiGroup: rbac.authorization.k8s.io + +--- + +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ include "corootClusterAgent.name" . }} + labels: + {{- include "corootClusterAgent.labels" . | nindent 4 }} +data: + config.yaml: | + {{- toYaml .Values.corootClusterAgent.config | nindent 4 }} + +--- + +apiVersion: v1 +kind: Service +metadata: + name: {{ include "corootClusterAgent.name" . }} + labels: + {{- include "corootClusterAgent.labels" . | nindent 4 }} +spec: + type: ClusterIP + ports: + - port: 8080 + targetPort: 8080 + selector: + {{- include "corootClusterAgent.selectorLabels" . | nindent 6 }} + +--- + +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "corootClusterAgent.name" . }} + labels: + {{- include "corootClusterAgent.labels" . | nindent 4 }} +spec: + replicas: 1 + selector: + matchLabels: + {{- include "corootClusterAgent.selectorLabels" . | nindent 6 }} + template: + metadata: + annotations: + checksum/config: {{ toYaml .Values.corootClusterAgent.config | sha256sum }} + {{- with .Values.corootClusterAgent.podAnnotations }} + {{- toYaml . | nindent 8 }} + {{- end }} + labels: + {{- include "corootClusterAgent.selectorLabels" . | nindent 8 }} + spec: + {{- with .Values.corootClusterAgent.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + serviceAccountName: {{ include "corootClusterAgent.name" . }} + securityContext: + {{- toYaml .Values.corootClusterAgent.podSecurityContext | nindent 8 }} + containers: + - name: cluster-agent + securityContext: + {{- toYaml .Values.corootClusterAgent.securityContext | nindent 12 }} + image: "{{ .Values.corootClusterAgent.image.repository }}:{{ .Values.corootClusterAgent.image.tag }}" + imagePullPolicy: {{ .Values.corootClusterAgent.image.pullPolicy }} + env: + - name: CLICKHOUSE_PASSWORD + valueFrom: + secretKeyRef: + name: {{ include "coroot.clickhouse.fullname" . }} + key: admin-password + {{- with .Values.corootClusterAgent.env }} + {{- . | toYaml | nindent 12 }} + {{- end }} + resources: + {{- toYaml .Values.corootClusterAgent.resources | nindent 12 }} + volumeMounts: + - name: config + mountPath: /config.yaml + subPath: config.yaml + volumes: + - name: config + configMap: + name: {{ include "corootClusterAgent.name" . }} + {{- with .Values.corootClusterAgent.nodeSelector }} + nodeSelector: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.corootClusterAgent.affinity }} + affinity: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.corootClusterAgent.tolerations }} + tolerations: + {{- toYaml . | nindent 8 }} + {{- end }} +{{- end -}} diff --git a/charts/coroot/templates/connect.yaml b/charts/coroot/templates/connect.yaml index 158efce..8828f61 100644 --- a/charts/coroot/templates/connect.yaml +++ b/charts/coroot/templates/connect.yaml @@ -51,10 +51,6 @@ spec: value: /tmp/config.yaml - name: PROMETHEUS_URL value: {{ printf "http://%s:%s" (include "coroot.prometheus.server.fullname" .) (.Values.prometheus.server.service.servicePort | toString ) }} - {{- if .Values.pyroscope.enabled }} - - name: PYROSCOPE_URL - value: {{ printf "http://%s:%s" (include "coroot.pyroscope.fullname" .) (.Values.pyroscope.service.port | toString ) }} - {{- end }} {{- if and .Values.clickhouse.enabled }} - name: CLICKHOUSE_ADDRESS value: {{ printf "%s:%s" (include "coroot.clickhouse.fullname" .) (.Values.clickhouse.service.ports.tcp | toString ) }} diff --git a/charts/coroot/templates/deployment.yaml b/charts/coroot/templates/deployment.yaml index b8daec0..dc58690 100644 --- a/charts/coroot/templates/deployment.yaml +++ b/charts/coroot/templates/deployment.yaml @@ -45,10 +45,6 @@ spec: - --bootstrap-refresh-interval={{ .Values.corootCE.bootstrap.refreshInterval }} {{- end }} env: - {{- if and .Values.pyroscope.enabled }} - - name: BOOTSTRAP_PYROSCOPE_URL - value: {{ printf "http://%s:%s" (include "coroot.pyroscope.fullname" .) (.Values.pyroscope.service.port | toString ) }} - {{- end }} {{- if and .Values.clickhouse.enabled }} - name: BOOTSTRAP_CLICKHOUSE_ADDRESS value: {{ printf "%s:%s" (include "coroot.clickhouse.fullname" .) (.Values.clickhouse.service.ports.tcp | toString ) }} diff --git a/charts/coroot/values.yaml b/charts/coroot/values.yaml index 7c4b12e..c4cc87c 100644 --- a/charts/coroot/values.yaml +++ b/charts/coroot/values.yaml @@ -74,8 +74,6 @@ corootConnect: prometheus: url: ${PROMETHEUS_URL} refresh_interval: 15s - pyroscope: - url: ${PYROSCOPE_URL} clickhouse: addr: ${CLICKHOUSE_ADDRESS} auth: @@ -102,6 +100,38 @@ corootConnect: affinity: {} env: [] +corootClusterAgent: + enabled: true + config: + listen: :8080 + clickhouse: + address: coroot-clickhouse:9000 + database: default + auth: + user: default + password: ${CLICKHOUSE_PASSWORD} + profiles: + ttl_days: 7 + scrape: + interval: 1m + image: + repository: ghcr.io/coroot/coroot-cluster-agent + pullPolicy: IfNotPresent + tag: "0.1.0" + imagePullSecrets: [] + podAnnotations: {} + podSecurityContext: {} + securityContext: {} + resources: + requests: + cpu: 100m + memory: 1Gi + nodeSelector: {} + tolerations: [] + affinity: {} + env: [] + + prometheus: enabled: true alertmanager: @@ -379,59 +409,7 @@ node-agent: tracesEndpoint: "http://coroot-opentelemetry-collector:4318/v1/traces" logsEndpoint: "http://coroot-opentelemetry-collector:4318/v1/logs" profiling: - pyroscopeEndpoint: "http://coroot-pyroscope:4040/ingest" - -pyroscope: - enabled: true - persistence: - enabled: true - size: 30Gi - rbac: - create: true - pyroscopeConfigs: - retention: 8h - retention-levels: - 0: 1h - 1: 4h - 2: 8h - log-level: debug - scrape-configs: - - job-name: 'kubernetes-pods' - enabled-profiles: [cpu, mem] - kubernetes-sd-configs: - - role: pod - relabel-configs: - - source-labels: [ __meta_kubernetes_pod_annotation_pyroscope_io_scrape ] - action: keep - regex: true - - source-labels: - [ __meta_kubernetes_pod_annotation_pyroscope_io_application_name ] - action: replace - target-label: __name__ - - source-labels: [ __meta_kubernetes_pod_annotation_pyroscope_io_scheme ] - action: replace - regex: (https?) - target-label: __scheme__ - - source-labels: - [ __address__, __meta_kubernetes_pod_annotation_pyroscope_io_port ] - action: replace - regex: ([^:]+)(?::\d+)?;(\d+) - replacement: $1:$2 - target-label: __address__ - - action: labelmap - regex: __meta_kubernetes_pod_label_(.+) - - source-labels: [ __meta_kubernetes_namespace ] - action: replace - target-label: namespace - - source-labels: [ __meta_kubernetes_pod_name ] - action: replace - target-label: pod - - source-labels: [ __meta_kubernetes_pod_phase ] - regex: Pending|Succeeded|Failed|Completed - action: drop - - action: labelmap - regex: __meta_kubernetes_pod_annotation_pyroscope_io_profile_(.+) - replacement: __profile_$1 + profilesEndpoint: "http://coroot-cluster-agent:8080/profiles" clickhouse: enabled: true