Skip to content

Commit ff924de

Browse files
authored
Update the three_data_hall docs for the three data hall with unified image (#2188)
* Update the three_data_hall docs for the three data hall with unified image * Ensure that the unified image will always be used for 3dh testing
1 parent f68e301 commit ff924de

File tree

14 files changed

+476
-195
lines changed

14 files changed

+476
-195
lines changed

config/tests/three_data_hall/Readme.md

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,30 @@
22

33
This example requires that your Kubernetes cluster has nodes which are labeled with `topology.kubernetes.io/zone`.
44
The example requires at least 3 unique zones, those can be faked for testing, by adding the labels to a node.
5-
If you want to use cloud provider specific zone label values you can set the `AZ1`, `AZ2` and `AZ3` environment variables.
6-
You can also set the namespace with the `NAMESPACE` environment variable to deploy this setup in a specific namespace.
5+
6+
## Create the RBAC settings
7+
8+
This example uses the unified image to read data from the Kubernetes API and therefore we have to
9+
create the according RBAC setup. If you use a different namespace than the default namespace, you have
10+
to adjust the `fdb-kubernetes` `ClusterRoleBinding` to point to the right `ServiceAccount`.
11+
12+
```bash
13+
kubectl apply -f ./config/tests/three_data_hall/unified_image_role.yaml
14+
```
15+
716

817
## Create the Three-Data-Hall cluster
918

10-
This will bring up a FDB cluster using the three-data-hall redundancy mode.
19+
This will bring up the three data hall cluster managed by a single `FoundationDBCluster` resource:
1120

1221
```bash
13-
./create.bash
22+
kubectl apply -f ./config/tests/three_data_hall/cluster.yaml
1423
```
1524

1625
## Delete
1726

1827
This will remove all created resources:
1928

2029
```bash
21-
./delete.bash
30+
kubectl delete -f ./config/tests/three_data_hall/cluster.yaml
2231
```
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
apiVersion: apps.foundationdb.org/v1beta2
2+
kind: FoundationDBCluster
3+
metadata:
4+
labels:
5+
cluster-group: test-cluster
6+
name: test-cluster
7+
spec:
8+
# The unified image supports to make use of node labels, so setting up a three data hall cluster
9+
# is easier with the unified image.
10+
imageType: unified
11+
version: 7.1.63
12+
faultDomain:
13+
key: kubernetes.io/hostname
14+
processCounts:
15+
stateless: -1
16+
databaseConfiguration:
17+
# Ensure that enough coordinators are available. The processes will be spread across the different zones.
18+
logs: 9
19+
storage: 9
20+
redundancy_mode: "three_data_hall"
21+
processes:
22+
general:
23+
customParameters:
24+
- "knob_disable_posix_kernel_aio=1"
25+
- "locality_data_hall=$NODE_LABEL_TOPOLOGY_KUBERNETES_IO_ZONE"
26+
volumeClaimTemplate:
27+
spec:
28+
resources:
29+
requests:
30+
storage: "16G"
31+
podTemplate:
32+
spec:
33+
securityContext:
34+
runAsUser: 4059
35+
runAsGroup: 4059
36+
fsGroup: 4059
37+
serviceAccount: fdb-kubernetes
38+
# Make sure that the pods are spread equally across the different availability zones.
39+
topologySpreadConstraints:
40+
- maxSkew: 1
41+
topologyKey: topology.kubernetes.io/zone
42+
whenUnsatisfiable: DoNotSchedule
43+
labelSelector:
44+
matchLabels:
45+
foundationdb.org/fdb-cluster-name: test-cluster
46+
containers:
47+
- name: foundationdb
48+
env:
49+
# This feature allows the fdb-kubernetes-monitor to read the labels from the node where
50+
# it is running.
51+
- name: ENABLE_NODE_WATCH
52+
value: "true"
53+
resources:
54+
requests:
55+
cpu: 250m
56+
memory: 128Mi

config/tests/three_data_hall/create.bash

Lines changed: 0 additions & 35 deletions
This file was deleted.

config/tests/three_data_hall/delete.bash

Lines changed: 0 additions & 5 deletions
This file was deleted.

config/tests/three_data_hall/final.yaml

Lines changed: 0 additions & 41 deletions
This file was deleted.

config/tests/three_data_hall/functions.bash

Lines changed: 0 additions & 29 deletions
This file was deleted.

config/tests/three_data_hall/stage_1.yaml

Lines changed: 0 additions & 41 deletions
This file was deleted.
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
apiVersion: v1
2+
kind: ServiceAccount
3+
metadata:
4+
name: fdb-kubernetes
5+
---
6+
apiVersion: rbac.authorization.k8s.io/v1
7+
kind: Role
8+
metadata:
9+
name: fdb-kubernetes
10+
rules:
11+
- apiGroups:
12+
- ""
13+
resources:
14+
- "pods"
15+
verbs:
16+
- "get"
17+
- "watch"
18+
- "update"
19+
- "patch"
20+
- "list"
21+
---
22+
apiVersion: rbac.authorization.k8s.io/v1
23+
kind: RoleBinding
24+
metadata:
25+
name: fdb-kubernetes
26+
roleRef:
27+
apiGroup: rbac.authorization.k8s.io
28+
kind: Role
29+
name: fdb-kubernetes
30+
subjects:
31+
- kind: ServiceAccount
32+
name: fdb-kubernetes
33+
---
34+
apiVersion: rbac.authorization.k8s.io/v1
35+
kind: ClusterRole
36+
metadata:
37+
name: fdb-kubernetes
38+
rules:
39+
- apiGroups:
40+
- ""
41+
resources:
42+
- "nodes"
43+
verbs:
44+
- "get"
45+
- "watch"
46+
- "list"
47+
---
48+
apiVersion: rbac.authorization.k8s.io/v1
49+
kind: ClusterRoleBinding
50+
metadata:
51+
name: fdb-kubernetes
52+
roleRef:
53+
apiGroup: rbac.authorization.k8s.io
54+
kind: ClusterRole
55+
name: fdb-kubernetes
56+
subjects:
57+
- kind: ServiceAccount
58+
name: fdb-kubernetes

config/tests/unified_image/images.yaml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
11
- op: add
22
path: "/spec/imageType"
33
value: unified
4-
- op: add
5-
path: "/spec/mainContainer"
6-
value:
7-
imageConfigs:
8-
- tagSuffix: "-local"
94
- op: remove
105
path: "/spec/processes/general/podTemplate/spec/initContainers/0"
116
- op: add

controllers/generate_initial_cluster_file.go

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,19 @@ func (g generateInitialClusterFile) reconcile(ctx context.Context, r *Foundation
129129
processLocality = append(processLocality, currentLocality)
130130
}
131131

132+
limits := locality.GetHardLimits(cluster)
133+
// Only for the three data hall mode we allow a less restrictive selection of the initial coordinators.
134+
// The reason for this is that we don't know the data_hall locality until the fdbserver processes are running
135+
// as they will report the data_hall locality. So this is a workaround to allow an easy bring up of a three_data_hall
136+
// cluster with the unified image. Once the processes are reporting and the cluster is configured, the operator
137+
// will choose 9 coordinators spread across the 3 data halls.
138+
if cluster.Spec.DatabaseConfiguration.RedundancyMode == fdbv1beta2.RedundancyModeThreeDataHall {
139+
count = 3
140+
delete(limits, fdbv1beta2.FDBLocalityDataHallKey)
141+
}
142+
132143
coordinators, err := locality.ChooseDistributedProcesses(cluster, processLocality, count, locality.ProcessSelectionConstraint{
133-
HardLimits: locality.GetHardLimits(cluster),
144+
HardLimits: limits,
134145
})
135146
if err != nil {
136147
return &requeue{curError: err}

0 commit comments

Comments
 (0)