Skip to content

Commit

Permalink
deployment sidecar for logging & prometheus metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
usu committed Mar 31, 2024
1 parent 5745469 commit 5192278
Show file tree
Hide file tree
Showing 4 changed files with 94 additions and 1 deletion.
55 changes: 54 additions & 1 deletion .helm/ecamp3/templates/api_cache_deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ spec:
metadata:
labels:
{{- include "apiCache.selectorLabels" . | nindent 8 }}
annotations:
checksum/vclConfigmap: {{ include (print $.Template.BasePath "/api_cache_vcl_configmap.yaml") . | sha256sum }}
rollme: {{ .Values.imageTag | quote }}
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
Expand All @@ -25,7 +28,7 @@ spec:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
enableServiceLinks: false
containers:
- name: {{ .Chart.Name }}-api-cache
- name: {{ .Chart.Name }}-api-cache-varnishd
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.apiCache.image.repository }}:{{ .Values.apiCache.image.tag | default .Values.imageTag }}"
Expand Down Expand Up @@ -54,8 +57,58 @@ spec:
volumeMounts:
- name: vcl-configmap
mountPath: /etc/varnish
- name: vsm
mountPath: /var/lib/varnish
{{- if .Values.apiCache.logging.enabled }}
- name: {{ .Chart.Name }}-api-cache-varnishncsa
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.apiCache.image.repository }}:{{ .Values.apiCache.image.tag | default .Values.imageTag }}"
imagePullPolicy: {{ .Values.apiCache.image.pullPolicy }}
command:
- varnishncsa
{{- if .Values.apiCache.logging.customOutputJsonFormat }}
- -j
{{- end }}
{{- if .Values.apiCache.logging.customOutput }}
- -F
- {{ .Values.apiCache.logging.customOutput | quote }}
{{- end }}
- -t
- {{ .Values.apiCache.logging.timeout | quote }}
resources:
{{- toYaml .Values.apiCache.logging.resources | nindent 12 }}
volumeMounts:
- name: vsm
mountPath: /var/lib/varnish
{{- end }}
{{- if .Values.apiCache.prometheus.enabled }}
- name: {{ .Chart.Name }}-api-cache-prometheus-exporter
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.apiCache.prometheus.image.repository }}:{{ .Values.apiCache.prometheus.image.tag }}"
imagePullPolicy: {{ .Values.apiCache.prometheus.image.pullPolicy }}
ports:
- name: api-cache-metrics
containerPort: {{ .Values.apiCache.prometheus.port }}
protocol: TCP
resources:
{{- toYaml .Values.apiCache.prometheus.resources | nindent 12 }}
command:
- prometheus-varnish-exporter
- -web.telemetry-path
- "{{ .Values.apiCache.prometheus.path }}"
- -web.listen-address
- ":{{ .Values.apiCache.prometheus.port }}"
volumeMounts:
- name: vsm
mountPath: /var/lib/varnish
{{- end }}
volumes:
- name: vcl-configmap
configMap:
name: {{ include "apiCache.name" . }}-vcl-configmap
- name: vsm
emptyDir:
medium: Memory
{{- end }}
4 changes: 4 additions & 0 deletions .helm/ecamp3/templates/api_cache_service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ spec:
targetPort: api-cache-purge
protocol: TCP
name: api-cache-purge
- port: {{ .Values.apiCache.prometheus.port }}
targetPort: api-cache-metrics
protocol: TCP
name: api-cache-metrics
selector:
{{- include "apiCache.selectorLabels" . | nindent 4 }}
{{- end }}
26 changes: 26 additions & 0 deletions .helm/ecamp3/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,32 @@ apiCache:
requests:
cpu: 10m
memory: 100Mi
logging:
enabled: true
customOutput: null
customOutputJsonFormat: false
# Timeout before returning error on initial VSM connection.
# If set the VSM connection is retried every 0.5 seconds for this many seconds.
# If zero the connection is attempted only once and will fail immediately if unsuccessful.
# If set to "off", the connection will not fail, allowing the utility to start and wait indefinetely for the Varnish instance to appear.
# Defaults to "off" in this case.
timeout: "off"
resources:
requests:
cpu: 10m
memory: 20Mi
prometheus:
enabled: true
image:
repository: softonic/varnish
tag: 7.2.1
pullPolicy: IfNotPresent
path: "/metrics"
port: 9131
resources:
requests:
cpu: 10m
memory: 20Mi

autoscaling:
enabled: false
Expand Down
10 changes: 10 additions & 0 deletions .ops/observability/prometheus-values-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,16 @@ prometheus:
- default
endpoints:
- port: "api-metrics"
- name: "varnish"
selector:
matchLabels:
app.kubernetes.io/instance: ecamp3-dev
app.kubernetes.io/name: ecamp3-api-cache
namespaceSelector:
matchNames:
- default
endpoints:
- port: "api-cache-metrics"
prometheusSpec:
storageSpec:
volumeClaimTemplate:
Expand Down

0 comments on commit 5192278

Please sign in to comment.