k8s官方案例:部署WordPress+MySql个人博客

k8s官方案例:部署WordPress+MySql个人博客

步骤:

  • 创建PersistentVolumeClaims(PVC)和PersistentVolume(PV)
  • 创建Secret(注入MySql密码等)
  • 部署MySQL容器组(Deployment)
  • 部署WordPress容器组(Deployment)

创建PersistentVolumeClaims(PVC)和PersistentVolume(PV)

MySQL和WordPress都使用持久存储(PV)来存储数据。这里我们使用基于rook-ceph项目提供的RBD块存储(存储池),为MySQL和WordPress动态创建PV。rook-ceph部署上篇博客。

apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
   name: mywordpress
   # StorageClass的名字,pvc调用时填的名字
provisioner: ceph.rook.io/block
parameters:
  pool: replicapool
  # Specify the namespace of the rook cluster from which to create volumes.
  # If not specified, it will use `rook` as the default namespace of the cluster.
  # This is also the namespace where the cluster will be
  clusterNamespace: rook-ceph
  # Specify the filesystem type of the volume. If not specified, it will use `ext4`.
  fstype: xfs
# 设置回收策略默认为:Retain
reclaimPolicy: Retain
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: mysql-pv-claim
  labels:
    app: wordpress
spec:
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 20Gi
  storageClassName: mywordpress

创建资源对象

kubectl apply -f mywordpress-storageclass-pvc.yaml

指定一个Secret变量存放MySQL密码

  • 4
    点赞
  • 16
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值