创建Deployment
apiVersion: apps/v1
kind: Deployment
metadata:
name: ghost-deployment
labels:
app: ghost
spec:
replicas: 1
selector:
matchLabels:
app: ghost
template:
metadata:
labels:
app: ghost
spec:
volumes:
- name: tz
hostPath:
path: /etc/localtime
- name: ghost-content
hostPath:
path: /data/ghost-content
- name: ghost-db # 第一次创建时不挂载这个,需要启动后从./current/content/data里复制出来一份
hostPath:
path: /data/ghost-dev.db
containers:
- name: ghost
image: ghost:latest
volumeMounts:
- name: tz
mountPath: /etc/localtime
- name: ghost-content
mountPath: /var/lib/ghost/content
- name: ghost-db # 第一次创建时不挂载这个
mountPath: /var/lib/ghost/current/content/data/ghost-dev.db
ports:
- containerPort: 2368
env:
- name: NODE_ENV
value: "development"
- name: url
value: "http://www.dev-f.cn"
创建Service
apiVersion: v1
kind: Service
metadata:
name: ghost-service
spec:
selector:
app: ghost
ports:
- protocol: TCP
port: 80
targetPort: 2368
创建Ingress
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: ghost-ingress
annotations:
# kubernetes.io/ingress.class: traefik
# traefik.ingress.kubernetes.io/router.middlewares: default-redirect@kubernetescrd
nginx.ingress.kubernetes.io/rewrite-target: /
nginx.ingress.kubernetes.io/ssl-redirect: "true"
spec:
# tls: # https配置(需要添加secret)
# - hosts:
# - "www.example.com"
# secretName: example-tls
rules:
- host: "www.example.com"
http:
paths:
- path: "/"
pathType: Prefix
backend:
service:
name: ghost-service
port:
number: 80