Mac M1 Parallels CentOS7.9 Deploy Typecho

一、创建名称空间

kubectl create ns prod

二、创建PV & PVC

vim local-pv1.yaml
apiVersion: v1
kind: PersistentVolume
metadata:
  name: local-pv-1
spec:
  capacity:
    storage: 1Gi
  accessModes:
  - ReadWriteOnce
  persistentVolumeReclaimPolicy: Retain
  storageClassName: local-storage
  local:
    path: /data
  nodeAffinity:
    required:
      nodeSelectorTerms:
      - matchExpressions:
        - key: kubernetes.io/hostname
          operator: In
          values:
          - no1
vim local-pvc1.yaml
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
  name: local-pvc-1
  namespace: prod
spec:
  accessModes:
  - ReadWriteOnce
  resources:
    requests:
      storage: 1Gi
  storageClassName: local-storage
  volumeName: local-pv-1
  volumeMode: Filesystem

三、创建部署文件并部署Typecho

vim typecho-deploy.yaml

注意替换镜像地址!!! (本篇不提供)

apiVersion: apps/v1
kind: Deployment
metadata:
  name: typecho-deploy
  namespace: prod
spec:
  selector:
    matchLabels:
      app: typecho-pod
  template:
    metadata:
      namespace: prod
      labels:
        app: typecho-pod
    spec:
      containers:
      - name: typecho
        image: # 替换成自己的Typecho镜像地址
        ports:
          - containerPort: 80
        volumeMounts:
        - name: local-data
          mountPath: /data
      volumes:
      - name: local-data
        persistentVolumeClaim:
          claimName: local-pvc-1

---

apiVersion: v1
kind: Service
metadata:
  name: typecho-svc
  namespace: prod
spec:
  selector:
    app: typecho-pod
  type: NodePort
  ports:
  - port: 80
    nodePort: 30010
    targetPort: 80
[root@no1 k8s]# kubectl apply -f typecho-deploy.yaml

[root@no1 k8s]# vim typecho-deploy.yaml
[root@no1 k8s]# kubectl get deploy,svc,po -n prod
NAME                             READY   UP-TO-DATE   AVAILABLE   AGE
deployment.apps/typecho-deploy   1/1     1            1           20m

NAME                  TYPE       CLUSTER-IP     EXTERNAL-IP   PORT(S)        AGE
service/typecho-svc   NodePort   10.211.55.201   <none>        80:30010/TCP   20m

NAME                                 READY   STATUS    RESTARTS   AGE
pod/typecho-deploy-96b58b4bc-xl5rm   1/1     Running   0          20m

可以看到已成功运行!访问你的IP:PORT,进行测试
在这里插入图片描述

填写完毕点击下一步,注意字段值的替换,如下图,可以看到已经安装成功。
在这里插入图片描述
访问首页,博客首页如下图所示
在这里插入图片描述
至此,Typecho 安装完成!

使用Handsome主题进行美化后的样式如下
在这里插入图片描述