mirror of
https://github.com/cozystack/cozystack.git
synced 2026-12-01 20:56:02 +09:00
The SPA fetched its branding (title, logo) only by reading the cozy-dashboard-console-config ConfigMap through the kube-api. That read already works for any signed-in user — console-rbac.yaml binds get on that ConfigMap to system:authenticated — but it still depends on the kube-api being reachable and on the apiserver authenticating the session's token. A dashboard login whose token the apiserver rejects (an OIDC session the kube-api does not accept) gets no branding at all. Mount that ConfigMap read-only under the nginx web root and serve it at /branding/config.json, and read that static asset first in loadConfig, falling back to the kube-api ConfigMap for charts that predate the mount (their static path serves the SPA index.html, whose non-JSON body trips the fallback). Branding then resolves with no kube-api call at all, so it renders regardless of whether the apiserver authenticates the session and without the console-config-reader RBAC. Because config.json is now a static asset reachable by anyone past the proxy, restrict it to the documented white-labeling keys: the branding map also carries Keycloak-only keys, including loginThemeImage, which can point at a private registry. Keycloak reads those from _cluster.branding directly. The mount uses an items selector so only config.json, not any other key the ConfigMap may grow, is exposed under the web root. Signed-off-by: Alexey Artamonov <aleksei.artamonov@aenix.io>
118 lines
3.8 KiB
YAML
118 lines
3.8 KiB
YAML
apiVersion: apps/v1
|
|
kind: Deployment
|
|
metadata:
|
|
name: cozy-dashboard-console
|
|
spec:
|
|
replicas: 1
|
|
selector:
|
|
matchLabels:
|
|
app.kubernetes.io/instance: cozy-dashboard
|
|
app.kubernetes.io/name: console
|
|
strategy:
|
|
rollingUpdate:
|
|
maxSurge: 25%
|
|
maxUnavailable: 25%
|
|
type: RollingUpdate
|
|
template:
|
|
metadata:
|
|
annotations:
|
|
checksum/config: {{ include (print $.Template.BasePath "/configmap.yaml") . | sha256sum }}
|
|
labels:
|
|
app.kubernetes.io/instance: cozy-dashboard
|
|
app.kubernetes.io/name: console
|
|
spec:
|
|
affinity:
|
|
podAntiAffinity:
|
|
preferredDuringSchedulingIgnoredDuringExecution:
|
|
- podAffinityTerm:
|
|
labelSelector:
|
|
matchExpressions:
|
|
- key: app.kubernetes.io/name
|
|
operator: In
|
|
values:
|
|
- console
|
|
- key: app.kubernetes.io/instance
|
|
operator: In
|
|
values:
|
|
- cozy-dashboard
|
|
topologyKey: kubernetes.io/hostname
|
|
weight: 100
|
|
containers:
|
|
- image: {{ .Values.console.image | quote }}
|
|
imagePullPolicy: IfNotPresent
|
|
livenessProbe:
|
|
failureThreshold: 3
|
|
httpGet:
|
|
path: /healthcheck
|
|
port: 8080
|
|
scheme: HTTP
|
|
initialDelaySeconds: 3
|
|
periodSeconds: 10
|
|
successThreshold: 1
|
|
timeoutSeconds: 2
|
|
startupProbe:
|
|
httpGet:
|
|
path: /healthcheck
|
|
port: 8080
|
|
scheme: HTTP
|
|
failureThreshold: 30
|
|
periodSeconds: 2
|
|
name: console
|
|
ports:
|
|
- containerPort: 8080
|
|
name: http
|
|
protocol: TCP
|
|
resources:
|
|
limits:
|
|
cpu: 200m
|
|
memory: 256Mi
|
|
requests:
|
|
cpu: 100m
|
|
ephemeral-storage: 50Mi
|
|
memory: 128Mi
|
|
securityContext:
|
|
allowPrivilegeEscalation: false
|
|
capabilities:
|
|
add: []
|
|
drop:
|
|
- ALL
|
|
privileged: false
|
|
readOnlyRootFilesystem: false
|
|
runAsGroup: 0
|
|
runAsNonRoot: true
|
|
runAsUser: 101
|
|
seccompProfile:
|
|
type: RuntimeDefault
|
|
terminationMessagePath: /dev/termination-log
|
|
terminationMessagePolicy: File
|
|
# Serve the branding config.json as a static asset under the web root
|
|
# so the SPA reads it with no kube-api call — branding then renders
|
|
# even when the apiserver rejects the session's token, and without the
|
|
# console-config-reader RBAC the kube-api read otherwise needs.
|
|
volumeMounts:
|
|
- name: branding
|
|
mountPath: /usr/share/nginx/html/branding
|
|
readOnly: true
|
|
dnsPolicy: ClusterFirst
|
|
enableServiceLinks: false
|
|
hostIPC: false
|
|
hostNetwork: false
|
|
hostPID: false
|
|
priorityClassName: system-cluster-critical
|
|
restartPolicy: Always
|
|
schedulerName: default-scheduler
|
|
serviceAccountName: cozy-dashboard-console
|
|
terminationGracePeriodSeconds: 30
|
|
volumes:
|
|
# optional: without the ConfigMap the SPA falls back to the kube-api,
|
|
# so a missing branding source is not worth failing the pod on. items
|
|
# restricts the mount to config.json so no other key the ConfigMap may
|
|
# grow becomes a file under the public web root.
|
|
- name: branding
|
|
configMap:
|
|
name: cozy-dashboard-console-config
|
|
optional: true
|
|
items:
|
|
- key: config.json
|
|
path: config.json
|