Skip to content

Commit

Permalink
Adjust examples for multi kc
Browse files Browse the repository at this point in the history
  • Loading branch information
johscheuer committed Nov 21, 2022
1 parent ee88e36 commit 3b4214e
Show file tree
Hide file tree
Showing 8 changed files with 56 additions and 71 deletions.
2 changes: 1 addition & 1 deletion config/tests/multi_dc/create.bash
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ DIR="${BASH_SOURCE%/*}"

. $DIR/functions.bash

# To test a multi-region FDB cluster setup we need to have 4 Kubernetes clusters
# To test a multi-region FDB cluster setup we need to have 3 Kubernetes clusters
cluster1=${CLUSTER1:-cluster1}
cluster2=${CLUSTER2:-cluster2}
cluster3=${CLUSTER3:-cluster3}
Expand Down
2 changes: 1 addition & 1 deletion config/tests/multi_dc/delete.bash
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

set -eu

# To test a multi-region FDB cluster setup we need to have 4 Kubernetes clusters
# To test a multi-region FDB cluster setup we need to have 3 Kubernetes clusters
cluster1=${CLUSTER1:-cluster1}
cluster2=${CLUSTER2:-cluster2}
cluster3=${CLUSTER3:-cluster3}
Expand Down
27 changes: 0 additions & 27 deletions config/tests/multi_kc/apply.bash

This file was deleted.

32 changes: 22 additions & 10 deletions config/tests/multi_kc/create.bash
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#! /bin/bash
#!/usr/bin/env bash

set -eu

# This directory provides an example of creating a cluster using the multi-KC
# replication topology.
Expand All @@ -15,14 +17,24 @@ DIR="${BASH_SOURCE%/*}"

. $DIR/functions.bash

applyFile $DIR/stage_1.yaml dc1 '""'
checkReconciliationLoop test-cluster-dc1
connectionString=$(getConnectionString test-cluster-dc1)
# To test a multi-region FDB cluster setup we need to have 3 Kubernetes clusters
cluster1=${CLUSTER1:-cluster1}
cluster2=${CLUSTER2:-cluster2}
cluster3=${CLUSTER3:-cluster3}

# For all the clusters we have to create tha according kubeconfig
kubeconfig1=${KUBECONFIG1:-"${cluster1}.kubeconfig"}
kubeconfig2=${KUBECONFIG2:-"${cluster2}.kubeconfig"}
kubeconfig3=${KUBECONFIG3:-"${cluster3}.kubeconfig"}

applyFile $DIR/stage_1.yaml dc1 '""' "${kubeconfig1}"
checkReconciliationLoop test-cluster-dc1 "${kubeconfig1}"
connectionString=$(getConnectionString test-cluster-dc1 "${kubeconfig1}")

applyFile $DIR/final.yaml dc1 $connectionString
applyFile $DIR/final.yaml dc2 $connectionString
applyFile $DIR/final.yaml dc3 $connectionString
applyFile $DIR/final.yaml dc1 $connectionString "${kubeconfig1}"
applyFile $DIR/final.yaml dc2 $connectionString "${kubeconfig2}"
applyFile $DIR/final.yaml dc3 $connectionString "${kubeconfig3}"

checkReconciliationLoop test-cluster-dc1
checkReconciliationLoop test-cluster-dc2
checkReconciliationLoop test-cluster-dc3
checkReconciliationLoop test-cluster-dc1 "${kubeconfig1}"
checkReconciliationLoop test-cluster-dc2 "${kubeconfig2}"
checkReconciliationLoop test-cluster-dc3 "${kubeconfig3}"
18 changes: 16 additions & 2 deletions config/tests/multi_kc/delete.bash
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
#! /bin/bash
#!/usr/bine/env bash

kubectl delete fdb -l cluster-group=test-cluster
set -eu

# To test a multi-region FDB cluster setup we need to have 3 Kubernetes clusters
cluster1=${CLUSTER1:-cluster1}
cluster2=${CLUSTER2:-cluster2}
cluster3=${CLUSTER3:-cluster3}

