2022-06-16 02:41:01 +08:00
# FoundationDB Kubernetes monitor
2021-08-22 16:28:09 +08:00
This package provides a launcher program for running FoundationDB in Kubernetes.
2022-06-16 02:41:01 +08:00
## Testing
2021-08-22 16:28:09 +08:00
To test this, run the following commands from the root of the FoundationDB
repository:
2021-09-22 03:12:43 +08:00
```bash
2022-07-04 22:25:25 +08:00
mkdir -p website
2022-06-16 02:41:01 +08:00
docker build -t foundationdb/foundationdb-kubernetes:7.1.5-local --target fdb-kubernetes-monitor --build-arg FDB_VERSION=7.1.5 --build-arg FDB_LIBRARY_VERSIONS="7.1.5 6.3.24 6.2.30" -f packaging/docker/Dockerfile .
docker build -t foundationdb/foundationdb-kubernetes:7.1.6-local --target fdb-kubernetes-monitor --build-arg FDB_VERSION=7.1.6 --build-arg FDB_LIBRARY_VERSIONS="7.1.6 6.3.24 6.2.30" -f packaging/docker/Dockerfile .
2021-09-22 03:12:43 +08:00
kubectl apply -f packaging/docker/kubernetes/test_config.yaml
# Wait for the pods to become ready
2022-06-16 02:41:01 +08:00
kubectl rollout status sts/fdb-kubernetes-example
2021-09-22 03:12:43 +08:00
ips=$(kubectl get pod -l app=fdb-kubernetes-example -o json | jq -j '[[.items|.[]|select(.status.podIP!="")]|limit(3;.[])|.status.podIP+":4501"]|join(",")')
2021-11-13 03:58:38 +08:00
sed -e "s/fdb.cluster: \"\"/fdb.cluster: \"test:test@$ips\"/" -e "s/\"runProcesses\": false/\"runProcesses\": true/" packaging/docker/kubernetes/test_config.yaml | kubectl apply -f -
2022-06-16 02:41:01 +08:00
kubectl annotate pod -l app=fdb-kubernetes-example foundationdb.org/outdated-config-map-seen=$(date +%s) --overwrite
2021-09-22 03:12:43 +08:00
# Watch the logs for the fdb-kubernetes-example pods to confirm that they have launched the fdbserver processes.
kubectl exec -it sts/fdb-kubernetes-example -- fdbcli --exec "configure new double ssd"
```
2022-06-16 02:41:01 +08:00
This will set up a cluster in your Kubernetes environment using a StatefulSet, to provide a simple subset of what the Kubernetes operator does to set up the cluster.
Note: This assumes that you are running Docker Desktop on your local machine, with Kubernetes configured through Docker Desktop.
2021-09-18 07:26:05 +08:00
2022-06-16 02:41:01 +08:00
You can then make changes to the data in the ConfigMap and update the `fdbserver` processes:
2021-08-22 16:28:09 +08:00
2021-09-22 03:12:43 +08:00
```bash
2021-11-13 03:58:38 +08:00
sed -e "s/fdb.cluster: \"\"/fdb.cluster: \"test:test@$ips\"/" -e "s/\"runProcesses\": false/\"runProcesses\": true/" packaging/docker/kubernetes/test_config.yaml | kubectl apply -f -
2021-08-23 12:19:10 +08:00
2021-09-22 03:12:43 +08:00
# You can apply an annotation to speed up the propagation of config
2022-06-16 02:41:01 +08:00
kubectl annotate pod -l app=fdb-kubernetes-example foundationdb.org/outdated-config-map-seen=$(date +%s) --overwrite
2021-08-23 12:19:10 +08:00
2021-09-22 03:12:43 +08:00
# Watch the logs for the fdb-kubernetes-example pods to confirm that they have reloaded their configuration, and then do a bounce.
kubectl exec -it sts/fdb-kubernetes-example -- fdbcli --exec "kill; kill all; status"
```
2021-08-22 16:28:09 +08:00
Once you are done, you can tear down the example with the following command:
2021-09-22 03:12:43 +08:00
```bash
2022-06-16 02:41:01 +08:00
kubectl delete -f packaging/docker/kubernetes/test_config.yaml
kubectl delete pvc -l app=fdb-kubernetes-example
2021-09-22 03:12:43 +08:00
```
2022-07-04 22:25:25 +08:00
### FDB Kubernetes operator
The following steps assume that you already have a [local development ](https://github.com/FoundationDB/fdb-kubernetes-operator#local-development ) setup for the fdb-kubernetes-operator.
```bash
mkdir -p website
# Change this version if you want to create a cluster with a different version
docker build -t foundationdb/foundationdb-kubernetes:7.1.11-local --target fdb-kubernetes-monitor --build-arg FDB_VERSION=7.1.11 --build-arg FDB_LIBRARY_VERSIONS="7.1.11 6.3.24 6.2.30" -f packaging/docker/Dockerfile .
```
Depending on the local Kubernetes setup you use you might have to push the newly build image to a local registry.
Now you should change to the directoy that contains the [fdb-kubernetes-operator ](https://github.com/FoundationDB/fdb-kubernetes-operator ) repository.
In the top directory run:
```bash
# Adjust the version for the cluster if it differs from the build image
vim ./config/tests/base/cluster.yaml
# Now you can create the cluster
kubectl apply -k ./config/tests/unified_image
```