Skip to content

Commit

Permalink
Enable metrics in helm charts (#28)
Browse files Browse the repository at this point in the history
Adds a deployment template for the site controller, with a metrics port
associated with the pod. Enables users to put custom pod labels on the
inbox listener, stream service, and site controller, so that they may
opt these deployments into scraping executed by some external framework
on the basis of labels.

For instance, if a prometheus PodMonitor is set up to scrape pods with
label monitoring: true, this can now be accomplished through the chart.
  • Loading branch information
wkalt authored Jan 21, 2023
1 parent 2e23d90 commit 5429ba1
Show file tree
Hide file tree
Showing 9 changed files with 92 additions and 8 deletions.
4 changes: 2 additions & 2 deletions charts/edge-site/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ type: application
# 1.0.0-alpha.0
# 1.0.0-alpha.1
# 1.0.0
version: "0.0.4"
version: "0.0.5"

appVersion: "e29ff09f68025bf55fa84718dea6842517a8507a"
appVersion: "201bbaf83eec1617bdb3951be571ac5e63e8ba77"
4 changes: 2 additions & 2 deletions charts/edge-site/templates/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ spec:
targetPort: 9099
- name: metrics
protocol: TCP
port: 6002
targetPort: 6002
port: 6001
targetPort: 6001
4 changes: 2 additions & 2 deletions charts/primary-site/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ type: application
# 1.0.0-alpha.0
# 1.0.0-alpha.1
# 1.0.0
version: 0.0.5
version: 0.0.6

appVersion: "70f49b27f1123702526d83fbc754992f578b4ca2"
appVersion: "201bbaf83eec1617bdb3951be571ac5e63e8ba77"
2 changes: 2 additions & 0 deletions charts/primary-site/templates/cronjobs/garbage-collector.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,10 @@ spec:
name: cloud-credentials
optional: true
env:
{{ with lookup "v1" "Secret" .Release.Namespace "cloud-credentials" }}
- name: GOOGLE_APPLICATION_CREDENTIALS
value: /secrets/credentials.json
{{ end }}
- name: FOXGLOVE_API_URL
value: "{{ .Values.globals.foxgloveApiUrl }}"
- name: FOXGLOVE_SITE_TOKEN
Expand Down
8 changes: 8 additions & 0 deletions charts/primary-site/templates/deployments/inbox-listener.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ spec:
metadata:
labels:
app: inbox-listener
{{- range $key, $value := .Values.inboxListener.deployment.podLabels }}
{{ $key }}: {{ $value | quote }}
{{- end }}
spec:
volumes:
- name: cloud-credentials
Expand All @@ -37,13 +40,18 @@ spec:
volumeMounts:
- mountPath: /secrets
name: cloud-credentials
ports:
- name: metrics
containerPort: 6001
envFrom:
- secretRef:
name: cloud-credentials
optional: true
env:
{{ with lookup "v1" "Secret" .Release.Namespace "cloud-credentials" }}
- name: GOOGLE_APPLICATION_CREDENTIALS
value: /secrets/credentials.json
{{ end }}
- name: FOXGLOVE_API_URL
value: "{{ .Values.globals.foxgloveApiUrl }}"
- name: FOXGLOVE_SITE_TOKEN
Expand Down
46 changes: 46 additions & 0 deletions charts/primary-site/templates/deployments/site-controller.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: site-controller
labels:
app: site-controller
spec:
replicas: 1
selector:
matchLabels:
app: site-controller
template:
metadata:
labels:
app: site-controller
{{- range $key, $value := .Values.siteController.deployment.podLabels }}
{{ $key }}: {{ $value | quote }}
{{- end }}
spec:
containers:
- name: site-controller
image: us-central1-docker.pkg.dev/foxglove-images/images/site-controller:{{ .Chart.AppVersion }}
resources:
requests:
cpu: {{ .Values.siteController.deployment.resources.requests.cpu }}
memory: {{ .Values.siteController.deployment.resources.requests.memory }}
limits:
cpu: {{ .Values.siteController.deployment.resources.limits.cpu }}
memory: {{ .Values.siteController.deployment.resources.limits.memory }}
livenessProbe:
httpGet:
path: /liveness
port: 6002
ports:
- name: metrics
containerPort: 6001
env:
- name: FOXGLOVE_API_URL
value: {{ .Values.globals.foxgloveApiUrl }}
- name: FOXGLOVE_SITE_TOKEN
valueFrom:
secretKeyRef:
name: foxglove-site
key: token
- name: MODE
value: self-managed
10 changes: 9 additions & 1 deletion charts/primary-site/templates/deployments/stream-service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ spec:
metadata:
labels:
app: stream-service
{{- range $key, $value := .Values.streamService.deployment.podLabels }}
{{ $key }}: {{ $value | quote }}
{{- end }}
spec:
volumes:
- name: cloud-credentials
Expand All @@ -35,7 +38,10 @@ spec:
cpu: {{ .Values.streamService.deployment.resources.limits.cpu }}
memory: {{ .Values.streamService.deployment.resources.limits.memory }}
ports:
- containerPort: 8080
- name: http
containerPort: 8080
- name: metrics
containerPort: 6001
volumeMounts:
- mountPath: /secrets
name: cloud-credentials
Expand All @@ -44,8 +50,10 @@ spec:
name: cloud-credentials
optional: true
env:
{{ with lookup "v1" "Secret" .Release.Namespace "cloud-credentials" }}
- name: GOOGLE_APPLICATION_CREDENTIALS
value: /secrets/credentials.json
{{ end }}
- name: FOXGLOVE_API_URL
value: "{{ .Values.globals.foxgloveApiUrl }}"
- name: PORT
Expand Down
9 changes: 8 additions & 1 deletion charts/primary-site/templates/services/stream.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@ metadata:
spec:
type: ClusterIP
ports:
- port: 8080
- name: http
port: 8080
protocol: TCP
targetPort: 8080
- name: metrics
port: 6001
protocol: TCP
targetPort: 6001
selector:
app: stream-service
13 changes: 13 additions & 0 deletions charts/primary-site/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ inboxListener:
limits:
cpu: 1000m
memory: 1Gi
podLabels: {}

streamService:
deployment:
Expand All @@ -48,6 +49,18 @@ streamService:
limits:
cpu: 1000m
memory: 1Gi
podLabels: {}

siteController:
deployment:
resources:
requests:
cpu: 250m
memory: 250Mi
limits:
cpu: 250m
memory: 250Mi
podLabels: {}

garbageCollector:
schedule: "*/10 * * * *" # every 10 minutes
Expand Down

0 comments on commit 5429ba1

Please sign in to comment.