使用Kubernetes部署Halo个人博客系统
前言
自从决定搭建博客以来,前后对比了各种博客框架,对比下来发现还是Halo深得我心。本站搭建在Kubernetes上,这篇文章主要是分享我的配置。
Halo简介
Halo 是一款基于 Java 的轻量级博客系统,它采用了现代化的技术栈,支持 Markdown 写作、多主题切换、评论系统、搜索引擎优化(SEO)等功能。Halo 旨在为用户提供一个简单易用、高度可定制化的博客搭建体验,它支持 REST API,拥有模板系统和附件系统,易于部署,且代码开源,允许用户自由查看和修改源码以适应特定需求
k8s配置文件
deployment.yaml
apiVersion: v1
kind: Namespace
metadata:
name: blog
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: blog-pv-claim
namespace: blog
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 20Gi
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: blog-deployment
namespace: blog
labels:
app: blog
spec:
replicas: 1
selector:
matchLabels:
app: blog
template:
metadata:
labels:
app: blog
spec:
containers:
- name: blog
image: halohub/halo:2.15.0
args: [
"--spring.r2dbc.url=r2dbc:pool:mysql://mysql地址:3306/blog
--spring.r2dbc.username=mysql用户名
--spring.r2dbc.password=mysql密码
--spring.sql.init.platform=mysql
--halo.external-url=https://blog.mixio.cn/"
]
ports:
- containerPort: 8090
readinessProbe:
httpGet:
path: /actuator/health/readiness
port: 8090
initialDelaySeconds: 30
periodSeconds: 30
timeoutSeconds: 5
failureThreshold: 5
volumeMounts:
- name: blog-storage
mountPath: /root/.halo2
volumes:
- name: blog-storage
persistentVolumeClaim:
claimName: blog-pv-claim
---
apiVersion: v1
kind: Service
metadata:
name: blog-service
namespace: blog
spec:
ports:
- port: 8090
selector:
app: blog
type: ClusterIP
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: blog-ingress
namespace: blog
annotations:
kubernetes.io/ingress.class: traefik
traefik.ingress.kubernetes.io/router.tls: "true"
traefik.ingress.kubernetes.io/http2: "true"
cert-manager.io/cluster-issuer: "letsencrypt-prod"
spec:
tls:
- secretName: blog-tls
hosts:
- blog.mixio.cn
rules:
- host: blog.mixio.cn
http:
paths:
- path: /
pathType: ImplementationSpecific
backend:
service:
name: blog-service
port:
number: 8090
使用命令等待部署完成即可:
kubectl apply -f deployment.yaml
本文是原创文章,采用 CC BY-NC-ND 4.0 协议,完整转载请注明来自 从前从前 Bolg