After-Dark on k3s (lightweight Kubernetes by Rancher)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Josh Habdas 2dd51623c4 updated README more 6 months ago
README.md updated README more 6 months ago
after-dark-k3s-hugo.yaml changed path for posts 7 months ago
after-dark-nginx.yaml initial commit 7 months ago
after-dark-service.yaml initial commit 7 months ago

README.md

After Dark K3s

Run After Dark in a lightweight K3s cluster providing the power of Kubernetes container orchestration for a fraction of the resources.

Installation

In two steps. First setup k3s, then deploy After Dark to your cluster.

Step 1: Download and install k3s via script

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.

Step 2: Deploy After Dark to your k3s cluster

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.

Overview of deployment

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.

Usage

Operating your k3s After Dark site

  • First retrieve your pod name and store it in a variable for your convenience $ AD_POD=$(kubectl get pods -l app=after-dark-hugo -o jsonpath='{.items[0].metadata.name}')
  • Create a new post
    $ 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
  • Apply custom styling
    $ kubectl cp custom.css $AD_POD:/after-dark/flying-toasters/assets/css/custom.css
  • Build your draft posts
    $ kubectl exec $AD_POD -- hugo -D -c /my-content -d /output
  • Full rebuilt your site e.g after new styles appied $ kubectl exec $AD_POD -- hugo -c /my-content -d /output Note this will also revert drafts.
  • Edit your posts $ kubectl exec -it $AD_POD -- vi /my-content/my-post.md or directly inside your host’s /my-content

Browsing to your site

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.)