From d99b0c798129d14d2198ce304c68a31b7f13a3a3 Mon Sep 17 00:00:00 2001 From: batistein Date: Sat, 15 Apr 2023 21:54:21 +0200 Subject: [PATCH] :seedling: update konnectivity-agent --- charts/konnectivity-agent/Chart.yaml | 4 +- .../konnectivity-agent/templates/_helpers.tpl | 23 ++++++ .../templates/deployment.yaml | 2 +- charts/konnectivity-agent/templates/rbac.yaml | 5 +- .../templates/server-service.yaml | 18 +++++ .../templates/server-serviceMonitor.yaml | 38 ++++++++++ .../konnectivity-agent/templates/service.yaml | 18 +++++ .../templates/serviceMonitor.yaml | 38 ++++++++++ charts/konnectivity-agent/values.yaml | 76 ++++++++++++++++++- 9 files changed, 215 insertions(+), 7 deletions(-) create mode 100644 charts/konnectivity-agent/templates/server-service.yaml create mode 100644 charts/konnectivity-agent/templates/server-serviceMonitor.yaml create mode 100644 charts/konnectivity-agent/templates/service.yaml create mode 100644 charts/konnectivity-agent/templates/serviceMonitor.yaml diff --git a/charts/konnectivity-agent/Chart.yaml b/charts/konnectivity-agent/Chart.yaml index 3eb481e..503ec39 100644 --- a/charts/konnectivity-agent/Chart.yaml +++ b/charts/konnectivity-agent/Chart.yaml @@ -13,5 +13,5 @@ dependencies: version: 1.0.0 alias: proportional-autoscaler condition: proportional-autoscaler.enabled -appVersion: v0.0.32 -version: 1.0.3 +appVersion: v0.1.2 +version: 1.0.5 diff --git a/charts/konnectivity-agent/templates/_helpers.tpl b/charts/konnectivity-agent/templates/_helpers.tpl index 4afb728..306a821 100644 --- a/charts/konnectivity-agent/templates/_helpers.tpl +++ b/charts/konnectivity-agent/templates/_helpers.tpl @@ -43,6 +43,29 @@ app.kubernetes.io/managed-by: {{ .Release.Service }} addonmanager.kubernetes.io/mode: Reconcile {{- end }} +{{/* +Common labels for server +*/}} +{{- define "konnectivity-server.labels" -}} +helm.sh/chart: {{ include "konnectivity-agent.chart" . }} +{{ include "konnectivity-server.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +addonmanager.kubernetes.io/mode: Reconcile +{{- end }} + + +{{/* +Selector labels for server +*/}} +{{- define "konnectivity-server.selectorLabels" -}} +app.kubernetes.io/name: konnectivity-server +app.kubernetes.io/instance: konnectivity-server +k8s-app: konnectivity-agent +{{- end }} + {{/* Selector labels */}} diff --git a/charts/konnectivity-agent/templates/deployment.yaml b/charts/konnectivity-agent/templates/deployment.yaml index 46004c0..b13c2b4 100644 --- a/charts/konnectivity-agent/templates/deployment.yaml +++ b/charts/konnectivity-agent/templates/deployment.yaml @@ -73,4 +73,4 @@ spec: {{- with .Values.affinity }} affinity: {{- toYaml . | nindent 8 }} - {{- end }} \ No newline at end of file + {{- end }} diff --git a/charts/konnectivity-agent/templates/rbac.yaml b/charts/konnectivity-agent/templates/rbac.yaml index 79719f0..1afa86c 100644 --- a/charts/konnectivity-agent/templates/rbac.yaml +++ b/charts/konnectivity-agent/templates/rbac.yaml @@ -4,8 +4,7 @@ metadata: name: system:konnectivity-server namespace: {{ .Release.Namespace }} labels: - {{- include "konnectivity-agent.labels" . | nindent 4 }} - kubernetes.io/cluster-service: "true" +{{ include "konnectivity-agent.labels" . | indent 4 }} roleRef: apiGroup: rbac.authorization.k8s.io kind: ClusterRole @@ -13,4 +12,4 @@ roleRef: subjects: - apiGroup: rbac.authorization.k8s.io kind: User - name: system:konnectivity-server \ No newline at end of file + name: system:konnectivity-server diff --git a/charts/konnectivity-agent/templates/server-service.yaml b/charts/konnectivity-agent/templates/server-service.yaml new file mode 100644 index 0000000..dda3390 --- /dev/null +++ b/charts/konnectivity-agent/templates/server-service.yaml @@ -0,0 +1,18 @@ +{{- if .Values.server.serviceMonitor.enabled }} +apiVersion: v1 +kind: Service +metadata: + name: konnectivity-server + namespace: {{ .Release.Namespace }} + labels: +{{ include "konnectivity-server.labels" . | indent 4}} +spec: + clusterIP: None + ports: + - name: http-metrics + port: {{ .Values.ports.admin }} + protocol: TCP + targetPort: {{ .Values.ports.admin }} + selector: + {{- include "konnectivity-server.selectorLabels" . | nindent 4 }} +{{- end }} diff --git a/charts/konnectivity-agent/templates/server-serviceMonitor.yaml b/charts/konnectivity-agent/templates/server-serviceMonitor.yaml new file mode 100644 index 0000000..46a873f --- /dev/null +++ b/charts/konnectivity-agent/templates/server-serviceMonitor.yaml @@ -0,0 +1,38 @@ +{{- if .Values.server.serviceMonitor.enabled }} +apiVersion: monitoring.coreos.com/v1 +kind: ServiceMonitor +metadata: + name: konnectivity-server + namespace: {{ .Release.Namespace }} + labels: +{{ include "konnectivity-server.labels" . | indent 4 }} +{{- if .Values.server.serviceMonitor.extraLabels }} +{{ toYaml .Values.server.serviceMonitor.extraLabels | indent 4 }} +{{- end }} +spec: + jobLabel: jobLabel + selector: + matchLabels: +{{ include "konnectivity-server.selectorLabels" . | indent 6}} + namespaceSelector: + matchNames: + - {{ .Release.Namespace }} + endpoints: + - port: http-metrics + path: /metrics + {{- if .Values.server.serviceMonitor.interval}} + interval: {{ .Values.server.serviceMonitor.interval }} + {{- end }} + {{- if .Values.server.serviceMonitor.proxyUrl }} + proxyUrl: {{ .Values.server.serviceMonitor.proxyUrl}} + {{- end }} + bearerTokenFile: /var/run/secrets/kubernetes.io/serviceaccount/token +{{- if .Values.server.serviceMonitor.metricRelabelings }} + metricRelabelings: +{{ tpl (toYaml .Values.server.serviceMonitor.metricRelabelings | indent 4) . }} +{{- end }} +{{- if .Values.server.serviceMonitor.relabelings }} + relabelings: +{{ tpl (toYaml .Values.server.serviceMonitor.relabelings | indent 4) . }} +{{- end }} +{{- end }} diff --git a/charts/konnectivity-agent/templates/service.yaml b/charts/konnectivity-agent/templates/service.yaml new file mode 100644 index 0000000..548e080 --- /dev/null +++ b/charts/konnectivity-agent/templates/service.yaml @@ -0,0 +1,18 @@ +{{- if .Values.serviceMonitor.enabled }} +apiVersion: v1 +kind: Service +metadata: + name: {{ include "konnectivity-agent.fullname" . }} + namespace: {{ .Release.Namespace }} + labels: +{{ include "konnectivity-agent.labels" . | indent 4}} +spec: + clusterIP: None + ports: + - name: http-metrics + port: {{ .Values.ports.admin }} + protocol: TCP + targetPort: {{ .Values.ports.admin }} + selector: + {{- include "konnectivity-agent.selectorLabels" . | nindent 4 }} +{{- end }} diff --git a/charts/konnectivity-agent/templates/serviceMonitor.yaml b/charts/konnectivity-agent/templates/serviceMonitor.yaml new file mode 100644 index 0000000..b2eaa70 --- /dev/null +++ b/charts/konnectivity-agent/templates/serviceMonitor.yaml @@ -0,0 +1,38 @@ +{{- if .Values.serviceMonitor.enabled }} +apiVersion: monitoring.coreos.com/v1 +kind: ServiceMonitor +metadata: + name: {{ include "konnectivity-agent.fullname" . }} + namespace: {{ .Release.Namespace }} + labels: +{{ include "konnectivity-agent.labels" . | indent 4 }} +{{- if .Values.serviceMonitor.extraLabels }} +{{ toYaml .Values.serviceMonitor.extraLabels | indent 4 }} +{{- end }} +spec: + jobLabel: jobLabel + selector: + matchLabels: + {{- include "konnectivity-agent.selectorLabels" . | nindent 6 }} + namespaceSelector: + matchNames: + - {{ .Release.Namespace }} + endpoints: + - port: http-metrics + path: /metrics + {{- if .Values.serviceMonitor.interval}} + interval: {{ .Values.serviceMonitor.interval }} + {{- end }} + {{- if .Values.serviceMonitor.proxyUrl }} + proxyUrl: {{ .Values.serviceMonitor.proxyUrl}} + {{- end }} + bearerTokenFile: /var/run/secrets/kubernetes.io/serviceaccount/token +{{- if .Values.serviceMonitor.metricRelabelings }} + metricRelabelings: +{{ tpl (toYaml .Values.serviceMonitor.metricRelabelings | indent 4) . }} +{{- end }} +{{- if .Values.serviceMonitor.relabelings }} + relabelings: +{{ tpl (toYaml .Values.serviceMonitor.relabelings | indent 4) . }} +{{- end }} +{{- end }} diff --git a/charts/konnectivity-agent/values.yaml b/charts/konnectivity-agent/values.yaml index 6e3e6ea..6d4b1db 100644 --- a/charts/konnectivity-agent/values.yaml +++ b/charts/konnectivity-agent/values.yaml @@ -9,7 +9,6 @@ image: pullPolicy: Always nameOverride: "" -fullnameOverride: "" cluster: host: @@ -57,8 +56,83 @@ nodeSelector: {} affinity: {} +serviceMonitor: + enabled: false + ## Set extraLabels for the serviceMonitor object. + extraLabels: {} + ## Scrape interval. If not set, the Prometheus default scrape interval is used. + ## + interval: "" + + ## proxyUrl: URL of a proxy that should be used for scraping. + ## + proxyUrl: "" + + ## MetricRelabelConfigs to apply to samples after scraping, but before ingestion. + ## ref: https://github.com/prometheus-operator/prometheus-operator/blob/main/Documentation/api.md#relabelconfig + ## + metricRelabelings: [] + # - action: keep + # regex: 'kube_(daemonset|deployment|pod|namespace|node|statefulset).+' + # sourceLabels: [__name__] + + ## RelabelConfigs to apply to samples before scraping + ## ref: https://github.com/prometheus-operator/prometheus-operator/blob/main/Documentation/api.md#relabelconfig + ## + relabelings: [] + # - sourceLabels: [__meta_kubernetes_pod_node_name] + # separator: ; + # regex: ^(.*)$ + # targetLabel: nodename + # replacement: $1 + # action: replace + + ## Additional labels + ## + additionalLabels: {} + # foo: bar + +server: + serviceMonitor: + enabled: false + ## Set extraLabels for the serviceMonitor object. + extraLabels: {} + ## Scrape interval. If not set, the Prometheus default scrape interval is used. + ## + interval: "" + + ## proxyUrl: URL of a proxy that should be used for scraping. + ## + proxyUrl: "" + + ## MetricRelabelConfigs to apply to samples after scraping, but before ingestion. + ## ref: https://github.com/prometheus-operator/prometheus-operator/blob/main/Documentation/api.md#relabelconfig + ## + metricRelabelings: [] + # - action: keep + # regex: 'kube_(daemonset|deployment|pod|namespace|node|statefulset).+' + # sourceLabels: [__name__] + + ## RelabelConfigs to apply to samples before scraping + ## ref: https://github.com/prometheus-operator/prometheus-operator/blob/main/Documentation/api.md#relabelconfig + ## + relabelings: [] + # - sourceLabels: [__meta_kubernetes_pod_node_name] + # separator: ; + # regex: ^(.*)$ + # targetLabel: nodename + # replacement: $1 + # action: replace + + ## Additional labels + ## + additionalLabels: {} + # foo: bar + proportional-autoscaler: enabled: true + image: + tag: 1.8.6 fullnameOverride: konnectivity-agent-proportional-autoscaler options: target: deployment/konnectivity-agent