Skip to content

Commit 589d65f

Browse files
committed
chore: improve deployment
1 parent 82b834e commit 589d65f

File tree

3 files changed

+97
-4
lines changed

3 files changed

+97
-4
lines changed

infra/runtime/syncroot/base/studio-gateway.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,16 @@ kind: Namespace
33
metadata:
44
name: runtime-gateway
55
---
6+
apiVersion: v1
7+
kind: ConfigMap
8+
metadata:
9+
name: runtime-environment
10+
namespace: runtime-gateway
11+
data:
12+
upgrade_channel: ${UPGRADE_CHANNEL}
13+
environment: ${ENVIRONMENT}
14+
serviceowner: ${SERVICEOWNER_ID}
15+
---
616
apiVersion: source.toolkit.fluxcd.io/v1
717
kind: OCIRepository
818
metadata:
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
.config/
2+
infra/
3+
tests/
4+
**/bin
5+
**/obj
Lines changed: 82 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
apiVersion: policy/v1
2+
kind: PodDisruptionBudget
3+
metadata:
4+
name: studio-gateway-pdb
5+
spec:
6+
maxUnavailable: 1
7+
selector:
8+
matchLabels:
9+
app: studio-gateway
10+
---
111
apiVersion: apps/v1
212
kind: Deployment
313
metadata:
@@ -6,45 +16,113 @@ metadata:
616
altinn.studio/image: studio-gateway:latest
717
altinn.studio/image-tag: latest
818
spec:
9-
replicas: 1
19+
minReadySeconds: 3
20+
revisionHistoryLimit: 5
21+
progressDeadlineSeconds: 60
22+
replicas: 2
23+
strategy:
24+
# Rolling upgrade of pods
25+
type: RollingUpdate
26+
rollingUpdate:
27+
maxUnavailable: 0
28+
maxSurge: 1
1029
selector:
1130
matchLabels:
1231
app: studio-gateway
1332
template:
1433
metadata:
1534
labels:
1635
app: studio-gateway
36+
annotations:
37+
# for mTLS mainly
38+
linkerd.io/inject: enabled
1739
spec:
40+
topologySpreadConstraints:
41+
# Try to spread across availability zones first (highest priority)
42+
# A skew of 1 can result in 1 AZ being unused when AZs = 3 and replicas = 3
43+
- maxSkew: 1
44+
topologyKey: topology.kubernetes.io/zone
45+
# ScheduleAnyway ensures progress even if distribution is imperfect
46+
whenUnsatisfiable: ScheduleAnyway
47+
labelSelector:
48+
matchLabels:
49+
app: studio-gateway
50+
# Try to spread across nodes within zones
51+
# Prevents multiple replicas from running on the same node, improving fault tolerance
52+
- maxSkew: 1
53+
topologyKey: kubernetes.io/hostname
54+
whenUnsatisfiable: ScheduleAnyway
55+
labelSelector:
56+
matchLabels:
57+
app: studio-gateway
1858
serviceAccountName: studio-gateway
59+
terminationGracePeriodSeconds: 30
1960
# explicitly set security context to embedded .net non-root user (1654)
2061
securityContext:
2162
runAsUser: 1654
2263
runAsGroup: 1654
2364
fsGroup: 1654
2465
runAsNonRoot: true
66+
# Seccomp (secure computing mode) restricts syscalls the container can make
67+
# RuntimeDefault uses the container runtime's default profile, blocking risky syscalls
68+
seccompProfile:
69+
type: RuntimeDefault
2570
containers:
2671
- name: studio-gateway
27-
image: studio-gateway:latest
72+
image: ""
73+
imagePullPolicy: IfNotPresent
74+
securityContext:
75+
allowPrivilegeEscalation: false
76+
readOnlyRootFilesystem: true
77+
privileged: false
78+
capabilities:
79+
drop:
80+
- ALL
2881
ports:
2982
- containerPort: 8080
3083
name: http
3184
protocol: TCP
3285
env:
3386
- name: ASPNETCORE_HTTP_PORTS
3487
value: "8080"
88+
- name: ASPNETCORE_ENVIRONMENT
89+
valueFrom:
90+
# Configmap is created in syncroot
91+
configMapKeyRef:
92+
name: runtime-environment
93+
key: environment
94+
- name: GATEWAY_UPGRADE_CHANNEL
95+
valueFrom:
96+
configMapKeyRef:
97+
name: runtime-environment
98+
key: upgrade_channel
99+
- name: GATEWAY_ENVIRONMENT
100+
valueFrom:
101+
configMapKeyRef:
102+
name: runtime-environment
103+
key: environment
104+
- name: GATEWAY_SERVICEOWNER
105+
valueFrom:
106+
configMapKeyRef:
107+
name: runtime-environment
108+
key: serviceowner
35109
livenessProbe:
36110
httpGet:
37111
path: /health/live
38112
port: 8080
39-
initialDelaySeconds: 10
113+
initialDelaySeconds: 2
40114
periodSeconds: 10
41115
timeoutSeconds: 3
42116
failureThreshold: 3
43117
readinessProbe:
44118
httpGet:
45119
path: /health/ready
46120
port: 8080
47-
initialDelaySeconds: 5
121+
initialDelaySeconds: 2
48122
periodSeconds: 5
49123
timeoutSeconds: 3
50124
failureThreshold: 3
125+
resources:
126+
requests:
127+
cpu: 10m
128+
memory: 64Mi

0 commit comments

Comments
 (0)