-
Notifications
You must be signed in to change notification settings - Fork 0
/
addc.yaml
668 lines (668 loc) · 16.2 KB
/
addc.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
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
---
apiVersion: v1
kind: Namespace
metadata:
name: samba-ad-server
labels:
name: samba-ad-server
---
apiVersion: v1
kind: ConfigMap
metadata:
name: container-json
namespace: samba-ad-server
data:
# https://github.com/samba-in-kubernetes/sambacc/blob/master/examples/addc_ou.json
# https://github.com/samba-in-kubernetes/sambacc/blob/master/sambacc/schema/conf-v0.schema.json
# https://www.samba.org/samba/docs/current/man-html/smb.conf.5.html
container.json: |
{
"samba-container-config": "v0",
"configs": {
"dc-0": {
"instance_features": ["addc"],
"domain_settings": "sink",
"globals": ["sink"],
"instance_name": "dc-0"
},
"dc-1": {
"instance_features": ["addc"],
"domain_settings": "sink",
"globals": ["sink"],
"instance_name": "dc-1"
}
},
"globals": {
"sink": {
"options": {
"dns forwarder": "169.254.25.10",
"interfaces": "eth0",
"rpc server dynamic port range": "49152-49165"
}
}
},
"domain_settings": {
"sink": {
"realm": "DOMAIN1.SINK.TEST",
"short_domain": "DOMAIN1",
"admin_password": "Passw0rd"
}
},
"organizational_units": {
"sink": [
{"name": "employees"}
]
},
"domain_groups": {
"sink": [
{"name": "supervisors"},
{
"name": "employees",
"ou": "employees"
},
{"name": "characters"},
{"name": "bulk"}
]
},
"domain_users": {
"sink": [
{
"name": "bwayne",
"password": "1115Rose.",
"given_name": "Bruce",
"surname": "Wayne",
"member_of": ["supervisors", "characters", "employees"],
"ou": "employees"
},
{
"name": "ckent",
"password": "1115Rose.",
"given_name": "Clark",
"surname": "Kent",
"member_of": ["characters", "employees"],
"ou": "employees"
},
{
"name": "bbanner",
"password": "1115Rose.",
"given_name": "Bruce",
"surname": "Banner",
"member_of": ["characters", "employees"],
"ou": "employees"
},
{
"name": "pparker",
"password": "1115Rose.",
"given_name": "Peter",
"surname": "Parker",
"member_of": ["characters", "employees"],
"ou": "employees"
},
{
"name": "user0",
"password": "1115Rose.",
"given_name": "George0",
"surname": "Hue-Sir",
"member_of": ["bulk"]
},
{
"name": "user1",
"password": "1115Rose.",
"given_name": "George1",
"surname": "Hue-Sir",
"member_of": ["bulk"]
},
{
"name": "user2",
"password": "1115Rose.",
"given_name": "George2",
"surname": "Hue-Sir",
"member_of": ["bulk"]
},
{
"name": "user3",
"password": "1115Rose.",
"given_name": "George3",
"surname": "Hue-Sir",
"member_of": ["bulk"]
},
{
"name": "user4",
"password": "1115Rose.",
"given_name": "George4",
"surname": "Hue-Sir",
"member_of": ["bulk"]
},
{
"name": "user5",
"password": "1115Rose.",
"given_name": "George5",
"surname": "Hue-Sir",
"member_of": ["bulk"]
},
{
"name": "user6",
"password": "1115Rose.",
"given_name": "George6",
"surname": "Hue-Sir",
"member_of": ["bulk"]
},
{
"name": "user7",
"password": "1115Rose.",
"given_name": "George7",
"surname": "Hue-Sir",
"member_of": ["bulk"]
},
{
"name": "user8",
"password": "1115Rose.",
"given_name": "George8",
"surname": "Hue-Sir",
"member_of": ["bulk"]
},
{
"name": "user9",
"password": "1115Rose.",
"given_name": "George9",
"surname": "Hue-Sir",
"member_of": ["bulk"]
}
]
}
}
---
apiVersion: metallb.io/v1beta1
kind: IPAddressPool
metadata:
name: dc-0
namespace: metallb-system
spec:
addresses:
- 192.168.3.40/32
autoAssign: false
---
apiVersion: metallb.io/v1beta1
kind: IPAddressPool
metadata:
name: dc-1
namespace: metallb-system
spec:
addresses:
- 192.168.3.41/32
autoAssign: false
---
apiVersion: metallb.io/v1beta1
kind: L2Advertisement
metadata:
name: l2-dc
namespace: metallb-system
spec:
ipAddressPools:
- dc-0
- dc-1
# interfaces:
# - ens192
---
apiVersion: v1
kind: Service
metadata:
name: svc-dc-0
namespace: samba-ad-server
annotations:
metallb.universe.tf/address-pool: dc-0
labels:
app: samba-ad-server
spec:
type: LoadBalancer
selector:
statefulset.kubernetes.io/pod-name: dc-0
ports:
# https://www.iana.org/assignments/service-names-port-numbers/service-names-port-numbers.txt
# https://wiki.samba.org/index.php/Samba_AD_DC_Port_Usage
# https://learn.microsoft.com/en-us/troubleshoot/windows-server/identity/config-firewall-for-ad-domains-and-trusts
- port: 53
targetPort: 53
name: domain
- port: 53
targetPort: 53
name: domain-udp
protocol: UDP
- port: 88
targetPort: 88
name: kerberos
- port: 88
targetPort: 88
name: kerberos-udp
protocol: UDP
- port: 123
targetPort: 123
name: ntp-udp
protocol: UDP
- port: 135
targetPort: 135
name: epmap
- port: 137
targetPort: 137
name: netbios-ns-udp
protocol: UDP
- port: 138
targetPort: 138
name: netbios-dgm-udp
protocol: UDP
- port: 139
targetPort: 139
name: netbios-ssn
- port: 389
targetPort: 389
name: ldap
- port: 389
targetPort: 389
name: ldap-udp
protocol: UDP
- port: 445
targetPort: 445
name: microsoft-ds
- port: 464
targetPort: 464
name: kpasswd
- port: 464
targetPort: 464
name: kpasswd-udp
protocol: UDP
- port: 636
targetPort: 636
name: ldaps
- port: 3268
targetPort: 3268
name: msft-gc
- port: 3269
targetPort: 3269
name: msft-gc-ssl
- port: 49152
targetPort: 49152
name: rpc-49152
- port: 49153
targetPort: 49153
name: rpc-49153
- port: 49154
targetPort: 49154
name: rpc-49154
- port: 49155
targetPort: 49155
name: rpc-49155
- port: 49156
targetPort: 49156
name: rpc-49156
- port: 49157
targetPort: 49157
name: rpc-49157
- port: 49158
targetPort: 49158
name: rpc-49158
- port: 49159
targetPort: 49159
name: rpc-49159
- port: 49160
targetPort: 49160
name: rpc-49160
- port: 49161
targetPort: 49161
name: rpc-49161
- port: 49162
targetPort: 49162
name: rpc-49162
- port: 49163
targetPort: 49163
name: rpc-49163
- port: 49164
targetPort: 49164
name: rpc-49164
- port: 49165
targetPort: 49165
name: rpc-49165
---
apiVersion: v1
kind: Service
metadata:
name: svc-dc-1
namespace: samba-ad-server
annotations:
metallb.universe.tf/address-pool: dc-1
labels:
app: samba-ad-server
spec:
type: LoadBalancer
selector:
statefulset.kubernetes.io/pod-name: dc-1
ports:
# https://www.iana.org/assignments/service-names-port-numbers/service-names-port-numbers.txt
# https://wiki.samba.org/index.php/Samba_AD_DC_Port_Usage
# https://learn.microsoft.com/en-us/troubleshoot/windows-server/identity/config-firewall-for-ad-domains-and-trusts
- port: 53
targetPort: 53
name: domain
- port: 53
targetPort: 53
name: domain-udp
protocol: UDP
- port: 88
targetPort: 88
name: kerberos
- port: 88
targetPort: 88
name: kerberos-udp
protocol: UDP
- port: 123
targetPort: 123
name: ntp-udp
protocol: UDP
- port: 135
targetPort: 135
name: epmap
- port: 137
targetPort: 137
name: netbios-ns-udp
protocol: UDP
- port: 138
targetPort: 138
name: netbios-dgm-udp
protocol: UDP
- port: 139
targetPort: 139
name: netbios-ssn
- port: 389
targetPort: 389
name: ldap
- port: 389
targetPort: 389
name: ldap-udp
protocol: UDP
- port: 445
targetPort: 445
name: microsoft-ds
- port: 464
targetPort: 464
name: kpasswd
- port: 464
targetPort: 464
name: kpasswd-udp
protocol: UDP
- port: 636
targetPort: 636
name: ldaps
- port: 3268
targetPort: 3268
name: msft-gc
- port: 3269
targetPort: 3269
name: msft-gc-ssl
- port: 49152
targetPort: 49152
name: rpc-49152
- port: 49153
targetPort: 49153
name: rpc-49153
- port: 49154
targetPort: 49154
name: rpc-49154
- port: 49155
targetPort: 49155
name: rpc-49155
- port: 49156
targetPort: 49156
name: rpc-49156
- port: 49157
targetPort: 49157
name: rpc-49157
- port: 49158
targetPort: 49158
name: rpc-49158
- port: 49159
targetPort: 49159
name: rpc-49159
- port: 49160
targetPort: 49160
name: rpc-49160
- port: 49161
targetPort: 49161
name: rpc-49161
- port: 49162
targetPort: 49162
name: rpc-49162
- port: 49163
targetPort: 49163
name: rpc-49163
- port: 49164
targetPort: 49164
name: rpc-49164
- port: 49165
targetPort: 49165
name: rpc-49165
---
apiVersion: v1
kind: Service
metadata:
name: svc-dns-pool
namespace: samba-ad-server
labels:
app: samba-ad-server
spec:
type: ClusterIP
clusterIP: 10.233.0.10
selector:
app: samba-ad-server
ports:
- port: 53
targetPort: 53
name: domain
- port: 53
targetPort: 53
name: domain-udp
protocol: UDP
---
# https://github.com/samba-in-kubernetes/samba-operator/blob/master/tests/files/samba-ad-server-deployment.yml
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: dc
namespace: samba-ad-server
labels:
app: samba-ad-server
spec:
serviceName: samba-ad-server
replicas: 2
selector:
matchLabels:
app: samba-ad-server
template:
metadata:
labels:
app: samba-ad-server
spec:
containers:
- name: samba-ad-server
# https://quay.io/repository/samba.org/samba-ad-server?tab=tags
image: quay.io/samba.org/samba-ad-server:v0.5
# imagePullPolicy: Always
env:
- name: SAMBACC_CONFIG
value: /etc/samba-container/container.json
- name: SAMBA_CONTAINER_ID
valueFrom:
fieldRef:
fieldPath: metadata.name
- name: POD_INDEX
valueFrom:
fieldRef:
fieldPath: metadata.labels['apps.kubernetes.io/pod-index']
- name: POD_IP
valueFrom:
fieldRef:
fieldPath: status.podIP
command:
- bash
- -c
- |
if [ ! -S /var/lib/samba/private/ldap_priv/ldapi ]; then
until [ -S /var/lib/samba/private/ldap_priv/ldapi ]; do
sleep 1
done
EXTERNAL_IP=$(grep "$SAMBA_CONTAINER_ID" /etc/hosts | awk 'END{print $1}')
MY_DOMAIN=$(grep "$SAMBA_CONTAINER_ID" /etc/hosts | awk 'END{print $3}' | cut -f2- -d .)
sed -i -E '/^\[global]/,/^\[/{s/^(\s+)interfaces\s+=.*/\1interfaces = lo/}' /etc/samba/smb.conf
smbcontrol all reload-config
samba-tool dns delete localhost "$MY_DOMAIN" @ A "$POD_IP" -U administrator -P
samba-tool dns delete localhost "$MY_DOMAIN" "$SAMBA_CONTAINER_ID" A "$POD_IP" -U administrator -P
samba_dnsupdate --verbose --current-ip="$EXTERNAL_IP" --use-samba-tool --rpc-server-ip=127.0.0.1 --option=interfaces=lo
fi &
if [ "$POD_INDEX" -eq 0 ]; then
samba-dc-container run --setup=provision --setup=populate
else
samba-dc-container run --setup=wait-domain --setup=join
fi
resources:
limits:
memory: 4Gi
cpu: 2
requests:
memory: 1Gi
cpu: 500m
securityContext:
capabilities:
add:
- SYS_ADMIN
readinessProbe:
exec:
command:
- bash
- -c
- nslookup $SAMBA_CONTAINER_ID localhost
initialDelaySeconds: 5
periodSeconds: 2
timeoutSeconds: 1
ports:
# https://www.iana.org/assignments/service-names-port-numbers/service-names-port-numbers.txt
# https://wiki.samba.org/index.php/Samba_AD_DC_Port_Usage
# https://learn.microsoft.com/en-us/troubleshoot/windows-server/identity/config-firewall-for-ad-domains-and-trusts
- containerPort: 53
name: domain
- containerPort: 53
name: domain-udp
protocol: UDP
- containerPort: 88
name: kerberos
- containerPort: 88
name: kerberos-udp
protocol: UDP
- containerPort: 123
name: ntp-udp
protocol: UDP
- containerPort: 135
name: epmap
- containerPort: 137
name: netbios-ns-udp
protocol: UDP
- containerPort: 138
name: netbios-dgm-udp
protocol: UDP
- containerPort: 139
name: netbios-ssn
- containerPort: 389
name: ldap
- containerPort: 389
name: ldap-udp
protocol: UDP
- containerPort: 445
name: microsoft-ds
- containerPort: 464
name: kpasswd
- containerPort: 464
name: kpasswd-udp
protocol: UDP
- containerPort: 636
name: ldaps
- containerPort: 3268
name: msft-gc
- containerPort: 3269
name: msft-gc-ssl
- containerPort: 49152
name: rpc-49152
- containerPort: 49153
name: rpc-49153
- containerPort: 49154
name: rpc-49154
- containerPort: 49155
name: rpc-49155
- containerPort: 49156
name: rpc-49156
- containerPort: 49157
name: rpc-49157
- containerPort: 49158
name: rpc-49158
- containerPort: 49159
name: rpc-49159
- containerPort: 49160
name: rpc-49160
- containerPort: 49161
name: rpc-49161
- containerPort: 49162
name: rpc-49162
- containerPort: 49163
name: rpc-49163
- containerPort: 49164
name: rpc-49164
- containerPort: 49165
name: rpc-49165
volumeMounts:
- name: container-json
mountPath: /etc/samba-container/container.json
subPath: container.json
- name: var-lib-samba
mountPath: /var/lib/samba
- name: etc-samba
mountPath: /etc/samba
volumes:
- name: container-json
configMap:
name: container-json
- name: var-lib-samba
persistentVolumeClaim:
claimName: var-lib-samba
- name: etc-samba
persistentVolumeClaim:
claimName: etc-samba
hostAliases:
- ip: 192.168.3.40
hostnames:
- dc-0
- dc-0.domain1.sink.test
- ip: 192.168.3.41
hostnames:
- dc-1
- dc-1.domain1.sink.test
dnsConfig:
nameservers:
- 10.233.0.10
searches:
- domain1.sink.test
dnsPolicy: None
volumeClaimTemplates:
- metadata:
name: var-lib-samba
spec:
storageClassName: rook-ceph-block
resources:
requests:
storage: 1Gi
accessModes:
- ReadWriteOnce
- metadata:
name: etc-samba
spec:
storageClassName: rook-ceph-block
resources:
requests:
storage: 1Gi
accessModes:
- ReadWriteOnce