The CloudSQL proxy pod was using backstage.selectorLabels which made it match the Backstage service selector (app.kubernetes.io/name: backstage, app.kubernetes.io/instance: backstage). This caused Traefik to sometimes route requests to the CloudSQL proxy instead of Backstage, resulting in 502 errors. Changed pod labels to use distinct values (backstage-cloudsql-proxy) so the pod is not selected by the Backstage service. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
50 lines
1.5 KiB
YAML
50 lines
1.5 KiB
YAML
{{- if .Values.cloudSqlProxy.enabled -}}
|
|
apiVersion: apps/v1
|
|
kind: Deployment
|
|
metadata:
|
|
name: backstage-cloudsql-proxy
|
|
namespace: {{ .Values.namespaceOverride }}
|
|
labels:
|
|
{{- include "backstage.labels" . | nindent 4 }}
|
|
app: backstage-cloudsql-proxy
|
|
spec:
|
|
replicas: 1
|
|
selector:
|
|
matchLabels:
|
|
app: backstage-cloudsql-proxy
|
|
template:
|
|
metadata:
|
|
labels:
|
|
app: backstage-cloudsql-proxy
|
|
app.kubernetes.io/name: backstage-cloudsql-proxy
|
|
app.kubernetes.io/instance: backstage-cloudsql-proxy
|
|
spec:
|
|
serviceAccountName: {{ .Values.cloudSqlProxyServiceAccount.name }}
|
|
automountServiceAccountToken: true
|
|
securityContext:
|
|
fsGroup: 65532
|
|
runAsUser: 65532
|
|
runAsNonRoot: true
|
|
containers:
|
|
- name: cloud-sql-proxy
|
|
image: "{{ .Values.cloudSqlProxy.image.repository }}:{{ .Values.cloudSqlProxy.image.tag }}"
|
|
args:
|
|
- "{{ .Values.cloudSqlProxy.connectionName }}"
|
|
- "--port={{ .Values.cloudSqlProxy.port }}"
|
|
- "--address=0.0.0.0"
|
|
{{- if .Values.cloudSqlProxy.privateIp }}
|
|
- "--private-ip"
|
|
{{- end }}
|
|
ports:
|
|
- name: postgres
|
|
containerPort: {{ .Values.cloudSqlProxy.port }}
|
|
protocol: TCP
|
|
securityContext:
|
|
runAsNonRoot: true
|
|
runAsUser: 65532
|
|
allowPrivilegeEscalation: false
|
|
readOnlyRootFilesystem: false
|
|
resources:
|
|
{{- toYaml .Values.cloudSqlProxy.resources | nindent 10 }}
|
|
{{- end }}
|