-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathingress.yaml
More file actions
246 lines (240 loc) · 6.82 KB
/
Copy pathingress.yaml
File metadata and controls
246 lines (240 loc) · 6.82 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
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
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: vision-week-ingress
namespace: vision-week
labels:
app: vision-week-virtual-exploration
annotations:
kubernetes.io/ingress.class: "nginx"
nginx.ingress.kubernetes.io/ssl-redirect: "true"
nginx.ingress.kubernetes.io/force-ssl-redirect: "true"
nginx.ingress.kubernetes.io/proxy-body-size: "10m"
nginx.ingress.kubernetes.io/proxy-connect-timeout: "60"
nginx.ingress.kubernetes.io/proxy-send-timeout: "60"
nginx.ingress.kubernetes.io/proxy-read-timeout: "60"
nginx.ingress.kubernetes.io/rate-limit: "100"
nginx.ingress.kubernetes.io/rate-limit-window: "1m"
nginx.ingress.kubernetes.io/enable-cors: "true"
nginx.ingress.kubernetes.io/cors-allow-origin: "*"
nginx.ingress.kubernetes.io/cors-allow-methods: "GET, POST, PUT, DELETE, OPTIONS"
nginx.ingress.kubernetes.io/cors-allow-headers: "Authorization, Content-Type, X-Requested-With"
nginx.ingress.kubernetes.io/cors-max-age: "86400"
cert-manager.io/cluster-issuer: "letsencrypt-prod"
nginx.ingress.kubernetes.io/configuration-snippet: |
add_header X-Frame-Options "SAMEORIGIN" always;
add_header X-Content-Type-Options "nosniff" always;
add_header X-XSS-Protection "1; mode=block" always;
add_header Referrer-Policy "strict-origin-when-cross-origin" always;
add_header Content-Security-Policy "default-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval'; style-src 'self' 'unsafe-inline'; img-src 'self' data: https:; font-src 'self' data:; connect-src 'self'; media-src 'self'; object-src 'none'; child-src 'self'; frame-ancestors 'self'; form-action 'self'; base-uri 'self';" always;
spec:
tls:
- hosts:
- vision-week.example.com
- api.vision-week.example.com
- ws.vision-week.example.com
secretName: vision-week-tls
rules:
# Main application
- host: vision-week.example.com
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: vision-week-app-service
port:
number: 80
# API subdomain
- host: api.vision-week.example.com
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: vision-week-app-service
port:
number: 80
# WebSocket subdomain
- host: ws.vision-week.example.com
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: vision-week-websocket-service
port:
number: 8080
---
# WebSocket Service
apiVersion: v1
kind: Service
metadata:
name: vision-week-websocket-service
namespace: vision-week
labels:
app: vision-week-virtual-exploration
component: websocket
spec:
type: ClusterIP
ports:
- name: websocket
port: 8080
targetPort: websocket
protocol: TCP
selector:
app: vision-week-virtual-exploration
component: websocket
---
# WebSocket Deployment
apiVersion: apps/v1
kind: Deployment
metadata:
name: vision-week-websocket
namespace: vision-week
labels:
app: vision-week-virtual-exploration
component: websocket
spec:
replicas: 2
strategy:
type: RollingUpdate
rollingUpdate:
maxSurge: 1
maxUnavailable: 0
selector:
matchLabels:
app: vision-week-virtual-exploration
component: websocket
template:
metadata:
labels:
app: vision-week-virtual-exploration
component: websocket
spec:
containers:
- name: websocket
image: vision-week/app:latest
imagePullPolicy: Always
command: ["php", "/var/www/html/src/WebSocket/server.php"]
ports:
- name: websocket
containerPort: 8080
protocol: TCP
env:
- name: APP_ENV
valueFrom:
configMapKeyRef:
name: vision-week-config
key: APP_ENV
- name: WEBSOCKET_HOST
valueFrom:
configMapKeyRef:
name: vision-week-config
key: WEBSOCKET_HOST
- name: WEBSOCKET_PORT
valueFrom:
configMapKeyRef:
name: vision-week-config
key: WEBSOCKET_PORT
- name: REDIS_HOST
valueFrom:
configMapKeyRef:
name: vision-week-config
key: REDIS_HOST
- name: REDIS_PORT
valueFrom:
configMapKeyRef:
name: vision-week-config
key: REDIS_PORT
- name: REDIS_PASSWORD
valueFrom:
secretKeyRef:
name: redis-secrets
key: REDIS_PASSWORD
resources:
requests:
memory: "128Mi"
cpu: "100m"
limits:
memory: "256Mi"
cpu: "200m"
livenessProbe:
tcpSocket:
port: websocket
initialDelaySeconds: 30
periodSeconds: 10
timeoutSeconds: 5
failureThreshold: 3
readinessProbe:
tcpSocket:
port: websocket
initialDelaySeconds: 5
periodSeconds: 5
timeoutSeconds: 3
failureThreshold: 3
---
# Network Policy for security
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: vision-week-network-policy
namespace: vision-week
labels:
app: vision-week-virtual-exploration
spec:
podSelector:
matchLabels:
app: vision-week-virtual-exploration
policyTypes:
- Ingress
- Egress
ingress:
# Allow ingress from nginx-ingress
- from:
- namespaceSelector:
matchLabels:
name: ingress-nginx
ports:
- protocol: TCP
port: 80
- protocol: TCP
port: 8080
# Allow internal communication
- from:
- podSelector:
matchLabels:
app: vision-week-virtual-exploration
ports:
- protocol: TCP
port: 80
- protocol: TCP
port: 5432
- protocol: TCP
port: 6379
- protocol: TCP
port: 8080
egress:
# Allow DNS resolution
- to: []
ports:
- protocol: UDP
port: 53
# Allow HTTPS outbound (for external APIs)
- to: []
ports:
- protocol: TCP
port: 443
# Allow internal communication
- to:
- podSelector:
matchLabels:
app: vision-week-virtual-exploration
ports:
- protocol: TCP
port: 5432
- protocol: TCP
port: 6379