ghost-on-kubernetes

by SREDevOps.org

Helm chartv2.0.2App 6.55.0MITVerified publisher

Deploy the leading open-source publishing platform, Ghost, on Kubernetes and Docker with maximum security and efficiency using a hardened, multi-arch container image.

About this chart

Ghost on Kubernetes Helm Chart

Deploy Ghost CMS on Kubernetes with a hardened, rootless, multi-arch container image.

Prerequisites

  • Kubernetes 1.25 or newer (enforced by kubeVersion in Chart.yaml)
  • Helm 3.13 or newer
  • A default StorageClass, or an explicit storageClassName per claim
  • An Ingress controller (Traefik and nginx presets included) if you enable Ingress
  • cert-manager if you use ingress.tls.mode: certManager or both

Install

helm repo add sredevopsorg https://sredevopsorg.github.io/ghost-on-kubernetes
helm repo update

helm install my-ghost sredevopsorg/ghost-on-kubernetes \
  --namespace ghost --create-namespace \
  --set ghost.url=https://yourdomain.tld \
  --set ingress.hosts[0].host=yourdomain.tld \
  --set ingress.tls.hosts[0]=yourdomain.tld \
  --set persistence.ghost.storageClassName=your-storage-class \
  --set persistence.mysql.storageClassName=your-storage-class

Run helm install and read the NOTES output: it prints the URL, the TLS state, and any warning that applies to the configuration you chose.

Common configurations

Every example below is a file in examples/ and is rendered by CI.

ExampleUse it for
examples/production-values.yamlInternal MySQL, cert-manager TLS, disruption budget
examples/ha-values.yamlThree replicas over ReadWriteMany storage, spread across zones
examples/external-mysql-values.yamlA database managed outside this release
examples/development-values.yamlLocal development, no Ingress, small footprint
examples/manual-tls-values.yamlA certificate you supply yourself
helm install my-ghost sredevopsorg/ghost-on-kubernetes \
  -n ghost --create-namespace \
  -f examples/production-values.yaml

Configuration

Ghost

ParameterDescriptionDefault
ghost.urlPublic site URL, including the schemehttps://yourdomain.tld
ghost.adminUrlAdmin URL, defaults to ghost.url""
ghost.probeHostHost header used by the probes, defaults to the hostname of ghost.url""
ghost.contentPathWhere Ghost stores uploads, themes and logs/home/nonroot/app/ghost/content
ghost.config.existingSecretMount config.production.json from a secret you manage""
ghost.mail.*Outgoing mail, required before Ghost can send mailSMTP settings
ghost.resourcesGhost container requests and limits100m/256Mi – 800m/800Mi
ghost.securityContextContainer security context, restricted-PSS compliantnon-root, read-only rootfs
ghost.extraConfigMerged into config.production.json, top-level keys win{}
ghost.initContainer.enabledRoot init container that chowns the content volumefalse
ghost.readinessProbe.enabledGates traffic to the podtrue
ghost.startupProbe.enabledAllows a slow first boot while the database migratestrue
ghost.livenessProbe.enabledRestarts a wedged processfalse
ghost.affinitynodeAffinity, podAffinity, podAntiAffinity, each optional{}
ghost.nodeSelector / tolerations / topologySpreadConstraintsScheduling controlempty

Database

ParameterDescriptionDefault
mysql.enabledDeploy the MySQL StatefulSet and its headless Servicetrue
mysql.auth.database / username / password / rootPasswordCredentialschange me
mysql.auth.existingSecretUse a secret you manage, keys MYSQL_DATABASE, MYSQL_USER, MYSQL_PASSWORD, MYSQL_ROOT_PASSWORD, MYSQL_HOST""
mysql.external.*Connection details used when mysql.enabled=falseplaceholders
mysql.initContainer.enabledRoot init container that chowns the data directorytrue
mysql.livenessProbe.enabled / readinessProbe.enabledTCP checkstrue

Cache

Valkey is a cache, not a database: Ghost works without it and simply serves more slowly.

