一、创建名称空间
kubectl create ns prod
二、创建PV & PVC
vim local-pv1.yaml
apiVersion: v1kind: PersistentVolumemetadata:name: local-pv-1spec:capacity:storage: 1GiaccessModes:- ReadWriteOncepersistentVolumeReclaimPolicy: RetainstorageClassName: local-storagelocal:path: /datanodeAffinity:required:nodeSelectorTerms:- matchExpressions:- key: kubernetes.io/hostnameoperator: Invalues:- no1
vim local-pvc1.yaml
kind: PersistentVolumeClaimapiVersion: v1metadata:name: local-pvc-1namespace: prodspec:accessModes:- ReadWriteOnceresources:requests:storage: 1GistorageClassName: local-storagevolumeName: local-pv-1volumeMode: Filesystem
三、创建部署文件并部署Typecho
vim typecho-deploy.yaml
注意替换镜像地址!!! (本篇不提供)
apiVersion: apps/v1kind: Deploymentmetadata:name: typecho-deploynamespace: prodspec: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: v1kind: Servicemetadata:name: typecho-svcnamespace: prodspec: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 prodNAME READY UP-TO-DATE AVAILABLE AGEdeployment.apps/typecho-deploy 1/1 11 20mNAMETYPE CLUSTER-IP EXTERNAL-IP PORT(S)AGEservice/typecho-svc NodePort 10.211.55.201 <none>80:30010/TCP 20mNAME READY STATUSRESTARTS AGEpod/typecho-deploy-96b58b4bc-xl5rm 1/1 Running 020m
可以看到已成功运行!访问你的IP:PORT,进行测试
填写完毕点击下一步,注意字段值的替换,如下图,可以看到已经安装成功。
访问首页,博客首页如下图所示
至此,Typecho 安装完成!
使用Handsome主题进行美化后的样式如下