我已经为我的 wordpress 应用程序创建了一个 docker 图像
FROM wordpress:php7.4-apache
COPY . /var/www/html
在我将我的图像推送到我的私人仓库之后。当我运行我的新图像时,我的自定义 wordpress 文件在/var/www/html
.
但是当我使用 pvc 在 kubernetes 中创建部署时,路径 /var/www/html 上的文件被 wordpress:php7.4-apache 图像中的文件替换
我像这样创建我的 pvc
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: wp-pv-claim
namespace: custom
labels:
app: wordpress
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 20Gi
我的部署看起来像
apiVersion: apps/v1
kind: Deployment
metadata:
namespace: custom
name: wordpress
labels:
app: wordpress
spec:
replicas: 1
selector:
matchLabels:
app: wordpress
template:
metadata:
labels:
app: wordpress
spec:
containers:
- image: privaterepo.azurecr.io/custom:latest
name: wordpress
env:
- name: WORDPRESS_DB_HOST
value: mysqlhost
- name: DB_HOST
value: mysqlhost
- name: WORDPRESS_DB_USER
value: mysqluser
- name: DB_USER
value: mysqluser
- name: WORDPRESS_DB_PASSWORD
value: mysqlpassword
- name: DB_PASS
value: mysqlpassword
- name: WORDPRESS_DB_NAME
value: dbname
- name: DB_NAME
value: dbname
- name: WORDPRESS_TABLE_PREFIX
value: wp
ports:
- containerPort: 80
name: client
volumeMounts:
- name: wordpress-persistent-storage
mountPath: /var/www/html
volumes:
- name: wordpress-persistent-storage
persistentVolumeClaim:
claimName: wp-pv-claim