Skip to content

Instantly share code, notes, and snippets.

@mikegior
Last active January 24, 2023 23:50
Show Gist options
  • Save mikegior/8fb7abf65045625a66d7a49ac8a1a8d2 to your computer and use it in GitHub Desktop.
Save mikegior/8fb7abf65045625a66d7a49ac8a1a8d2 to your computer and use it in GitHub Desktop.
All-in-one Ghost Blog deployment
---
apiVersion: v1
kind: Namespace
metadata:
name: ghost-blog
---
apiVersion: v1
kind: Secret
metadata:
name: ghost-mysql-secret
namespace: ghost-blog
type: Opaque
stringData:
#CHANGE THIS VALUE
password: INSERT_SECRET_HERE
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: ghost-mysql-content
namespace: ghost-blog
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 5Gi
storageClassName: longhorn
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: ghost-content
namespace: ghost-blog
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 5Gi
storageClassName: longhorn
---
apiVersion: v1
kind: Service
metadata:
name: ghost-mysql
namespace: ghost-blog
labels:
app: ghost-blog-demo-mysql
spec:
ports:
- port: 3306
selector:
app: ghost-blog-demo-mysql
clusterIP: None
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: ghost-mysql
namespace: ghost-blog
labels:
app: ghost-blog-demo-mysql
spec:
selector:
matchLabels:
app: ghost-blog-demo-mysql
strategy:
type: Recreate
template:
metadata:
labels:
app: ghost-blog-demo-mysql
spec:
containers:
- image: mysql:8.0
name: mysql
env:
- name: MYSQL_ROOT_PASSWORD
valueFrom:
secretKeyRef:
name: ghost-mysql-secret
key: password
ports:
- containerPort: 3306
name: mysql
volumeMounts:
- name: ghost-mysql-content
mountPath: /var/lib/mysql
volumes:
- name: ghost-mysql-content
persistentVolumeClaim:
claimName: ghost-mysql-content
---
apiVersion: v1
kind: Service
metadata:
name: ghost-blog
namespace: ghost-blog
spec:
selector:
app: ghost-blog-demo
ports:
- protocol: TCP
port: 80
targetPort: 2368
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: ghost-blog
namespace: ghost-blog
spec:
replicas: 1
selector:
matchLabels:
app: ghost-blog-demo
template:
metadata:
labels:
app: ghost-blog-demo
spec:
containers:
- name: ghost-blog
image: ghost:latest
imagePullPolicy: Always
ports:
- containerPort: 2368
env:
- name: url
#CHANGE THIS VALUE - EXAMPLE: https://www.yoursite.com
value: https://www.<DOMAIN>.<TLD>
- name: database__client
value: mysql
- name: database__connection__host
value: ghost-mysql
- name: database__connection__user
value: root
- name: database__connection__password
valueFrom:
secretKeyRef:
name: ghost-mysql-secret
key: password
- name: database__connection__database
value: ghost-db
volumeMounts:
- mountPath: /var/lib/ghost/content
name: ghost-content
volumes:
- name: ghost-content
persistentVolumeClaim:
claimName: ghost-content
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment