kubernetes|kubernetes storageclass rbd
StorageClass 对象支持多种类型的存储卷插件来提供 PV,从 Storage Classes 官方文档 provisioner 部分可以看到,它目前支持很多种存储卷类型,其中就有我们熟悉的 Ceph RBD 类型。
创建 ceph-secret-admin(从ceph集群内部获取)
ceph auth get-key client.admin | base64
QVFDR09mcGFBVkY5SXhBQUFsMU9LUHR3R1BaNEo3V3ZLNHNXd3c9PQ==
创建 ceph-secret-admin.yaml
apiVersion: v1
kind: Secret
metadata:
name: ceph-secret-admin
namespace: kube-system
type: "kubernetes.io/rbd"
data:
key: QVFDR09mcGFBVkY5SXhBQUFsMU9LUHR3R1BaNEo3V3ZLNHNXd3c9PQ==
创建 rbd-storage-class storageclass.yaml
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: ceph-storageclass
provisioner: kubernetes.io/rbd
parameters:
monitors: 192.168.1.101:6789
adminId: admin
adminSecretName: ceph-secret-admin
adminSecretNamespace: kube-system
pool: rbd
userId: admin
userSecretName: ceph-secret-admin
fsType: ext4
imageFormat: "1"
【kubernetes|kubernetes storageclass rbd】创建pvc pvc.yaml
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: test-pvc
annotations:
volume.beta.kubernetes.io/storage-class: ceph-storageclass
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 1Gi
文章图片
pv.png
文章图片
qq.png 创建应用测试 deployment
apiVersion: apps/v1beta1
kind: Deployment
metadata:
name: demo-sc
spec:
replicas: 1
template:
metadata:
labels:
app: demo-sc
spec:
containers:
- name: demo-sc
image: tomcat
ports:
- containerPort: 8080
volumeMounts:
- mountPath: "/home"
name: data
volumes:
- name: data
persistentVolumeClaim:
claimName: test-pvc
推荐阅读
- federation--kubernetes集群联邦的实现
- 如何在Kubernetes|如何在Kubernetes 里添加自定义的 API 对象(一)
- Kubernetes服务(初学者指南)
- 深入理解Kubernetes的认证与授权机制
- 利用Centos7|利用Centos7 YUM 快速搭建Kubernetes集群
- Kubernetes|Kubernetes stateful set讲解以及一个基于postgreSQL的具体例子
- learning|learning kubernetes by minikube, 3
- Kubernetes的代码规范
- 简单、有效、全面的Kubernetes监控方案
- Kubernetes HPA 基于 Prometheus 自定义指标的可控弹性伸缩