因为家里的环境都迁移到K8S了,便也把halo迁过来,于是有了这篇教程,虽然大家都用不上🐶.....

K8S的安装略过不表,Ingress用的是Traefik。

新建namespace

kubectl create ns halo

创建yaml配置文件

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: halo-pvc
  namespace: halo
  labels:
    app: halo
spec:
  storageClassName: nfs-client
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 1Gi

---
apiVersion: v1
kind: Service
metadata:
  name: halo
  namespace: halo
spec:
  ports:
    - protocol: TCP
      name: web
      port: 8090
  selector:
    app: halo

---
apiVersion: apps/v1
kind: Deployment  
metadata:
  name:  halo
  namespace: halo
  labels:
    app: halo
spec:
  selector:  
    matchLabels:
      app: halo
  template:  
    metadata:
      labels:
        app: halo
    spec:
      volumes:
      - name: halo-data
        persistentVolumeClaim:
          claimName: halo-pvc
      containers:
      - name: halo
        image: halohub/halo:latest
        ports:
          - name: web
            containerPort: 8090
        volumeMounts:
          - name: halo-data
            mountPath: /root/.halo

---
apiVersion: traefik.containo.us/v1alpha1
kind: IngressRoute
metadata:
  name: halo-https
  namespace: halo
spec:
  entryPoints:
    - websecure
  routes:
  - match: Host(`domain.com`)
    kind: Rule
    services:
    - name: halo
      port: 8090
  tls:
    certResolver: ali
    domains:
    - main: "domain.com"

部署

kubectl apply -f xxx.yaml

enjoy!

11 天 后

问个问题,你这样要手动把application-template.yaml文件复制到halo-pvc里吧?
我现在想把conf写道configmap,然后挂载~/.halo文件夹和configmap,但是会报重复的挂载点错误,有办法解决吗?conf好像只能放~/.halo下