1. Startsida
  2. /
  3. Aktuellt
  4. /
  5. Installing WikiJS in OpenShift

WikiJS installation on OpenShift / OKD 4

Installing WikiJS in OpenShift / OKD 4 using Crunchy PostgreSQL

At Binero Group, we work every day on improving software delivery. The company has Open Source running through its veins and as such we try to give back to our clients and customers what we develop as much as possible.

In search for a Kubernetes based Wiki, we came across WikiJS, a modern Wiki that has support for markdown files and multiple storage backends like git and PostgreSQL.
The website provides information about installing on Kubernetes, but OpenShift has some additional security features that need to be taken into account when installing software on it.

If you prefer to go straight to the code and a short explanation, you can find the Git repo here with a reference to the author that started the effort, but please read along a bit more if you want to learn about the reasoning behind the setup.

First of all we like to use products that have a large install base and a high level of automation, so the efforts for maintaining the software are kept to a minimum : we like to focus as much as possible on effective use and profit from the capabilities Kubernetes has to this. For that reason, we choose to use the Crunchy Data Postgres Operator for installing PostgreSQL as a storage backend for WikiJS, it being the best supported one.

Then we show how to build a docker image that can be added to an internal repository as needed and used for a so called sideloading mode, meaning the files that the installation needs are packaged in the container, so no internet connection is needed to pull the files when doing the initialisation. The image is publicly available on Docker Hub and is currently manually updated - this may change in the future, we recommend to setup the build for yourself to have the latest version required.

Let’s get started!

WikiJS in Openshift / OKD 4

How to install WikiJS in Openshift 4 (using sideloading mode)

Prerequisites:

  • running Openshift or OKD cluster with persistant storage setup
    Examples apply to any OKD or OpenShift 4 cluster, screenshots are taken from OKD running on CRC ( now OpenShift local ) as described here
1. Create a project:
oc new-project wikijs

Alternatively, go to https://console-openshift-console.apps-crc.testing/k8s/cluster/projects and click Create Project and name it wikijs:

How to create a project in wiki.js in OpenShift

2. Install the Crunchy Postgres for Kubernetes operator from OperatorHub or following the instructions here:

https://access.crunchydata.com/documentation/postgres-operator/v5/quickstart/

Choose all namespaces if you want it to be useable in more than one, if not use the wikijs one that we created before

Installing the Crunchy Postgres for Kubernete operator wiki.js in OpenShift

3. Install the postgres DB as follows, making sure your oc command is using the right context. Change the values if needed - currently it's 20GB.
oc apply -f postgres.yaml
4. Now you should have a PostgresCluster CR under the tab under installed operators:

PostgresCluster CR wiki.js in OpenShift

You should be able to connect from the local machine with psql like so (make sure psql is installed):

PG_CLUSTER_PRIMARY_POD=$(oc get pod -n wikijs -o name -l postgres-operator.crunchydata.com/cluster=wikijs,postgres-operator.crunchydata.com/role=master)

kubectl -n wikijs port-forward "${PG_CLUSTER_PRIMARY_POD}" 5432:5432 &

PG_CLUSTER_USER_SECRET_NAME=wikijs-pguser-wikijs
PGPASSWORD=$(kubectl get secrets -n wikijs "${PG_CLUSTER_USER_SECRET_NAME}" -o go-template='{{.data.password | base64decode}}') PGUSER=$(kubectl get secrets -n wikijs "${PG_CLUSTER_USER_SECRET_NAME}" -o go-template='{{.data.user | base64decode}}') PGDATABASE=$(kubectl get secrets -n wikijs "${PG_CLUSTER_USER_SECRET_NAME}" -o go-template='{{.data.dbname | base64decode}}') psql -h localhost

You should get a shell that shows the connection is using TLS, which is the default with this operator.

5. For me it did not work to have WikiJS connect to PostgreSQL with SSL, I needed to add the CA cert as described in the docs:

(DB_SLL_CA - Database CA certificate content, as a single line string (without spaces or new lines), without the prefix and suffix lines. (optional, requires 2.3+))

This is stored in the pgo-root-cacert secret, run the script to get it in the right format:

./getPsqlRootCAString.sh

It will give something like:

