Skip to content

Commit

Permalink
Add cp-metrics-watcher
Browse files Browse the repository at this point in the history
Signed-off-by: Ian Stanton <ian@tembo.io>
  • Loading branch information
ianstanton committed May 24, 2024
1 parent d681143 commit 17a7997
Show file tree
Hide file tree
Showing 5 changed files with 237 additions and 3 deletions.
62 changes: 62 additions & 0 deletions charts/tembo/templates/cp-metrics-watcher/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -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 }}
70 changes: 70 additions & 0 deletions charts/tembo/templates/cp-metrics-watcher/deployment.yaml
Original file line number Diff line number Diff line change
@@ -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 }}
15 changes: 15 additions & 0 deletions charts/tembo/templates/cp-metrics-watcher/service.yaml
Original file line number Diff line number Diff line change
@@ -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 }}
12 changes: 12 additions & 0 deletions charts/tembo/templates/cp-metrics-watcher/serviceaccount.yaml
Original file line number Diff line number Diff line change
@@ -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 }}
81 changes: 78 additions & 3 deletions charts/tembo/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ cpService:

image:
repository: quay.io/coredb/cp-service
tag: "162404b"
tag: "9d09130"
pullPolicy: IfNotPresent

resources:
Expand Down Expand Up @@ -341,7 +341,7 @@ cpWebserver:

image:
repository: quay.io/coredb/cp-service
tag: "162404b"
tag: "9d09130"
pullPolicy: IfNotPresent

# We should reconfigure the defaults
Expand Down Expand Up @@ -407,7 +407,7 @@ cpReconciler:

image:
repository: quay.io/coredb/cp-service
tag: "162404b"
tag: "9d09130"
pullPolicy: IfNotPresent

resources:
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit 17a7997

Please sign in to comment.