Deploy the leading open-source publishing platform, Ghost, on Kubernetes with maximum security and efficiency using a hardened, multi-arch container image.
Maintained by SREDevOps.org: SRE, DevOps, Linux, Ethical Hacking, AI, ML, Open Source, Cloud Native, Platform Engineering in English, Español, and Portugués (Brasil).Key Highlights: Security & Efficiency
This repository implements Ghost CMS v6.xx.x from @TryGhost (Official) on Kubernetes with a custom built image, which delivers significant improvements for production use and security features in Kubernetes.
Non-Root Execution: Both the Ghost and MySQL components run exclusively as a non-root user (UID/GID 65532) in Kubernetes, preventing potential privilege escalation attacks.
Distroless Runtime: We utilize Google Container Tools Distroless Debian 13 - NodeJS 22 as the final runtime environment. Distroless images contain only the required application and language dependencies, excluding shells and package managers, making them substantially more secure and reducing the attack surface.
Vulnerability Reduction: By replacing gosu with a native container execution flow and adopting Distroless, we removed several critical vulnerabilities reported in the original Ghost image:
Result: This change alone reduced 6 critical vulnerabilities and 34 high vulnerabilities reported by Docker Scout in the official image.
Custom Build Artifacts: We maintain two distinct Dockerfiles for production and development:
Production Image: The main image built using our hardened, multi-stage build process. See the Dockerfile.
Development Image: A variant tailored for testing, which bundles SQLite support. See the Dockerfile-dev.
Multi-Arch Support: Images are built for both amd64 and arm64 architectures.
Multi-Stage Build: We use the official Node 22 Jod LTS image for building, which significantly reduces the final image size and improves security by removing unnecessary build components.
Updated Ghost v6 & NodeJS 22 LTS: Using the latest stable versions for security and performance.
Robust Entrypoint (entrypoint.js): A custom Node.js entrypoint script, executed by the unprivileged user, handles necessary runtime operations like updating default themes before starting the Ghost application. The script can be reviewed here: entrypoint.js.
Dedicated Init Container: The deployment includes an initContainer to handle directory creation, correct ownership (UID/GID 65532), and permission setting prior to the main Ghost container launch, ensuring seamless operation inside the Distroless container.
Deployment Architecture Overview
This project provides complete Kubernetes manifest files (deploy/) to run a production-ready Ghost instance backed by a MySQL database.
Resource
Components
Details
Namespace
ghost-on-kubernetes
Provides logical isolation for all components. (File: 00-namespace.yaml)
StatefulSet
ghost-on-kubernetes-mysql
Manages the MySQL 8 database, ensuring stable networking and persistent storage. (File: 05-mysql.yaml)
Exposes the Ghost application to the outside world via HTTP/HTTPS (requires a TLD). (File: 07-ingress.yaml)
Note: You can host multiple Ghost instances by replacing the Namespace specification in each manifest file.
Installation Instructions (Production)
Follow these steps to deploy Ghost on your Kubernetes cluster.
Prerequisites
A functioning Kubernetes cluster (kubectl configured).
A provisioned StorageClass (required for PVCs).
0. Clone (or fork) the Repository
## Clone the repository
git clone https://github.com/sredevopsorg/ghost-on-kubernetes.git --depth 1 --branch main --single-branch --no-tags
## Change directory
cd ghost-on-kubernetes
1. Review and Configure
Review the example configuration files and modify the manifests in the deploy/ folder to suit your environment (e.g., storage class, domain name, secret values).
Configurations: Check the example configuration files in the examples/ directory:
config.production.sample.yaml: Recommended configuration using MySQL 8. Requires a valid top-level domain (TLD) for the url field and Ingress configuration.
config.development.sample.yaml: Uses SQLite for testing environments.
Una instancia de DeepSeek Harness por usuario sobre agent-sandbox: warm pools, suspensión por inactividad, un gateway con sesiones opacas y el hardening que la demo no trae.
When I wanted to run it on Kubernetes, the question was not how to start it, but what it needs in order not to break, to scale and, above all, to run the container in the safest possible way.