Ghost blog on Kubernetes

How to install your own private Ghost blog on Kubernetes.

Here my Ghost blog server with the Alto Theme.

I will use this blog site internal for my family to publish events, recipes, holliday plans, birthdays and our daily links.

And give our kids their own blog site so they can learn to build them.

First we need to make two yml files to define the persistent storage we will have on our nfs server and to install Ghost.

Persistent volume “ghostvol.yml”.

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: ghost-pv
  labels:
    app: ghost
spec:
  accessModes:
    - ReadWriteMany
  resources:
    requests:
      storage: 5Gi

Installation of Ghost “ghost.yml”

apiVersion: apps/v1
kind: Deployment
metadata:
  name: ghost
  labels:
    app: ghost
spec:
  replicas: 1
  selector:
    matchLabels:
      app: ghost
  template:
    metadata:
      labels:
        app: ghost
    spec:
      containers:
      - name: ghost
        image: ghost:5.8.2-alpine
        imagePullPolicy: Always
        ports:
        - containerPort: 2368
        env:
        - name: url
          value: http://192.168.0.220:2368
        volumeMounts:
        - mountPath: /var/lib/ghost/content
          name: content
      volumes:
       - name: content
         persistentVolumeClaim:
           claimName: ghost-pv

Please make sure to change the value to your own IP and that replicas is only 1. You can use more replicas but I got trouble i some cases.

Now to the installation.

kubectl create nc ghost
kubectl apply -f ghostvol.yml -n ghost
kubectl apply -f ghost.yml -n ghost
kubectl expose deployment ghost -n=ghost --port=2368 --target-port=2368 --name=ghost-service --type=LoadBalancer

I like to install Ghost in the namespace ghost.

We take a look on Portainer

Application.
Persistent volume.

How to uninstall Ghost.

kubectl delete service ghost-service -n ghost
kubectl delete -f ghost.yml -n ghost
kubectl delete -f ghostvol.yml -n ghost
kubectl delete ns ghost

Have fun making your own Ghost blog server.

Knud ;O)