[{1] https://kubernetes.io/docs/tutorials/stateful-application/mysql-wordpress-persistent-volume/
/ ** 更新:谢谢!我决定为wordpress docker开发环境使用一键设置 https://console.cloud.google.com/marketplace/details/google/wordpress ** /
wordpress-deployment.yaml
apiVersion: v1
kind: Service
metadata:
name: wordpress
labels:
app: wordpress
spec:
ports:
- port: 80
selector:
app: wordpress
tier: frontend
type: LoadBalancer
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: wp-pv-claim
labels:
app: wordpress
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 20Gi
---
apiVersion: apps/v1 # for versions before 1.9.0 use apps/v1beta2
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:4.8-apache
name: wordpress
env:
- name: WORDPRESS_DB_HOST
value: 34.72.250.151
- name: WORDPRESS_DB_PASSWORD
valueFrom:
secretKeyRef:
name: mysql-pass
key: password
- name: WORDPRESS_DB_USER
valueFrom:
secretkeyRef:
name: mysql-pass
ports:
- containerPort: 80
name: wordpress
volumeMounts:
- name: wordpress-persistent-storage
mountPath: /var/www/html
volumes:
- name: wordpress-persistent-storage
persistentVolumeClaim:
claimName: wp-pv-claim
答案 0 :(得分:1)
yaml文件中的以下代码段存在3个问题。
在以下代码段中,在 valueFrom:键之后有一个空格,请删除“:”之后的空格
在secretKeyRef键中,“ K”应为大写字母(secretKeyRef)。
secretKeyRef缺少“键”值。
- name: WORDPRESS_DB_USER
valueFrom:
secretkeyRef:
name: mysql-pass
应该是这样。
- name: WORDPRESS_DB_USER
valueFrom:
secretKeyRef:
name: mysql-pass
key: username
谢谢
答案 1 :(得分:0)
为了避免输入错误,我决定为wordpress docker开发环境使用一键设置 https://console.cloud.google.com/marketplace/details/google/wordpress