一、创建名称空间
kubectl create ns prod
二、创建PV & PVC
vim local-pv1.yaml
apiVersion: v1
kind: PersistentVolume
metadata:name: local-pv-1
spec:capacity:storage: 1GiaccessModes:- ReadWriteOncepersistentVolumeReclaimPolicy: RetainstorageClassName: local-storagelocal:path: /datanodeAffinity:required:nodeSelectorTerms:- matchExpressions:- key: kubernetes.io/hostnameoperator: Invalues:- no1
vim local-pvc1.yaml
kind: PersistentVolumeClaim
apiVersion: v1
metadata:name: local-pvc-1namespace: prod
spec:accessModes:- ReadWriteOnceresources:requests:storage: 1GistorageClassName: local-storagevolumeName: local-pv-1volumeMode: Filesystem
三、创建部署文件并部署Typecho
vim typecho-deploy.yaml
注意替换镜像地址!!! (本篇不提供)
apiVersion: apps/v1
kind: Deployment
metadata:name: typecho-deploynamespace: prod
spec:selector:matchLabels:app: typecho-podtemplate:metadata:namespace: prodlabels:app: typecho-podspec:containers:- name: typechoimage: # 替换成自己的Typecho镜像地址ports:- containerPort: 80volumeMounts:- name: local-datamountPath: /datavolumes:- name: local-datapersistentVolumeClaim:claimName: local-pvc-1---apiVersion: v1
kind: Service
metadata:name: typecho-svcnamespace: prod
spec:selector:app: typecho-podtype: NodePortports:- port: 80nodePort: 30010targetPort: 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 20mNAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
service/typecho-svc NodePort 10.211.55.201 <none> 80:30010/TCP 20mNAME READY STATUS RESTARTS AGE
pod/typecho-deploy-96b58b4bc-xl5rm 1/1 Running 0 20m
可以看到已成功运行!访问你的IP:PORT,进行测试
填写完毕点击下一步,注意字段值的替换,如下图,可以看到已经安装成功。
访问首页,博客首页如下图所示
至此,Typecho 安装完成!
使用Handsome主题进行美化后的样式如下