Wordpress+mysql helm 部署
Wordpress+mysql helm deployment
学习kubernetes,docker和helm;
我正在研究 Devops 程序,并被要求在我的实习企业中部署 wordpress+mysql 和 helm。试图做一些事情,但 wordpress 无法连接到数据库,我认为数据库无法写入已安装的 nfs 卷路径;如果可能的话,真的需要帮助和解释。尝试了我看到的一切,但没有奏效。
我在网络浏览器中从 wordpress 得到的错误是连接数据库时出错
这是我的项目清单文件,pods状态
Service.yaml
apiVersion: v1
kind: Service
metadata:
name: wordpress-mysql
labels:
app: wordpress
spec:
ports:
- port: 3306
name: wordpress-mysql
protocol: TCP
selector:
app: wordpress
tier: mysql
type: ClusterIP
---
apiVersion: v1
kind: Service
metadata:
name: wordpress
labels:
app: wordpress
spec:
ports:
- port: 80
name: wordpress
nodePort: 32000
selector:
app: wordpress
tier: frontend
type: NodePort
Deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: wordpress-mysql
labels:
app: wordpress
spec:
selector:
matchLabels:
app: wordpress
tier: mysql
strategy:
type: Recreate
template:
metadata:
labels:
app: wordpress
tier: mysql
spec:
containers:
- image: bitnami/mysql
name: mysql
env:
- name: MYSQL_ROOT_PASSWORD
value: root
ports:
- containerPort: 3306
name: mysql
volumeMounts:
- name: mysql-pvc
mountPath: "/var/lib/mysql"
volumes:
- name: mysql-pvc
persistentVolumeClaim:
claimName: mysql-pvc
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: wordpress
labels:
app: wordpress
spec:
selector:
matchLabels:
app: wordpress
tier: frontend
strategy:
type: Recreate
template:
metadata:
labels:
app: wordpress
tier: frontend
spec:
containers:
- image: wordpress:5.8-apache
name: wordpress
env:
- name: WORDPRESS_DB_HOST
value: wordpress-mysql
- name: WORDPRESS_DB_NAME
value: wordpressdb
- name: WORDPRESS_DB_PASSWORD
value: test123
ports:
- containerPort: 80
name: wordpress
volumeMounts:
- name: wordpress-pvc
mountPath: "/var/www/html"
volumes:
- name: wordpress-pvc
persistentVolumeClaim:
claimName: wordpress-pvc
Pods状态
NAME READY STATUS RESTARTS AGE
pod/wordpress-fcf86fbd9-q9csh 1/1 Running 0 34h
pod/wordpress-mysql-6dfb484d54-wrlnm 1/1 Running 0 34h
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
service/kubernetes ClusterIP 10.96.0.1 443/TCP 9d
service/wordpress NodePort 10.98.97.25 80:32000/TCP 34h
service/wordpress-mysql ClusterIP 10.97.50.98 3306/TCP 34h
NAME READY UP-TO-DATE AVAILABLE AGE
deployment.apps/wordpress 1/1 1 1 34h
deployment.apps/wordpress-mysql 1/1 1 1 34h
NAME DESIRED CURRENT READY AGE
replicaset.apps/wordpress-fcf86fbd9 1 1 1 34h
replicaset.apps/wordpress-mysql-6dfb484d54 1 1 1 34h
在此先感谢您的帮助。真的很需要
检查一下你的DB密码和你加入的WordPress连接密码是不一样的,最好是一样。
MYSQL_ROOT_PASSWORD : root
但 WORDPRESS_DB_PASSWORD: test123
尝试更新 Wordpress 的密码,以便它可以连接到 MySQL.
WORDPRESS_DB_NAME
您已将此数据库创建到 MySQL 中还是只是添加名称?直接地 ?这可能是由于 Wordpress 查找该数据库而您尚未创建它。尝试按照这个官方 tut 并按原样检查一次:https://kubernetes.io/docs/tutorials/stateful-application/mysql-wordpress-persistent-volume/ 只有大部分相同
学习kubernetes,docker和helm; 我正在研究 Devops 程序,并被要求在我的实习企业中部署 wordpress+mysql 和 helm。试图做一些事情,但 wordpress 无法连接到数据库,我认为数据库无法写入已安装的 nfs 卷路径;如果可能的话,真的需要帮助和解释。尝试了我看到的一切,但没有奏效。
我在网络浏览器中从 wordpress 得到的错误是连接数据库时出错
这是我的项目清单文件,pods状态
Service.yaml
apiVersion: v1 kind: Service metadata: name: wordpress-mysql labels: app: wordpress spec: ports: - port: 3306 name: wordpress-mysql protocol: TCP selector: app: wordpress tier: mysql type: ClusterIP --- apiVersion: v1 kind: Service metadata: name: wordpress labels: app: wordpress spec: ports: - port: 80 name: wordpress nodePort: 32000 selector: app: wordpress tier: frontend type: NodePort
Deployment.yaml
apiVersion: apps/v1 kind: Deployment metadata: name: wordpress-mysql labels: app: wordpress spec: selector: matchLabels: app: wordpress tier: mysql strategy: type: Recreate template: metadata: labels: app: wordpress tier: mysql spec: containers: - image: bitnami/mysql name: mysql env: - name: MYSQL_ROOT_PASSWORD value: root ports: - containerPort: 3306 name: mysql volumeMounts: - name: mysql-pvc mountPath: "/var/lib/mysql" volumes: - name: mysql-pvc persistentVolumeClaim: claimName: mysql-pvc --- apiVersion: apps/v1 kind: Deployment metadata: name: wordpress labels: app: wordpress spec: selector: matchLabels: app: wordpress tier: frontend strategy: type: Recreate template: metadata: labels: app: wordpress tier: frontend spec: containers: - image: wordpress:5.8-apache name: wordpress env: - name: WORDPRESS_DB_HOST value: wordpress-mysql - name: WORDPRESS_DB_NAME value: wordpressdb - name: WORDPRESS_DB_PASSWORD value: test123 ports: - containerPort: 80 name: wordpress volumeMounts: - name: wordpress-pvc mountPath: "/var/www/html" volumes: - name: wordpress-pvc persistentVolumeClaim: claimName: wordpress-pvc
Pods状态
NAME READY STATUS RESTARTS AGE pod/wordpress-fcf86fbd9-q9csh 1/1 Running 0 34h pod/wordpress-mysql-6dfb484d54-wrlnm 1/1 Running 0 34h NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE service/kubernetes ClusterIP 10.96.0.1 443/TCP 9d service/wordpress NodePort 10.98.97.25 80:32000/TCP 34h service/wordpress-mysql ClusterIP 10.97.50.98 3306/TCP 34h NAME READY UP-TO-DATE AVAILABLE AGE deployment.apps/wordpress 1/1 1 1 34h deployment.apps/wordpress-mysql 1/1 1 1 34h NAME DESIRED CURRENT READY AGE replicaset.apps/wordpress-fcf86fbd9 1 1 1 34h replicaset.apps/wordpress-mysql-6dfb484d54 1 1 1 34h
在此先感谢您的帮助。真的很需要
检查一下你的DB密码和你加入的WordPress连接密码是不一样的,最好是一样。
MYSQL_ROOT_PASSWORD : root
但 WORDPRESS_DB_PASSWORD: test123
尝试更新 Wordpress 的密码,以便它可以连接到 MySQL.
WORDPRESS_DB_NAME
您已将此数据库创建到 MySQL 中还是只是添加名称?直接地 ?这可能是由于 Wordpress 查找该数据库而您尚未创建它。尝试按照这个官方 tut 并按原样检查一次:https://kubernetes.io/docs/tutorials/stateful-application/mysql-wordpress-persistent-volume/ 只有大部分相同