Writefreely on Kubernetes

Finally!

It took some work, but Writefreely is finally running on my K3s cluster.

My starting point was with configurations in writefreely-docker which provided an excellent source of knowledge around building the docker container. Once built, I published the image to a local container repository for K3s to pull from.

I deployed a Pod to keep things simple. The key here is to make sure the securityContext object has fsGroup and runAsUser is set to to the same user defined in the image build process. In this case, the user is daemon (uid=2).

apiVersion: v1
kind: Pod
...
spec:
  securityContext:
    runAsUser: 2
    runAsGroup: 2
    fsGroup: 2
  containers:
    ...

ConfigMap can be used to inject Writefreely's config.ini into the Pod. The container image expects the configuration to be in in /config/config.ini and a directory for the templates and database in /data/. The data directory should be a PersistentVolume.

  containers:
    ...
      volumeMounts:
      - name: data
        mountPath: /data
      - name: config
        mountPath: /config/config.ini
        subPath: config.ini
    ...

The container expects environment variables to configure the admin user on first deployment.

...
containers:
    - name: writefreely
      image: containers.internal.hrck.net/writeas/writefreely:latest
      ...
      env:
        - name: USERNAME
          value: "alex"
        - name: PASSWORD
          value: "<value of admin user's password>"
     ...

Full build configuration and Kubernetes manifests can be found on Github

#kubernetes #k3s #k8s