美文网首页k8s入门
kubernetes storageclass rbd

kubernetes storageclass rbd

作者: shangyaqi | 来源:发表于2018-08-07 09:51 被阅读2次

    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"

    创建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

    相关文章

      网友评论

        本文标题:kubernetes storageclass rbd

        本文链接:https://www.haomeiwen.com/subject/mkhovftx.html