-
Notifications
You must be signed in to change notification settings - Fork 0
/
flickrs-k8s.yaml
246 lines (236 loc) · 5.58 KB
/
flickrs-k8s.yaml
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
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: flickrs-static
labels:
app: flickrs-static
spec:
replicas: 2
selector:
matchLabels:
app: flickrs-static
template:
metadata:
labels:
app: flickrs-static
spec:
imagePullSecrets:
- name: regcred
containers:
- name: flickrs-static
imagePullPolicy: Always
image: registry.gitlab.com/etrovub/smartnets/flickrs/nginx-static:master
livenessProbe:
httpGet:
path: /index.html
port: 80
initialDelaySeconds: 3
periodSeconds: 3
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: flickrs-api
labels:
app: flickrs-api
spec:
replicas: 1
# As long as we use sqlite, we need Recreate instead of roll-over
strategy:
type: Recreate
selector:
matchLabels:
app: flickrs-api
template:
metadata:
labels:
app: flickrs-api
spec:
imagePullSecrets:
- name: regcred
containers:
- name: flickrs-api
imagePullPolicy: Always
image: registry.gitlab.com/etrovub/smartnets/flickrs/apiserver:master
livenessProbe:
httpGet:
path: /api/setup
port: 8000
initialDelaySeconds: 3
periodSeconds: 3
env:
- name: RUST_BACKTRACE
value: "1"
- name: IMAGE_BASE_URL
value: /var/lib/flickrs/images/
- name: KEY_STORE_PATH
value: /var/lib/flickrs/keys/
- name: RUST_LOG
value: debug
- name: ROCKET_DATABASES
value: '{imagesdb={url="/var/lib/flickrs/images.sqlite"}}'
volumeMounts:
- name: flickrs-storage
mountPath: /var/lib/flickrs
volumes:
- name: flickrs-storage
persistentVolumeClaim:
claimName: flickrs-storage
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: flickrs-storage
spec:
storageClassName: rbd-csi
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 10Gi
---
apiVersion: v1
kind: Service
metadata:
labels:
app: flickrs-api
name: flickrs-api
spec:
clusterIP: None
ports:
- port: 8000
name: web
selector:
app: flickrs-api
---
apiVersion: v1
kind: Service
metadata:
labels:
app: flickrs-static
name: flickrs-static
spec:
clusterIP: None
ports:
- port: 80
name: web
selector:
app: flickrs-static
# Virtual hosting: nginx configurations
---
apiVersion: v1
kind: Secret
metadata:
name: nginx-confd
type: Opaque
stringData:
flickrs.conf: |
types {
application/wasm wasm;
}
server {
server_name "flickrs.opencloudedge.be";
client_max_body_size 128M;
location /api {
proxy_redirect off;
proxy_pass_header Server;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Scheme $scheme;
proxy_set_header Host $http_host;
proxy_set_header X-NginX-Proxy true;
proxy_connect_timeout 5;
proxy_read_timeout 240;
proxy_intercept_errors on;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
resolver kube-dns.kube-system.svc.cluster.local valid=5s;
proxy_pass "http://flickrs-api.flickrs.svc.cluster.local:8000";
}
location / {
proxy_redirect off;
proxy_pass_header Server;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Scheme $scheme;
proxy_set_header Host $http_host;
proxy_set_header X-NginX-Proxy true;
proxy_connect_timeout 5;
proxy_read_timeout 240;
proxy_intercept_errors on;
resolver kube-dns.kube-system.svc.cluster.local valid=5s;
proxy_pass "http://flickrs-static.flickrs.svc.cluster.local:80";
}
}
---
# Virtual hosting: nginx
apiVersion: apps/v1
kind: Deployment
metadata:
name: flickrs-virtual-host
labels:
app: flickrs-virtual-host
spec:
replicas: 1
selector:
matchLabels:
app: flickrs-virtual-host
template:
metadata:
labels:
app: flickrs-virtual-host
spec:
containers:
- name: nginx
image: nginx:1.19.3
ports:
- containerPort: 80
name: flickrs-virtual
volumeMounts:
- name: nginx-confd
mountPath: "/etc/nginx/conf.d/"
readOnly: true
volumes:
- name: nginx-confd
secret:
secretName: nginx-confd
---
# Virtual hosting service
apiVersion: v1
kind: Service
metadata:
name: flickrs-virtual-host
labels:
app: flickrs-virtual-host
spec:
ports:
- port: 80
name: flickrs-virtual
clusterIP: None
selector:
app: flickrs-virtual-host
---
apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
name: ingress-flickrs
annotations:
nginx.ingress.kubernetes.io/rewrite-target: /
nginx.ingress.kubernetes.io/proxy-body-size: "20m"
nginx.org/client-max-body-size: "20m"
kubernetes.io/ingress.class: "nginx-public"
cert-manager.io/cluster-issuer: letsencrypt-cloudflare-production
nginx.ingress.kubernetes.io/ssl-redirect: "true"
spec:
rules:
- host: "flickrs.opencloudedge.be"
http:
paths:
- backend:
serviceName: flickrs-virtual-host
servicePort: 80
tls:
- hosts:
- 'flickrs.opencloudedge.be'
secretName: flickrs-tls