From eaa86fd8679ca25d9bbdb25c3b3fea899f32350a Mon Sep 17 00:00:00 2001 From: Eric Dobbs Date: Sun, 12 Jan 2020 19:29:41 -0700 Subject: [PATCH] Simplify persistence configuration & expose macos folders We now map ~/.wiki-k8s in MacOS into the .wiki folder inside the container and similarly with MacOS ~/workspace/fedwiki First, when we create the k3d cluster, we include directives that are passed through to docker to mount the MacOS directories into the kubernetes host. Second, we use hostPath volumes in the kubernetes deployment config. These will work great for the primary use case of a local wiki. Deployments to remote kubernetes clusters will want to do this with the PersistentVolumeClaim that was removed with this change. One luxury of using hostPath and the legacy_security is that we no longer require an init container. --- examples/k8s/README.md | 8 +++++++- examples/k8s/wiki.yaml | 32 +++++++------------------------- 2 files changed, 14 insertions(+), 26 deletions(-) diff --git a/examples/k8s/README.md b/examples/k8s/README.md index 52fb2e0..6094126 100644 --- a/examples/k8s/README.md +++ b/examples/k8s/README.md @@ -7,7 +7,13 @@ using wiki to drive some learning about kubernetes. brew cask install docker brew install k3d - k3d create --publish 80:80 --name wiki + + mkdir -p ~/.wiki-k8s ~/workspace/fedwiki + k3d create \ + --publish 80:80 \ + -v "$HOME/.wiki-k8s:/macos/.wiki-k8s" \ + -v "$HOME/workspace/fedwiki:/macos/fedwiki" \ + --name wiki # Deploy Wiki diff --git a/examples/k8s/wiki.yaml b/examples/k8s/wiki.yaml index b21aef0..81e6ae2 100644 --- a/examples/k8s/wiki.yaml +++ b/examples/k8s/wiki.yaml @@ -1,15 +1,3 @@ -apiVersion: v1 -kind: PersistentVolumeClaim -metadata: - name: dot-wiki -spec: - accessModes: - - ReadWriteOnce - volumeMode: Filesystem - resources: - requests: - storage: 4Gi ---- apiVersion: apps/v1 kind: Deployment metadata: @@ -28,17 +16,6 @@ spec: runAsUser: 1000 runAsGroup: 1000 fsGroup: 1000 - initContainers: - - name: wiki-config - image: dobbs/farm:1.0.0 - securityContext: - runAsUser: 0 - runAsGroup: 0 - allowPrivilegeEscalation: false - volumeMounts: - - name: dot-wiki - mountPath: /home/node/.wiki - command: ["chown", "-R", "1000:1000", "/home/node/.wiki"] containers: - name: farm image: dobbs/farm:1.0.1 @@ -48,10 +25,15 @@ spec: volumeMounts: - name: dot-wiki mountPath: /home/node/.wiki + - name: fedwiki + mountPath: /home/node/fedwiki volumes: - name: dot-wiki - persistentVolumeClaim: - claimName: dot-wiki + hostPath: + path: /macos/.wiki-k8s + - name: fedwiki + hostPath: + path: /macos/fedwiki --- apiVersion: v1 kind: Service