Deploy a Typecho Blog on Kubernetes: Step‑by‑Step Guide with MySQL
This tutorial walks you through preparing a Kubernetes cluster, deploying MySQL and Typecho containers with detailed YAML configurations, creating the necessary services and ingress, testing the setup, and highlighting Kubernetes' high‑availability and auto‑scaling benefits for a reliable blog platform.
1. Preparation
Set up a Kubernetes cluster (refer to Tencent Cloud Lighthouse for cross‑region clusters) and install the Kuboard management panel.
2. Deployment Overview
The guide assumes a Kubernetes cluster with Kuboard, then proceeds to deploy a Typecho blog.
Docker images used:
MySQL: mysql - Official Image
Typecho: rehiy/typecho
3. Create MySQL Database
3.1 MySQL Deployment YAML
apiVersion: apps/v1
kind: Deployment
metadata:
name: mysql
namespace: default
labels:
app: mysql
spec:
replicas: 1
selector:
matchLabels:
app: mysql
template:
metadata:
labels:
app: mysql
spec:
containers:
- name: mysql
image: mysql:latest
ports:
- containerPort: 3306
env:
- name: MYSQL_ROOT_PASSWORD
value: typecho@123
- name: MYSQL_DATABASE
value: typecho
- name: MYSQL_USER
value: typecho
- name: MYSQL_PASSWORD
value: typecho@123
volumeMounts:
- name: db
mountPath: /var/lib/mysql
volumes:
- name: db
hostPath:
path: /var/lib/mysql
---
apiVersion: v1
kind: Service
metadata:
name: mysql
namespace: default
spec:
type: ClusterIP
selector:
app: mysql
ports:
- name: db-port
protocol: TCP
port: 3306
targetPort: 3306Apply the above YAML to create the MySQL deployment and service.
3.2 Create MySQL Service
After applying, the MySQL service is ready.
4. Create Typecho Blog
4.1 Typecho Deployment YAML
kind: Deployment
apiVersion: apps/v1
metadata:
name: myblog
namespace: default
labels:
app: myblog
spec:
selector:
matchLabels:
app: myblog
template:
metadata:
labels:
app: myblog
spec:
containers:
- name: typecho
image: rehiy/typecho
ports:
- containerPort: 80
- containerPort: 443
volumeMounts:
- name: myblog
subPath: usr
mountPath: /var/www/default/usr
volumes:
- name: myblog
hostPath:
path: /srv/myblog
type: DirectoryOrCreate
---
kind: Service
apiVersion: v1
metadata:
name: myblog
namespace: default
spec:
selector:
app: myblog
ports:
- name: http
port: 80
targetPort: 80
- name: https
port: 443
targetPort: 443
---
kind: Ingress
apiVersion: networking.k8s.io/v1
metadata:
name: myblog
namespace: default
annotations:
traefik.ingress.kubernetes.io/router.entrypoints: web,websecure
spec:
rules:
- host: blog.eg.cn
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: myblog
port:
name: http
tls:
- secretName: defaultApply this YAML to deploy the Typecho application, its service, and an ingress.
4.2 Deploy Typecho
Follow the same steps as MySQL: modify the YAML as needed and apply.
5. Testing
Point your domain to the pod IP, then access the domain. Successful access means the blog is up; continue with the Typecho installation prompts.
Tip:
Choose the highlighted option during installation.
6. Summary
Kubernetes provides powerful high‑availability features, automatically managing and scheduling container instances to keep applications continuously available. It monitors and self‑heals failing pods, offers elastic scaling based on load, and thus ensures the Typecho blog remains stable and reliable under varying traffic.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
MaGe Linux Operations
Founded in 2009, MaGe Education is a top Chinese high‑end IT training brand. Its graduates earn 12K+ RMB salaries, and the school has trained tens of thousands of students. It offers high‑pay courses in Linux cloud operations, Python full‑stack, automation, data analysis, AI, and Go high‑concurrency architecture. Thanks to quality courses and a solid reputation, it has talent partnerships with numerous internet firms.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