MIIBgTCCASegAwIBAgIQFlUx8CFOhxtbNv8baQQh7jA
KBggqhkjOPQQDAzAfMR0wGwYDVQQDExRwb3N0Z3
Jlcy1vcGVyYXRvci1jYTAeFw0yMjExMjUxMjM1NDNaFw
0zMjExMjIxMzM1NDNaMB8xHTAbBgNVBAMTFHBvc3
RncmVzLW9wACBhdG9yLWNhMFkwEwNHKoZIzj0CA
QYIKoZIzj0DAQcDQgAElokygIJH/U06gVTTQRZB0B1
cdSV8bP/HWVJ7BYOhcuOUymQsPnKDg27DgQSa9z
VVLADHf24vuMg8Uo/NDfjaf6NFMEMwDgYDVR0PAQ
H/BAQDAgEGMBIGA1UdEwEB/wQIMAYBAf8CAQAw
HQYDVR0OBBYEFN/HmCEkp7HKceaU/QACugp4tu/
LMAoGCCqGSM49BAMDA0gAMEUCIQC/qZJx55pqz
B0QmSRL6UmhnSeUl85rf2+X3eods2miKgIgM3swV3
UuTMgdDm8scsW1aDwhkPpCkwOXbaM0mX2jDvM=

Add this to the deploymentConfig.yaml, snippet:

- name: DB_SSL_CA
value:
MIIBgTCCASegAwIBAgIQFlUx8CFOhxtbNv8baQQh7jA
KBggqhkjOPQQDAzAfMR0wGwYDVQQDExRwb3N0Z3
Jlcy1vcGVyYXRvci1jYTAeFw0yMjExMjUxMjM1NDNaFw
0zMjExMjIxMzM1NDNaMB8xHTAbBgNVBAMTFHBvc3
RncmVzLW9wACBhdG9yLWNhMFkwEwNHKoZIzj0CA
QYIKoZIzj0DAQcDQgAElokygIJH/U06gVTTQRZB0B1
cdSV8bP/HWVJ7BYOhcuOUymQsPnKDg27DgQSa9z
VVLADHf24vuMg8Uo/NDfjaf6NFMEMwDgYDVR0PAQ
H/BAQDAgEGMBIGA1UdEwEB/wQIMAYBAf8CAQAw
HQYDVR0OBBYEFN/HmCEkp7HKceaU/QACugp4tu/
LMAoGCCqGSM49BAMDA0gAMEUCIQC/qZJx55pqz
B0QmSRL6UmhnSeUl85rf2+X3eods2miKgIgM3swV3
UuTMgdDm8scsW1aDwhkPpCkwOXbaM0mX2jDvM=

Now we are ready to deploy it.

6. The deployment file contains a reference to the docker image the author of the mentioned reference made. As mentioned, this can be build from the Dockerfile which is included.

For convenience we can use that image, to user your own, build the image and tag it:
docker build -t yourusername/repository-name .

I used docker hub :

docker build -t vgerris/wikijs:2 .

then push it to your registry of choice and update the reference in the deployment file
more info : https://docs.docker.com/engine/reference/commandline/push/

docker push vgerris/wikijs:2

Now apply the deployment:

oc apply -f deploymentConfig.yaml
7. Now that the app is deployed we can add a service and a route te expose it. Update the route file with your server URL:
oc apply -f service.yaml
oc apply -f route.yaml

You should have the application running and exposed on the route now, you can finish setting it up.

Enjoy WikiJS!

Optional
If you have an existing collection of Markdown files (MD) it can be useful to add those to the wiki. More information on how to set it up when stored in git can be found here.
The files will be indexed and added to WikiJS and can be directly edited with the Markdown editor. As a bonus, WikiJS has a diagram plugin that makes it really easy to add draw.io based diagrams directly in the documents.

It's also quite easy to setup OpenID connect with for example Keycloak.
Under administration, go to authentication, add strategy and select Keycloak.
Create a client in Keycloak and fill in the required fields.
Disable the guest user if you do not want it to be public, see:
https://docs.requarks.io/groups ( Private Wiki)

 

Binero Group delivers OKD on top of Binero cloud and also a fully supported Red Hat OpenShift Container Platform as a hosted or fully managed solution, on Swedish datacenters, GDPR compliant.

Try out Binero cloud and contact us if you have any questions, we are happy to help!

Create account in Binero cloud

Share this article

relaterade artiklar

vill du veta mer?

Vi drivs av att hjälpa våra kunder till högre innovationskraft och kostnadseffektiv IT. Vill du också ta del av det senaste inom högpresterande molntjänster?