ParameterDescriptionDefault
valkey.enabledDeploy the bundled Valkeyfalse
valkey.auth.enabledRequire a password on ittrue
valkey.auth.existingSecretUse a secret you manage, key valkey-password""
valkey.external.enabledCache through an external Valkey or Redisfalse
valkey.keyPrefixNamespace for every cache keyghost
valkey.ttl.*Entry lifetime per adapter, in seconds15 minutes to 24 hours

Storage

ParameterDescriptionDefault
persistence.ghost.enabledClaim for Ghost contenttrue
persistence.ghost.accessModeMust be ReadWriteMany for more than one replicaReadWriteOnce
persistence.ghost.size / storageClassName / selectorClaim tuning1Gi, default class
persistence.mysql.*Same keys for the database1Gi
persistence.valkey.*Same keys for the cache1Gi

Turning a claim off switches that workload to an emptyDir. Nothing breaks, but the data is lost on every pod restart. NOTES.txt warns when it happens.

Networking and exposure

ParameterDescriptionDefault
service.typeType of the Ghost ServiceClusterIP
service.port / targetPortGhost Service port and container port2368
ingress.enabledCreate an Ingresstrue
ingress.className / preset / entrypoint / annotationsIngress wiringtraefik
ingress.hosts[]Hosts and paths, with path and pathTypeyourdomain.tld
ingress.tls.enabled / mode / secretName / certManager.* / certificate / key / hostsTLSmanual, tls-secret
networkPolicy.enabled / egressRestrict traffic to the Ghost podsfalse

The MySQL and Valkey Services are always headless and internal: their type is not configurable, because a load balancer in front of a database or a cache is never what you want.

Platform

ParameterDescriptionDefault
replicaCountGhost replicas, ignored when autoscaling is on1
autoscaling.enabled / minReplicas / maxReplicas / metrics / behaviorHorizontalPodAutoscaleroff
podDisruptionBudget.enabled / maxUnavailable / minAvailableEviction safetyoff
strategy / minReadySeconds / revisionHistoryLimit / progressDeadlineSecondsRollout behaviourRollingUpdate, surge 1
serviceAccount.create / name / annotationsPod identitycreated, token not mounted
valkey.podSecurityContextMerged over podSecurityContext for Valkey pods{}
podSecurityContextPod level security context, fsGroup grants volume accessfsGroup: 65532
priorityClassNamePriority class for every podunset
imagePullSecrets[{name: <secret>}] for private registries[]
labels / annotations / podLabels / podAnnotationsExtra metadataempty
extraEnv / extraEnvFrom / extraVolumes / extraVolumeMountsEscape hatches for the Ghost podempty
initContainer.*Shared root init container image and resourcesbusybox
volumes.*Sizes of the ephemeral volumessee values.yaml
testImage.*Image used by helm testbusybox

Anything else

ghost.extraConfig is merged into config.production.json last, so any Ghost setting this chart does not model can still be set:

ghost:
  extraConfig:
    imageOptimization:
      sharp:
        quality: 80
    themes:
      - mytheme

For full control, set ghost.config.existingSecret to a secret holding your own config.production.json. The chart then stops rendering one, but the rest of the release still references your ghost.url, the Service, and the content volume.

Upgrading from 1.x

helm upgrade my-ghost sredevopsorg/ghost-on-kubernetes -n ghost --reset-values -f my-values.yaml

Every release in the 2.0.x line contains changes that a plain helm upgrade cannot apply to a running 1.x release:

  1. Workload selectors are release-scoped. The MySQL StatefulSet and the Valkey Deployment used to select on app: ghost-on-kubernetes-mysql, which two releases in one namespace shared. Selectors are immutable, so recreate those two workloads once, before or during the upgrade:

    kubectl delete statefulset <fullname>-mysql --cascade=orphan -n ghost
    kubectl delete deployment <fullname>-valkey --cascade=orphan -n ghost
    helm upgrade my-ghost sredevopsorg/ghost-on-kubernetes -n ghost -f my-values.yaml
    

    Persistent volume claims are not touched by that delete, so the data stays. If the delete is skipped, helm upgrade fails with an immutable-field error.

  2. The Ghost pod no longer runs a root init container. Ownership comes from podSecurityContext.fsGroup now. Set ghost.initContainer.enabled=true if your volume driver does not apply fsGroup (some NFS exports with root_squash).

  3. Probes are on by default. Readiness and startup now render where they previously did not, which restarts the pods once on upgrade. Liveness stays off unless you enable it, and ghost.probeHost now defaults to the hostname of ghost.url rather than ingress.hosts[0].host, so probes no longer fail when Ingress is disabled.

  4. Values that were never read are gone or replaced. service.mysql.type and service.valkey.type no longer exist: those Services are headless and ClusterIP. valkey.initResources was unused. ghost.affinity.enabled is ignored; set nodeAffinity, podAffinity or podAntiAffinity instead.

  5. strategy.rollingUpdate.maxSurge defaults to 1 instead of 3. With ReadWriteOnce content, a surge pod cannot attach the volume on a second node, so a lower surge stalls less often. For a single replica, strategy.type: Recreate is the simplest safe choice.

