From 17a799707ab9d1c945fdfbf029bfe3cf4daa9c11 Mon Sep 17 00:00:00 2001 From: Ian Stanton Date: Fri, 24 May 2024 16:47:06 -0400 Subject: [PATCH] Add cp-metrics-watcher Signed-off-by: Ian Stanton --- .../templates/cp-metrics-watcher/_helpers.tpl | 62 ++++++++++++++ .../cp-metrics-watcher/deployment.yaml | 70 ++++++++++++++++ .../templates/cp-metrics-watcher/service.yaml | 15 ++++ .../cp-metrics-watcher/serviceaccount.yaml | 12 +++ charts/tembo/values.yaml | 81 ++++++++++++++++++- 5 files changed, 237 insertions(+), 3 deletions(-) create mode 100644 charts/tembo/templates/cp-metrics-watcher/_helpers.tpl create mode 100644 charts/tembo/templates/cp-metrics-watcher/deployment.yaml create mode 100644 charts/tembo/templates/cp-metrics-watcher/service.yaml create mode 100644 charts/tembo/templates/cp-metrics-watcher/serviceaccount.yaml diff --git a/charts/tembo/templates/cp-metrics-watcher/_helpers.tpl b/charts/tembo/templates/cp-metrics-watcher/_helpers.tpl new file mode 100644 index 0000000..b59539c --- /dev/null +++ b/charts/tembo/templates/cp-metrics-watcher/_helpers.tpl @@ -0,0 +1,62 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "cpMetricsWatcher.name" -}} +{{- default .Chart.Name .Values.cpMetricsWatcher.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 "cpMetricsWatcher.fullname" -}} +{{- if .Values.cpMetricsWatcher.fullnameOverride }} +{{- .Values.cpMetricsWatcher.fullnameOverride | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- $name := default .Chart.Name .Values.cpMetricsWatcher.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 "cpMetricsWatcher.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "cpMetricsWatcher.labels" -}} +helm.sh/chart: {{ include "cpMetricsWatcher.chart" . }} +{{ include "cpMetricsWatcher.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "cpMetricsWatcher.selectorLabels" -}} +app.kubernetes.io/name: {{ include "cpMetricsWatcher.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +Create the name of the service account to use +*/}} +{{- define "cpMetricsWatcher.serviceAccountName" -}} +{{- if .Values.cpMetricsWatcher.serviceAccount.create }} +{{- default (include "cpMetricsWatcher.fullname" .) .Values.cpMetricsWatcher.serviceAccount.name }} +{{- else }} +{{- default "default" .Values.cpMetricsWatcher.serviceAccount.name }} +{{- end }} +{{- end }} diff --git a/charts/tembo/templates/cp-metrics-watcher/deployment.yaml b/charts/tembo/templates/cp-metrics-watcher/deployment.yaml new file mode 100644 index 0000000..d999565 --- /dev/null +++ b/charts/tembo/templates/cp-metrics-watcher/deployment.yaml @@ -0,0 +1,70 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "cpMetricsWatcher.fullname" . }} + labels: + {{- include "cpMetricsWatcher.labels" . | nindent 4 }} +spec: + replicas: {{ .Values.cpMetricsWatcher.replicas }} + selector: + matchLabels: + {{- include "cpMetricsWatcher.selectorLabels" . | nindent 6 }} + strategy: + rollingUpdate: + maxSurge: 25% + maxUnavailable: 25% + type: RollingUpdate + template: + metadata: + {{- with .Values.cpMetricsWatcher.podAnnotations }} + annotations: + {{- toYaml . | nindent 8 }} + {{- end }} + labels: + {{- include "cpMetricsWatcher.selectorLabels" . | nindent 8 }} + spec: + {{- with .Values.cpMetricsWatcher.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + serviceAccountName: {{ include "cpMetricsWatcher.fullname" . }} + securityContext: + {{- toYaml .Values.cpMetricsWatcher.podSecurityContext | nindent 8 }} + containers: + - name: {{ .Chart.Name }} + command: + - /usr/local/bin/cp-service + ports: + - name: http + containerPort: 8080 + protocol: TCP + env: + - name: RUST_LOG + value: {{ .Values.cpMetricsWatcher.logLevel }} + {{- if .Values.cpMetricsWatcher.env }}{{ .Values.cpMetricsWatcher.env | default list | toYaml | nindent 10 }}{{- end }} + securityContext: + {{- toYaml .Values.cpMetricsWatcher.securityContext | nindent 12 }} + image: "{{ .Values.cpMetricsWatcher.image.repository }}:{{ .Values.cpMetricsWatcher.image.tag | default .Chart.AppVersion }}" + imagePullPolicy: {{ .Values.cpMetricsWatcher.image.pullPolicy }} + livenessProbe: + httpGet: + path: "/health/lively" + port: http + readinessProbe: + httpGet: + path: "/health/lively" + port: http + resources: + {{- toYaml .Values.cpMetricsWatcher.resources | nindent 12 }} + {{- with .Values.cpMetricsWatcher.nodeSelector }} + nodeSelector: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.cpMetricsWatcher.affinity }} + affinity: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.cpMetricsWatcher.tolerations }} + tolerations: + {{- toYaml . | nindent 8 }} + {{- end }} diff --git a/charts/tembo/templates/cp-metrics-watcher/service.yaml b/charts/tembo/templates/cp-metrics-watcher/service.yaml new file mode 100644 index 0000000..3784608 --- /dev/null +++ b/charts/tembo/templates/cp-metrics-watcher/service.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ include "cpMetricsWatcher.fullname" . }} + labels: + {{- include "cpMetricsWatcher.labels" . | nindent 4 }} +spec: + type: {{ .Values.cpMetricsWatcher.service.type }} + ports: + - port: {{ .Values.cpMetricsWatcher.service.port }} + targetPort: http + protocol: TCP + name: http + selector: + {{- include "cpMetricsWatcher.selectorLabels" . | nindent 4 }} diff --git a/charts/tembo/templates/cp-metrics-watcher/serviceaccount.yaml b/charts/tembo/templates/cp-metrics-watcher/serviceaccount.yaml new file mode 100644 index 0000000..3f674f2 --- /dev/null +++ b/charts/tembo/templates/cp-metrics-watcher/serviceaccount.yaml @@ -0,0 +1,12 @@ +{{ if .Values.cpMetricsWatcher.serviceAccount.create }} +apiVersion: v1 +kind: ServiceAccount +metadata: + name: {{ include "cpMetricsWatcher.fullname" . }} + labels: + {{- include "cpMetricsWatcher.labels" . | nindent 4 }} + {{- with .Values.cpMetricsWatcher.serviceAccount.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +{{ end }} diff --git a/charts/tembo/values.yaml b/charts/tembo/values.yaml index 7542c5f..516626f 100644 --- a/charts/tembo/values.yaml +++ b/charts/tembo/values.yaml @@ -272,7 +272,7 @@ cpService: image: repository: quay.io/coredb/cp-service - tag: "162404b" + tag: "9d09130" pullPolicy: IfNotPresent resources: @@ -341,7 +341,7 @@ cpWebserver: image: repository: quay.io/coredb/cp-service - tag: "162404b" + tag: "9d09130" pullPolicy: IfNotPresent # We should reconfigure the defaults @@ -407,7 +407,7 @@ cpReconciler: image: repository: quay.io/coredb/cp-service - tag: "162404b" + tag: "9d09130" pullPolicy: IfNotPresent resources: @@ -458,6 +458,81 @@ cpReconciler: name: control-plane-queue-connection key: rw_uri +cpMetricsWatcher: + logLevel: info + + replicas: 1 + + podMonitor: + enabled: false + port: http + path: /metrics + + externalSecrets: + refreshInterval: "5m" + parameterStore: + name: "secret-store-parameter-store" + kind: ClusterSecretStore + secretName: ~ + secretRegex: ~ + + image: + repository: quay.io/coredb/cp-service + tag: "9d09130" + pullPolicy: IfNotPresent + + resources: + limits: + cpu: 1 + memory: 128Mi + requests: + cpu: 100m + memory: 128Mi + + serviceAccount: + create: true + annotations: {} + # Defaults to match name of deployment, + # when this is set to empty string. + name: "" + + service: + type: ClusterIP + port: 80 + + imagePullSecrets: [] + nameOverride: cp-metrics-watcher + fullnameOverride: "" + podAnnotations: {} + podSecurityContext: {} + securityContext: {} + nodeSelector: {} + tolerations: [] + affinity: {} + env: + - name: SERVICE_NAME + value: cp-metrics-watcher + - name: RUN_RECONCILE + value: 'false' + - name: RUN_REPORTER + value: 'false' + - name: RUN_METRONOME_REPORTER + value: 'false' + - name: RUN_METRICS_WATCHER + value: 'true' + - name: MAX_CONN_POOL_SIZE + value: '10' + - name: POSTGRES_CONNECTION + valueFrom: + secretKeyRef: + name: control-plane-connection + key: rw_uri + - name: POSTGRES_QUEUE_CONNECTION + valueFrom: + secretKeyRef: + name: control-plane-queue-connection + key: rw_uri + dataplaneWebserver: logLevel: info