Files
mtusi2026lab3/charts/messenger/templates/api.yaml
T

124 lines
3.2 KiB
YAML

apiVersion: v1
kind: ConfigMap
metadata:
name: messenger-config
namespace: {{ .Release.Namespace }}
data:
APP_PORT: '8080'
VALKEY_COORDINATOR: shard0
VALKEY_SHARDS: {{ include "messenger.shards" . | quote }}
{{- range $key, $value := .Values.api.env }}
{{ $key }}: {{ $value | quote }}
{{- end }}
---
apiVersion: v1
kind: Service
metadata:
labels:
app: api
name: api
namespace: {{ .Release.Namespace }}
spec:
selector:
app: api
ports:
- name: http
port: 8080
targetPort: 8080
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: api
namespace: {{ .Release.Namespace }}
spec:
{{- if not .Values.autoscaling.enabled }}
replicas: {{ .Values.api.replicas }}
{{- end }}
strategy:
rollingUpdate:
maxUnavailable: 0
maxSurge: 1
selector:
matchLabels:
app: api
template:
metadata:
annotations:
checksum/config: {{ printf "%s%s" (include "messenger.shards" .) (toJson .Values.api.env) | sha256sum }}
labels:
app: api
spec:
{{- with .Values.api.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
imagePullSecrets:
- name: {{ .Values.imagePullSecret }}
terminationGracePeriodSeconds: 20
topologySpreadConstraints:
- maxSkew: 1
topologyKey: kubernetes.io/hostname
whenUnsatisfiable: ScheduleAnyway
labelSelector:
matchLabels:
app: api
securityContext:
runAsNonRoot: true
runAsUser: 65532
seccompProfile:
type: RuntimeDefault
containers:
- name: api
image: "{{ .Values.image.repository }}@{{ .Values.image.digest }}"
imagePullPolicy: IfNotPresent
ports:
- containerPort: 8080
envFrom:
- configMapRef:
name: messenger-config
env:
- name: INSTANCE_ID
valueFrom:
fieldRef:
fieldPath: metadata.name
- name: CURSOR_SIGNING_KEY
valueFrom:
secretKeyRef:
name: {{ .Values.databaseSecret }}
key: cursor-key
- name: DATABASE_URL
valueFrom:
secretKeyRef:
name: {{ .Values.databaseSecret }}
key: database-url
resources:
{{- toYaml .Values.api.resources | nindent 12 }}
lifecycle:
preStop:
sleep:
seconds: 3
startupProbe:
httpGet:
path: /health/ready
port: 8080
periodSeconds: 2
failureThreshold: 30
readinessProbe:
timeoutSeconds: {{ .Values.api.readiness.timeoutSeconds }}
failureThreshold: {{ .Values.api.readiness.failureThreshold }}
httpGet:
path: /health/ready
port: 8080
periodSeconds: 2
livenessProbe:
httpGet:
path: /health/live
port: 8080
periodSeconds: 5
securityContext:
readOnlyRootFilesystem: true
allowPrivilegeEscalation: false
capabilities:
drop: [ALL]