Verifying

helm lint ./ghost-on-kubernetes --strict
helm template rel ./ghost-on-kubernetes
helm test my-ghost -n ghost

Troubleshooting

Ghost pod stuck in ContainerCreating with a pending PVC. kubectl describe pvc -n ghost and check the StorageClass name and the access mode. For more than one replica the claim must be ReadWriteMany.

Ghost logs: permission denied on the content volume. The volume driver is not applying fsGroup. Set ghost.initContainer.enabled=true, or chown the volume to 65532 once by hand.

Rollout stuck after an image change. A ReadWriteOnce volume plus maxUnavailable: 0 means the old pod holds the volume until the new one is ready, and the new pod may be waiting on a volume another node already has. Use strategy.type=Recreate, ReadWriteMany storage, or raise maxUnavailable to 1.

Probes fail with 404 or a wrong site. Set ghost.probeHost to the host Ghost serves, and check that ghost.url has the scheme (https://). Set ghost.readinessProbe.scheme=HTTPS when the probes must go through TLS.

MySQL will not start. kubectl logs -n ghost <pod> -c mysql-init for the ownership fix, then the mysql container. Check that the claim is bound, and that mysql.auth.* values are the ones the database was initialised with: the MySQL image only applies them on first start, so changing them later needs a manual ALTER USER.

TLS never becomes valid. With ingress.tls.mode=manual, create the secret yourself or set ingress.tls.certificate and ingress.tls.key. NOTES.txt says so at install time.

Security notes

  • Ghost runs as UID 65532 with a read-only root filesystem, all capabilities dropped and no service account token mounted.
  • MySQL runs as UID 65532, Valkey as UID 999, both with dropped capabilities.
  • Every pod sets seccompProfile: RuntimeDefault and fsGroup: 65532.
  • Containers that must start as root set runAsNonRoot: false explicitly. A container that inherits runAsNonRoot: true without an explicit runAsUser is rejected by the kubelet unless its image declares a non-root user, so the opt-in init containers carry that override.
  • The MySQL pod still starts with a root init container by default, which the restricted Pod Security Standard rejects. Set mysql.initContainer.enabled=false to drop it and rely on fsGroup.
  • Credentials live in values, Helm release secrets and rendered Secrets. Prefer mysql.auth.existingSecret, valkey.auth.existingSecret and ghost.config.existingSecret when a secret manager is available.

Uninstall

helm uninstall my-ghost -n ghost

Claims are not deleted with the release:

kubectl delete pvc -n ghost -l app.kubernetes.io/instance=my-ghost

Deploy ghost-on-kubernetes with OpenTenant

Each tenant gets its own release of this chart, with its own namespace, secrets and domain. The builder below already has ghost-on-kubernetes on a Hetzner server. Change the host, add apps from the marketplace, then copy the generated files. Providers and prices are samples, and nothing here is sent anywhere.

  1. Pick a serverConnect Hetzner, OVHcloud or AWS. The builder starts on Hetzner, the cheapest sample rate.
  2. Place the chartghost-on-kubernetes is pinned at v2.0.2 in opentenant.yaml. Drag more apps from the marketplace onto a rack.
  3. ApplySave opentenant.yaml and main.tf from the console, then run the commands below.
# opentenant.yaml, main.tf and dns.tf come from the builder below
opentenant validate opentenant.yaml
terraform init && terraform apply