NFS 动态 PVC 的 StorageClass 和 StatefulSet
参考资料¶
搭建 NFS 服务器¶
-
安装
-
创建共享目录
-
导出
创建 NFS StorageClass¶
-
克隆 NFS Provisioner 项目
-
下载资源文件
wget -O nfs-client-provisioner-rbac.yaml https://raw.githubusercontent.com/kubernetes-sigs/nfs-subdir-external-provisioner/master/deploy/rbac.yaml wget -O nfs-client-provisioner-deploy.yaml https://raw.githubusercontent.com/kubernetes-sigs/nfs-subdir-external-provisioner/master/deploy/deployment.yaml wget -O nfs-client-sc.yaml https://raw.githubusercontent.com/kubernetes-sigs/nfs-subdir-external-provisioner/master/deploy/class.yaml
-
批量替换 Namespace
-
修改 Deployment 配置
- 镜像
registry.cn-beijing.aliyuncs.com/pylixm/nfs-subdir-external-provisioner:v4.0.0
- NFS 主机
192.192.192.6
- NFS 目录
/d/nfs
- 镜像
-
创建资源
创建 StatefulSet¶
-
mysql-sts.yaml
apiVersion: apps/v1 kind: StatefulSet metadata: namespace: local name: mysql-sts labels: app: mysql spec: selector: matchLabels: app: mysql serviceName: mysql replicas: 1 template: metadata: labels: app: mysql spec: containers: - name: mysql image: mysql:8.0.20 args: - --lower-case-table-names=1 - --default-authentication-plugin=mysql_native_password - --default-time-zone=+8:00 env: - name: MYSQL_ROOT_PASSWORD value: root ports: - containerPort: 3306 volumeMounts: - mountPath: /var/lib/mysql name: data volumeClaimTemplates: - metadata: name: data spec: storageClassName: nfs-client accessModes: - ReadWriteOnce resources: requests: storage: 1Gi
-
mysql-svc.yaml