-
Notifications
You must be signed in to change notification settings - Fork 13
/
aks-deploy.yaml
269 lines (263 loc) · 5.8 KB
/
aks-deploy.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
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
apiVersion: v1
kind: ServiceAccount
metadata:
name: kubectl-client
namespace: default
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: kubectl-client
rules:
- apiGroups:
- ""
resources:
- configmaps
verbs:
- '*'
- apiGroups:
- ""
resources:
- services
verbs:
- '*'
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: kubectl-client
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: kubectl-client
subjects:
- kind: ServiceAccount
name: kubectl-client
namespace: default
---
# PixelStreaming Config
apiVersion: v1
kind: ConfigMap
metadata:
name: pixel-streaming-config
data:
matchmaker.json: |
{
"HttpPort": "90",
"UseHTTPS": "false",
"MatchmakerPort": "9999",
"LogToFile": "true"
}
signallingserver.json: |
{
"UseFrontend": false,
"UseMatchmaker": true,
"UseHTTPS": false,
"UseAuthentication": false,
"LogToFile": true,
"LogVerbose": true,
"HomepageFile": "player.html",
"AdditionalRoutes": {},
"EnableWebserver": true,
"MatchmakerAddress": "matchmaker",
"MatchmakerPort": "9999",
"PublicIp": "",
"HttpPort": 80,
"HttpsPort": 443,
"StreamerPort": 8888,
"SFUPort": 8889,
"MaxPlayerCount": -1
}
---
# MatchMaker Service
apiVersion: v1
kind: Service
metadata:
name: matchmaker
labels:
app: matchmaker
spec:
ports:
- port: 90
targetPort: 90
name: port90
- port: 9999
targetPort: 9999
name: port9999
selector:
app: matchmaker
type: LoadBalancer
---
# SignallingServer Service
apiVersion: v1
kind: Service
metadata:
name: signallingserver
labels:
app: signallingserver
spec:
ports:
- port: 80
targetPort: 80
name: port80
- port: 8888
targetPort: 8888
name: port8888
selector:
app: signallingserver
type: LoadBalancer
---
# TURN Server Service
apiVersion: v1
kind: Service
metadata:
name: turnserver
labels:
app: turnserver
spec:
ports:
- port: 3478
targetPort: 3478
name: porttcp3478
protocol: TCP
selector:
app: turnserver
type: LoadBalancer
---
# Deploy MatchMaker
apiVersion: apps/v1
kind: Deployment
metadata:
name: matchmaker
labels:
app: matchmaker
spec:
replicas: 1
selector:
matchLabels:
app: matchmaker
template:
metadata:
labels:
app: matchmaker
spec:
containers:
- name: matchmaker
image: fancy.azurecr.io/matchmaker:4.27
ports:
- containerPort: 90
- containerPort: 9999
volumeMounts:
- name: pixel-streaming-config
mountPath: /config
volumes:
- name: pixel-streaming-config
configMap:
name: pixel-streaming-config
---
# Deploy SignallingServer
apiVersion: apps/v1
kind: Deployment
metadata:
name: signallingserver
labels:
app: signallingserver
spec:
replicas: 1
selector:
matchLabels:
app: signallingserver
template:
metadata:
labels:
app: signallingserver
spec:
serviceAccountName: kubectl-client
initContainers:
- name: init
image: "fancy.azurecr.io/kubectlclient"
command: ["sh"]
args:
- -c
- |
signallingLoadBalancerIP=""
while [ -z "$signallingLoadBalancerIP" ]; do
signallingLoadBalancerIP=$(kubectl get service signallingserver -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
sleep 5
done
echo "signallingLoadBalancerIP=$signallingLoadBalancerIP" > /tmp/ip.txt
turnLoadBalancerIP=""
while [ -z "$turnLoadBalancerIP" ]; do
turnLoadBalancerIP=$(kubectl get service turnserver -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
sleep 5
done
echo "turnLoadBalancerIP=$turnLoadBalancerIP" >> /tmp/ip.txt
# Delete the old configmap if it exists
kubectl delete configmap signallingserver-config-ips --ignore-not-found
kubectl create configmap signallingserver-config-ips --from-env-file=/tmp/ip.txt
sleep 10
containers:
- name: signallingserver
image: fancy.azurecr.io/signallingwebserver:4.27
envFrom:
- configMapRef:
name: signallingserver-config-ips
args:
- --configFile=/config/signallingserver.json
- --peerConnectionOptions={"iceServers":[{"urls":["turn:$(turnLoadBalancerIP):3478"],"username":"usr","credential":"usr123"}]}
- --PublicIp=$(signallingLoadBalancerIP)
ports:
- containerPort: 80
- containerPort: 8888
volumeMounts:
- name: pixel-streaming-config
mountPath: /config
- name: game
image: fancy.azurecr.io/game:4.27
env:
- name: SIGNALSERVER_URL
value: ws://signallingserver:8888
volumes:
- name: pixel-streaming-config
configMap:
name: pixel-streaming-config
tolerations:
- key: "sku"
operator: "Equal"
value: "gpu"
effect: "NoSchedule"
---
# Kubernetes TURN Server DaemonSet
apiVersion: apps/v1
kind: DaemonSet
metadata:
name: turnserver
labels:
app: turnserver
spec:
selector:
matchLabels:
app: turnserver
template:
metadata:
labels:
app: turnserver
spec:
nodeSelector:
"agentpool": "turnp"
tolerations:
- key: "sku"
operator: "Equal"
value: "turn"
effect: "NoSchedule"
hostNetwork: true
containers:
- name: turnserver
image: fancy.azurecr.io/turn:latest
ports:
- containerPort: 3478
protocol: UDP
name: udp
- containerPort: 3478
protocol: TCP
name: tcp