Skip to content

Commit 192cb52

Browse files
committed
chore: improve deployment
1 parent 82b834e commit 192cb52

File tree

3 files changed

+109
-4
lines changed

3 files changed

+109
-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: 94 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
apiVersion: policy/v1
2+
kind: PodDisruptionBudget
3+
metadata:
4+
name: studio-gateway-pdb
5+
spec:
6+
# Makes sure that during e.g. nodepool upgrades, when nodes are drained
7+
# we apply a constraint that at most 1 AZ (hopefully, depending on skew)
8+
# is disrupted at a time
9+
# Examples:
10+
# 2 replicas * 30% = 0.6 = 1 unavailable
11+
# 3 replicas * 30% = 0.9 = 1 unavailable
12+
maxUnavailable: '30%'
13+
selector:
14+
matchLabels:
15+
app: studio-gateway
16+
---
117
apiVersion: apps/v1
218
kind: Deployment
319
metadata:
@@ -6,45 +22,119 @@ metadata:
622
altinn.studio/image: studio-gateway:latest
723
altinn.studio/image-tag: latest
824
spec:
9-
replicas: 1
25+
minReadySeconds: 3
26+
revisionHistoryLimit: 5
27+
progressDeadlineSeconds: 60
28+
replicas: 2
29+
strategy:
30+
# Rolling upgrade of pods
31+
type: RollingUpdate
32+
rollingUpdate:
33+
# Conservative rollout.
34+
# Setting maxUnavailable to 0 means we will never scale lower than desired replicas
35+
# during rollouts, but we might have to scale up the nodepool due to surge
36+
# Surge examples:
37+
# 2 replicas * 20% = 0.4 = 1 surge
38+
# 3 replicas * 20% = 0.6 = 1 surge
39+
maxUnavailable: 0
40+
maxSurge: '20%'
1041
selector:
1142
matchLabels:
1243
app: studio-gateway
1344
template:
1445
metadata:
1546
labels:
1647
app: studio-gateway
48+
annotations:
49+
# for mTLS mainly
50+
linkerd.io/inject: enabled
1751
spec:
52+
topologySpreadConstraints:
53+
# Try to spread across availability zones first (highest priority)
54+
# A skew of 1 can result in 1 AZ being unused when AZs = 3 and replicas = 3
55+
- maxSkew: 1
56+
topologyKey: topology.kubernetes.io/zone
57+
# ScheduleAnyway ensures progress even if distribution is imperfect
58+
whenUnsatisfiable: ScheduleAnyway
59+
labelSelector:
60+
matchLabels:
61+
app: studio-gateway
62+
# Try to spread across nodes within zones
63+
# Prevents multiple replicas from running on the same node, improving fault tolerance
64+
- maxSkew: 1
65+
topologyKey: kubernetes.io/hostname
66+
whenUnsatisfiable: ScheduleAnyway
67+
labelSelector:
68+
matchLabels:
69+
app: studio-gateway
1870
serviceAccountName: studio-gateway
71+
terminationGracePeriodSeconds: 30
1972
# explicitly set security context to embedded .net non-root user (1654)
2073
securityContext:
2174
runAsUser: 1654
2275
runAsGroup: 1654
2376
fsGroup: 1654
2477
runAsNonRoot: true
78+
# Seccomp (secure computing mode) restricts syscalls the container can make
79+
# RuntimeDefault uses the container runtime's default profile, blocking risky syscalls
80+
seccompProfile:
81+
type: RuntimeDefault
2582
containers:
2683
- name: studio-gateway
27-
image: studio-gateway:latest
84+
image: ""
85+
imagePullPolicy: IfNotPresent
86+
securityContext:
87+
allowPrivilegeEscalation: false
88+
readOnlyRootFilesystem: true
89+
privileged: false
90+
capabilities:
91+
drop:
92+
- ALL
2893
ports:
2994
- containerPort: 8080
3095
name: http
3196
protocol: TCP
3297
env:
3398
- name: ASPNETCORE_HTTP_PORTS
3499
value: "8080"
100+
- name: ASPNETCORE_ENVIRONMENT
101+
valueFrom:
102+
# Configmap is created in syncroot
103+
configMapKeyRef:
104+
name: runtime-environment
105+
key: environment
106+
- name: GATEWAY_UPGRADE_CHANNEL
107+
valueFrom:
108+
configMapKeyRef:
109+
name: runtime-environment
110+
key: upgrade_channel
111+
- name: GATEWAY_ENVIRONMENT
112+
valueFrom:
113+
configMapKeyRef:
114+
name: runtime-environment
115+
key: environment
116+
- name: GATEWAY_SERVICEOWNER
117+
valueFrom:
118+
configMapKeyRef:
119+
name: runtime-environment
120+
key: serviceowner
35121
livenessProbe:
36122
httpGet:
37123
path: /health/live
38124
port: 8080
39-
initialDelaySeconds: 10
125+
initialDelaySeconds: 2
40126
periodSeconds: 10
41127
timeoutSeconds: 3
42128
failureThreshold: 3
43129
readinessProbe:
44130
httpGet:
45131
path: /health/ready
46132
port: 8080
47-
initialDelaySeconds: 5
133+
initialDelaySeconds: 2
48134
periodSeconds: 5
49135
timeoutSeconds: 3
50136
failureThreshold: 3
137+
resources:
138+
requests:
139+
cpu: 10m
140+
memory: 64Mi

0 commit comments

Comments
 (0)