========================== Syncthing Dokuwiki Example ========================== .. note:: This tutorial requires the usage of LoadBalancer to expose applications from within the cluster. If you are running a KIND cluster, please follow this guide to install metallb if you haven't already: https://kind.sigs.k8s.io/docs/user/loadbalancer/ In this example, we will demonstrate how Syncthing can be used to maintain a synchronized volume across several Dokuwiki application instances. First, create a namespace for the Dokuwiki application and launch the required resources: .. code-block:: bash kubectl create ns dokuwiki-east kubectl apply -f examples/dokuwiki/ -n dokuwiki-east Ensure that we can access the dokuwiki application by obtaining the external IP address: .. code-block:: console $ kubectl get service -n dokuwiki-east dokuwiki-service NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE dokuwiki-service LoadBalancer 10.96.231.229 172.18.255.200 5196:30113/TCP 16m Open your browser and navigate to the value in your ``EXTERNAL-IP`` field, in our case it is ``172.18.255.200:5196``. This should take you to the front-end for the Dokuwiki application. You'll be able to create new wiki pages here, as well as edit existing ones. Once opened, you should see a page like this: .. image:: images/dokuwiki-east-1.png :align: center :width: 100% :alt: Dokuwiki East Now let's populate our DokuWiki with its first page, and what better subject to talk about then the Syncthing data mover? Create a new page on the DokuWiki website with the following contents: .. code-block:: Syncthing is a data mover that allows you to synchronize your data across multiple devices. It's an awesome tool that you should try out if you haven't already. Now let's create a Syncthing-based ReplicationSource to synchronize the data within our DokuWiki PVC: .. code-block:: console $ kubectl apply -f examples/syncthing/replicationsource_empty.yaml -n dokuwiki-east replicationsource.volsync.backube/sync-dokuwiki created Let's retrieve our ReplicationSource's Syncthing information once it becomes available: .. code-block:: console $ kubectl get replicationsource -n dokuwiki-east sync-dokuwiki \ -o jsonpath='{.status.syncthing}' -w {"ID":"TMBYRB4-EIINYAW-ZFBX4LV-7FE37NT-BLQPSKB-P2BFIPW-QW6ST3C-PSU7UQD","address":"tcp://10.96.217.239:22000"} Once the above data becomes available, let's save the Syncthing ID and address as an environment variable in our shell so that we can reuse it later. .. code-block:: console export SYNCTHING_EAST_ID=$(kubectl get replicationsource -n dokuwiki-east sync-dokuwiki -o jsonpath='{.status.syncthing.ID}') export SYNCTHING_EAST_ADDRESS=$(kubectl get replicationsource -n dokuwiki-east sync-dokuwiki -o jsonpath='{.status.syncthing.address}') Now that ``dokuwiki-east`` is all configured, let's create two other namespaces with their own DokuWiki applications: ``dokuwiki-west`` and ``dokuwiki-central``. .. code-block:: console kubectl create ns dokuwiki-west kubectl create ns dokuwiki-central We'll launch a DokuWiki application in each namespace: .. code-block:: console kubectl apply -f examples/dokuwiki/ -n dokuwiki-west kubectl apply -f examples/dokuwiki/ -n dokuwiki-central These can now be accessed through their own respective external IP addresses: .. code-block:: console :caption: Obtaining the External IP for ``dokuwiki-west`` $ kubectl get service -n dokuwiki-west dokuwiki-service NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE dokuwiki-service LoadBalancer 10.96.142.135 172.18.255.202 5196:32364/TCP 114s .. code-block:: console :caption: Obtaining the External IP for ``dokuwiki-central`` $ kubectl get service -n dokuwiki-central dokuwiki-service NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE dokuwiki-service LoadBalancer 10.96.254.251 172.18.255.203 5196:31687/TCP 2m32s Go ahead and open both of these up in their own respective tabs. You should see empty pages for both ``dokuwiki-west`` and ``dokuwiki-central``. Let's change this by creating Syncthing-based ReplicationSources in each of these namespaces, and configuring them to use ``dokuwiki-east`` as their introducer node. Using the information that we obtained from the ReplicationSource in ``dokuwiki-east`` earlier, create a ReplicationSource with the following contents and apply it in each namespace: .. code-block:: bash :caption: Syncthing-based ReplicationSource using ``dokuwiki-east`` as an introducer for ns in dokuwiki-west dokuwiki-central; do cat <