Run After Dark in a lightweight K3s cluster providing the power of Kubernetes container orchestration for a fraction of the resources.
In two steps. First setup k3s, then deploy After Dark to your cluster.
Download and install k3s via script as suggested on the K3s website:
curl -sfL https://get.k3s.io | sh -
# Check for Ready node, takes maybe 30 seconds
kubectl get node
Run on host machine you wish to use to manage your cluster. This could be locally for development, on an RPi or even a VPS with 512 MB RAM. The K3s installation script gives you access to the kubectl
command giving you the ability to perform container orchestration straight-away.
Pull down Deployment files to host machine:
git clone https://git.habd.as/teowood/after-dark-k3s-amd64
Use kubectl
to apply the deployment files and get things kicked off:
cd after-dark-k3s-amd64 && kubectl apply -f .
Your cluster is now running and you have a containerized version of After Dark running inside your cluster and accessible via browser.
Continue reading for an overview of the deployment and basic usage.
Multi-tier deployment consisting of:
after-dark-k3s-hugo.yaml
deploys a pod using two containers. First, an ephemeral initialization tasked with downloading After Dark from source repo and, finally, the actual hugo container which kicks in and installs the site. When done it runs hugo server
in watch mode so Hugo rebuilds After Dark site as files change.after-dark-nginx.yaml
deploys an nginx web server that serves the content of the rendered site. As file changes occur Hugo will rebuild the After Dark site and nginx will pick up the changes.after-dark-service.yaml
exposes nginx to a NodePort so we can actually reach the site from a browser.$ AD_POD=$(kubectl get pods -l app=after-dark-hugo -o jsonpath='{.items[0].metadata.name}')
$ kubectl exec $AD_POD -- hugo new post/new-post.md -c /my-content -d /output
or you can go ahead and copy your stuff under /my-content
on your host$ kubectl cp custom.css $AD_POD:/after-dark/flying-toasters/assets/css/custom.css
$ kubectl exec $AD_POD -- hugo -D -c /my-content -d /output
$ kubectl exec $AD_POD -- hugo -c /my-content -d /output
Note this will also revert drafts.$ kubectl exec -it $AD_POD -- vi /my-content/my-post.md
or directly inside your host’s /my-content
To view your site run kubectl get svc
to locate the NodePort exposed to nginx. You should see output like:
Name | Type | Cluster-IP | External-IP | Port(s) | Age |
---|---|---|---|---|---|
after-dark-service | NodePort | 10.43.129.249 | <none> |
8080:32146/TCP | 1h |
Grab the port number next to 8080:
and use it to browse to your site using the node IP or, locally on the host, using the loopback e.g. http://localhost:32146
. (Note: Ignore the Cluster-IP and the External-IP, you want the real IP of your host.)