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.
This commit is contained in:
Eric Dobbs 2020-01-12 19:29:41 -07:00
parent 37d6785ee2
commit eaa86fd867
2 changed files with 14 additions and 26 deletions

View File

@ -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

View File

@ -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