在k8S集群部署wordpress案例
1.编写资源清单
[root@master231 pod]# cat 03-pods-wordpress.yaml
apiVersion: v1
kind: Pod
metadata:
name: baimei-wp
spec:
hostNetwork: true
nodeName: worker233
containers:
- name: db
image: harbor.baimei.com/baimei-db/mysql:5.7
# 向容器传递环境变量
env:
# 变量的名称
- name: MYSQL_ALLOW_EMPTY_PASSWORD
# 指定变量的值
value: "yes"
- name: MYSQL_DATABASE
value: "wordpress"
- name: MYSQL_USER
value: "admin"
- name: MYSQL_PASSWORD
value: "baimei"
- name: wp
image: harbor.baimei.com/baimei-wordpress/wordpress:latest
env:
- name: WORDPRESS_DB_HOST
value: "127.0.0.1"
- name: WORDPRESS_DB_USER
value: "admin"
- name: WORDPRESS_DB_PASSWORD
value: "baimei"
- name: WORDPRESS_DB_NAME
value: "wordpress"
2.创建Pod
kubectl get pods
kubectl apply -f 03-pods-wordpress.yaml
kubectl get pods -o wide
3.访问WordPress的WebUI
http://10.0.0.233/