-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathkubernetes-deploy.yaml
More file actions
162 lines (157 loc) · 3.45 KB
/
kubernetes-deploy.yaml
File metadata and controls
162 lines (157 loc) · 3.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
---
# Example Kubernetes deployment using CI/CD-built images from GHCR
# Replace `{{IMAGE_TAG}}` with the pinned tag produced by CI (for example v0.2.0)
apiVersion: v1
kind: ConfigMap
metadata:
name: routing-table-data
namespace: default
data:
# Do not store very large files here. Use a PVC or external storage for routes.txt.
example: |
# small example dataset
192.0.2.0/24,198.51.100.1,10
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: routing-table-api
namespace: default
labels:
app: routing-table-api
spec:
replicas: 2
strategy:
type: RollingUpdate
rollingUpdate:
maxUnavailable: 25%
maxSurge: 25%
selector:
matchLabels:
app: routing-table-api
template:
metadata:
labels:
app: routing-table-api
spec:
containers:
- name: api
image: ghcr.io/weekmo/routing-table-api:{{IMAGE_TAG}}
imagePullPolicy: IfNotPresent
ports:
- containerPort: 5000
name: http
protocol: TCP
volumeMounts:
- name: routes-data
mountPath: /app/routes.txt
subPath: routes.txt
readOnly: true
livenessProbe:
httpGet:
path: /health
port: 5000
initialDelaySeconds: 30
periodSeconds: 30
timeoutSeconds: 10
failureThreshold: 3
readinessProbe:
httpGet:
path: /health
port: 5000
initialDelaySeconds: 20
periodSeconds: 10
timeoutSeconds: 5
failureThreshold: 3
resources:
requests:
memory: "512Mi"
cpu: "500m"
limits:
memory: "2Gi"
cpu: "2000m"
env:
- name: PYTHONUNBUFFERED
value: "1"
- name: PROC_NUM
value: "4"
- name: HOST
value: "0.0.0.0"
- name: PORT
value: "5000"
volumes:
- name: routes-data
persistentVolumeClaim:
claimName: routes-pvc
---
apiVersion: v1
kind: Service
metadata:
name: routing-table-api
namespace: default
labels:
app: routing-table-api
spec:
type: ClusterIP
ports:
- port: 5000
targetPort: 5000
protocol: TCP
name: http
selector:
app: routing-table-api
---
apiVersion: batch/v1
kind: Job
metadata:
name: routing-table-api-tests
namespace: default
labels:
app: routing-table-api-tests
spec:
backoffLimit: 2
template:
metadata:
labels:
app: routing-table-api-tests
spec:
restartPolicy: Never
containers:
- name: tests
image: ghcr.io/weekmo/routing-table-api:test
imagePullPolicy: IfNotPresent
env:
- name: API_URL
value: "http://routing-table-api:5000"
resources:
requests:
memory: "256Mi"
cpu: "250m"
limits:
memory: "512Mi"
cpu: "500m"
initContainers:
- name: wait-for-api
image: busybox:1.36
command:
- sh
- -c
- |
until wget -q --spider http://routing-table-api:5000/health; do
echo "Waiting for API to be ready..."
sleep 5
done
echo "API is ready!"
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: routes-pvc
namespace: default
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 1Gi
storageClassName: standard