# For all the clusters we have to create tha according kubeconfig
kubeconfig1=${KUBECONFIG1:-"${cluster1}.kubeconfig"}
kubeconfig2=${KUBECONFIG2:-"${cluster2}.kubeconfig"}
kubeconfig3=${KUBECONFIG3:-"${cluster3}.kubeconfig"}

kubectl --kubeconfig "${kubeconfig1}" delete fdb -l cluster-group=test-cluster
kubectl --kubeconfig "${kubeconfig2}" delete fdb -l cluster-group=test-cluster
kubectl --kubeconfig "${kubeconfig3}" delete fdb -l cluster-group=test-cluster
8 changes: 4 additions & 4 deletions config/tests/multi_kc/final.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,22 @@ metadata:
cluster-group: test-cluster
name: test-cluster-$zone
spec:
version: 6.2.30
version: 7.1.25
faultDomain:
key: foundationdb.org/kubernetes-cluster
value: $zone
zoneIndex: $zoneIndex
zoneCount: 3
instanceIDPrefix: $zone
processGroupIDPrefix: $zone
processCounts:
stateless: -1
seedConnectionString: $connectionString
customParameters:
- "knob_disable_posix_kernel_aio=1"
databaseConfiguration:
redundancy_mode: "double"
processes:
general:
customParameters:
- "knob_disable_posix_kernel_aio=1"
volumeClaimTemplate:
spec:
resources:
Expand Down
30 changes: 8 additions & 22 deletions config/tests/multi_kc/functions.bash
Original file line number Diff line number Diff line change
@@ -1,42 +1,28 @@
function applyFile() {
path=$1
zone=$2
connectionString=$3
zoneIndex=${zone:2:1}

sed -e "s/\$zoneIndex/$zoneIndex/" $path | sed -e "s/\$zone/$zone/" | sed -e "s/\$connectionString/$connectionString/" | kubectl apply -f -
zone="${zone}" zoneIndex="${zone:2:1}" connectionString="${3}" envsubst < "${1}" | kubectl --kubeconfig "${4}" apply -f -
}

function checkReconciliation() {
clusterName=$1

generationsOutput=$(kubectl get fdb $clusterName -o jsonpath='{.metadata.generation} {.status.generations.reconciled}')
read -ra generations <<< $generationsOutput
if [[ ("${generations[1]}" != "") && ("${generations[0]}" == "${generations[1]}") ]]; then
generationsOutput=$(kubectl --kubeconfig "${2}" get fdb "${clusterName}" -o jsonpath='{.metadata.generation} {.status.generations.reconciled}')
read -ra generations <<< "${generationsOutput}"
if [[ ("${#generations[@]}" -ge 2) && ("${generations[0]}" == "${generations[1]}") ]]; then
return 1
else
echo "Latest generations for $clusterName: $generationsOutput"
return 0
fi
}


function getConnectionString() {
clusterName=$1

kubectl get fdb $clusterName -o jsonpath='{.status.connectionString}'
kubectl --kubeconfig "${2}" get fdb "${1}" -o jsonpath='{.status.connectionString}'
}


function checkReconciliationLoop() {
reconciled=0
name=$1
while [ $reconciled -ne 1 ] ; do
checkReconciliation $name
reconciled=$?
if [[ $reconciled -ne 1 ]]; then
echo "Waiting for reconcilliation"
sleep 5
fi
while checkReconciliation "${1}" "${2}"; do
echo "Waiting for reconciliation"
sleep 5
done
}
8 changes: 4 additions & 4 deletions config/tests/multi_kc/stage_1.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,22 @@ metadata:
cluster-group: test-cluster
name: test-cluster-$zone
spec:
version: 6.2.30
version: 7.1.25
faultDomain:
key: foundationdb.org/kubernetes-cluster
value: $zone
zoneIndex: $zoneIndex
zoneCount: 1
instanceIDPrefix: $zone
processGroupIDPrefix: $zone
processCounts:
stateless: -1
seedConnectionString: $connectionString
customParameters:
- "knob_disable_posix_kernel_aio=1"
databaseConfiguration:
redundancy_mode: "single"
processes:
general:
customParameters:
- "knob_disable_posix_kernel_aio=1"
volumeClaimTemplate:
spec:
resources:
Expand Down

0 comments on commit 3b4214e

Please sign in to comment.