From 27a80c7b2501ac756320faac5b62181d30fb8049 Mon Sep 17 00:00:00 2001 From: Eric Dobbs Date: Sun, 12 Jan 2020 15:30:42 -0700 Subject: [PATCH] Start an insecure wiki under simple.localtest.me Bootstrapping a simpler development environment --- examples/k8s/README.md | 17 ++------- examples/k8s/wiki.yaml | 86 ++++++++++-------------------------------- 2 files changed, 23 insertions(+), 80 deletions(-) diff --git a/examples/k8s/README.md b/examples/k8s/README.md index c123f03..52fb2e0 100644 --- a/examples/k8s/README.md +++ b/examples/k8s/README.md @@ -3,11 +3,11 @@ There are easier ways to get started with federated wiki. Here we are using wiki to drive some learning about kubernetes. -# We're using MacOS, Docker Desktop, and kind +# We're using MacOS, Docker Desktop, and k3d brew cask install docker - brew install kind - kind create cluster --name wiki + brew install k3d + k3d create --publish 80:80 --name wiki # Deploy Wiki @@ -15,13 +15,4 @@ using wiki to drive some learning about kubernetes. # Play with the wiki - # pbcopy & open are MacOS commands - kubectl port-forward svc/wiki-service 3000:80 \ - > port-forward.log \ - 2> port-forward.err & - # get admin password on the clipboard - kubectl exec svc/wiki-service -- \ - jq -r .admin .wiki/config.json \ - | pbcopy - open http://localhost:3000 - # login with the password on the clipboard + open http://simple.localtest.me diff --git a/examples/k8s/wiki.yaml b/examples/k8s/wiki.yaml index bbf2663..544709d 100644 --- a/examples/k8s/wiki.yaml +++ b/examples/k8s/wiki.yaml @@ -10,65 +10,6 @@ spec: requests: storage: 4Gi --- -apiVersion: v1 -kind: ConfigMap -metadata: - name: wiki-config -data: - config.json: | - { - "admin": "ADMIN", - "farm": true, - "cookieSecret": "RANDOM", - "security_type": "friends", - "secure_cookie": false, - "wikiDomains": { - "local": { - "id": "/home/node/.wiki/local.owner.json" - }, - "localhost": { - "id": "/home/node/.wiki/local.owner.json" - }, - "localtest.me": { - "id": "/home/node/.wiki/local.owner.json" - }, - "local.dbbs.co": { - "id": "/home/node/.wiki/local.owner.json" - } - } - } - local.owner.json: | - { - "name": "The Owner", - "friend": { - "secret": "ADMIN" - } - } - install-config: | - #!/bin/sh - randomstring() { - node -e 'console.log(require("crypto").randomBytes(64).toString("hex"))' - } - readonly ADMIN=$(randomstring) - readonly COOKIE=$(randomstring) - - readonly CONFIG=/home/node/.wiki/config.json - readonly OWNER=/home/node/.wiki/local.owner.json - [ -f $CONFIG ] || { - jq --arg admin $ADMIN \ - --arg cookie $COOKIE \ - '.admin = $admin | .cookieSecret = $cookie' \ - /etc/config/config.json \ - > $CONFIG - } - [ -f $OWNER ] || { - jq --arg admin $ADMIN \ - '.friend.secret = $admin' \ - /etc/config/local.owner.json \ - > $OWNER - } - chown -R 1000:1000 /home/node/.wiki ---- apiVersion: apps/v1 kind: Deployment metadata: @@ -97,13 +38,11 @@ spec: volumeMounts: - name: dot-wiki mountPath: /home/node/.wiki - - name: config-templates - mountPath: /etc/config - command: ["sh", "/etc/config/install-config"] + command: ["chown", "-R", "1000:1000", "/home/node/.wiki"] containers: - name: farm - image: dobbs/farm:1.0.0 - command: ["wiki", "--config", "/home/node/.wiki/config.json"] + image: dobbs/farm:1.0.1 + command: ["wiki", "--security_legacy=true", "--data=/home/node/.wiki/simple"] ports: - containerPort: 3000 volumeMounts: @@ -113,9 +52,6 @@ spec: - name: dot-wiki persistentVolumeClaim: claimName: dot-wiki - - name: config-templates - configMap: - name: wiki-config --- apiVersion: v1 kind: Service @@ -128,3 +64,19 @@ spec: port: 80 selector: app: wiki +--- +apiVersion: extensions/v1beta1 +kind: Ingress +metadata: + name: simple-wiki + annotations: + kubernetes.io/ingress.class: traefik +spec: + rules: + - host: simple.localtest.me + http: + paths: + - path: / + backend: + serviceName: wiki-service + servicePort: http