Ceph

    PLEASE NOTE: This document applies to v0.9 version and not to the latest stable release v1.8

    Documentation for other releases can be found by using the version selector in the top right of any doc page.

    Ceph Storage Quickstart

    This guide will walk you through the basic setup of a Ceph cluster and enable you to consume block, object, and file storage from other pods running in your cluster.

    Minimum Version

    Kubernetes v1.8 or higher is supported by Rook.

    Prerequisites

    To make sure you have a Kubernetes cluster that is ready for Rook, you can follow these instructions.

    If you are using dataDirHostPath to persist rook data on kubernetes hosts, make sure your host has at least 5GB of space available on the specified path.

    TL;DR

    If you’re feeling lucky, a simple Rook cluster can be created with the following kubectl commands. For the more detailed install, skip to the next section to deploy the Rook operator.

    cd cluster/examples/kubernetes/ceph
    kubectl create -f operator.yaml
    kubectl create -f cluster.yaml
    

    After the cluster is running, you can create block, object, or file storage to be consumed by other applications in your cluster.

    Deploy the Rook Operator

    The first step is to deploy the Rook system components, which include the Rook agent running on each node in your cluster as well as Rook operator pod.

    cd cluster/examples/kubernetes/ceph
    kubectl create -f operator.yaml
    
    # verify the rook-ceph-operator, rook-ceph-agent, and rook-discover pods are in the `Running` state before proceeding
    kubectl -n rook-ceph-system get pod
    

    You can also deploy the operator with the Rook Helm Chart.

    Create a Rook Cluster

    Now that the Rook operator, agent, and discover pods are running, we can create the Rook cluster. For the cluster to survive reboots, make sure you set the dataDirHostPath property that is valid for your hosts. For more settings, see the documentation on configuring the cluster.

    Save the cluster spec as cluster.yaml:

    #################################################################################
    # This example first defines some necessary namespace and RBAC security objects.
    # The actual Ceph Cluster CRD example can be found at the bottom of this example.
    #################################################################################
    apiVersion: v1
    kind: Namespace
    metadata:
      name: rook-ceph
    ---
    apiVersion: v1
    kind: ServiceAccount
    metadata:
      name: rook-ceph-osd
      namespace: rook-ceph
    ---
    apiVersion: v1
    kind: ServiceAccount
    metadata:
      name: rook-ceph-mgr
      namespace: rook-ceph
    ---
    kind: Role
    apiVersion: rbac.authorization.k8s.io/v1beta1
    metadata:
      name: rook-ceph-osd
      namespace: rook-ceph
    rules:
    - apiGroups: [""]
      resources: ["configmaps"]
      verbs: [ "get", "list", "watch", "create", "update", "delete" ]
    ---
    # Aspects of ceph-mgr that require access to the system namespace
    kind: Role
    apiVersion: rbac.authorization.k8s.io/v1beta1
    metadata:
      name: rook-ceph-mgr-system
      namespace: rook-ceph
    rules:
    - apiGroups:
      - ""
      resources:
      - configmaps
      verbs:
      - get
      - list
      - watch
    ---
    # Aspects of ceph-mgr that operate within the cluster's namespace
    kind: Role
    apiVersion: rbac.authorization.k8s.io/v1beta1
    metadata:
      name: rook-ceph-mgr
      namespace: rook-ceph
    rules:
    - apiGroups:
      - ""
      resources:
      - pods
      - services
      verbs:
      - get
      - list
      - watch
    - apiGroups:
      - batch
      resources:
      - jobs
      verbs:
      - get
      - list
      - watch
      - create
      - update
      - delete
    - apiGroups:
      - ceph.rook.io
      resources:
      - "*"
      verbs:
      - "*"
    ---
    # Allow the operator to create resources in this cluster's namespace
    kind: RoleBinding
    apiVersion: rbac.authorization.k8s.io/v1beta1
    metadata:
      name: rook-ceph-cluster-mgmt
      namespace: rook-ceph
    roleRef:
      apiGroup: rbac.authorization.k8s.io
      kind: ClusterRole
      name: rook-ceph-cluster-mgmt
    subjects:
    - kind: ServiceAccount
      name: rook-ceph-system
      namespace: rook-ceph-system
    ---
    # Allow the osd pods in this namespace to work with configmaps
    kind: RoleBinding
    apiVersion: rbac.authorization.k8s.io/v1beta1
    metadata:
      name: rook-ceph-osd
      namespace: rook-ceph
    roleRef:
      apiGroup: rbac.authorization.k8s.io
      kind: Role
      name: rook-ceph-osd
    subjects:
    - kind: ServiceAccount
      name: rook-ceph-osd
      namespace: rook-ceph
    ---
    # Allow the ceph mgr to access the cluster-specific resources necessary for the mgr modules
    kind: RoleBinding
    apiVersion: rbac.authorization.k8s.io/v1beta1
    metadata:
      name: rook-ceph-mgr
      namespace: rook-ceph
    roleRef:
      apiGroup: rbac.authorization.k8s.io
      kind: Role
      name: rook-ceph-mgr
    subjects:
    - kind: ServiceAccount
      name: rook-ceph-mgr
      namespace: rook-ceph
    ---
    # Allow the ceph mgr to access the rook system resources necessary for the mgr modules
    kind: RoleBinding
    apiVersion: rbac.authorization.k8s.io/v1beta1
    metadata:
      name: rook-ceph-mgr-system
      namespace: rook-ceph-system
    roleRef:
      apiGroup: rbac.authorization.k8s.io
      kind: Role
      name: rook-ceph-mgr-system
    subjects:
    - kind: ServiceAccount
      name: rook-ceph-mgr
      namespace: rook-ceph
    ---
    # Allow the ceph mgr to access cluster-wide resources necessary for the mgr modules
    kind: RoleBinding
    apiVersion: rbac.authorization.k8s.io/v1beta1
    metadata:
      name: rook-ceph-mgr-cluster
      namespace: rook-ceph
    roleRef:
      apiGroup: rbac.authorization.k8s.io
      kind: ClusterRole
      name: rook-ceph-mgr-cluster
    subjects:
    - kind: ServiceAccount
      name: rook-ceph-mgr
      namespace: rook-ceph
    ---
    #################################################################################
    # The Ceph Cluster CRD example
    #################################################################################
    apiVersion: ceph.rook.io/v1
    kind: CephCluster
    metadata:
      name: rook-ceph
      namespace: rook-ceph
    spec:
      cephVersion:
        # For the latest ceph images, see https://hub.docker.com/r/ceph/ceph/tags
        image: ceph/ceph:v13.2.4-20190109
      dataDirHostPath: /var/lib/rook
      dashboard:
        enabled: true
      mon:
        count: 3
        allowMultiplePerNode: true
      storage:
        useAllNodes: true
        useAllDevices: false
        config:
          databaseSizeMB: "1024"
          journalSizeMB: "1024"
    

    Create the cluster:

    kubectl create -f cluster.yaml
    

    Use kubectl to list pods in the rook namespace. You should be able to see the following pods once they are all running. The number of osd pods will depend on the number of nodes in the cluster and the number of devices and directories configured.

    $ kubectl -n rook-ceph get pod
    NAME                                   READY     STATUS      RESTARTS   AGE
    rook-ceph-mgr-a-9c44495df-ln9sq        1/1       Running     0          1m
    rook-ceph-mon-a-69fb9c78cd-58szd       1/1       Running     0          2m
    rook-ceph-mon-b-cf4ddc49c-c756f        1/1       Running     0          2m
    rook-ceph-mon-c-5b467747f4-8cbmv       1/1       Running     0          2m
    rook-ceph-osd-0-f6549956d-6z294        1/1       Running     0          1m
    rook-ceph-osd-1-5b96b56684-r7zsp       1/1       Running     0          1m
    rook-ceph-osd-prepare-mynode-ftt57     0/1       Completed   0          1m
    

    Storage

    For a walkthrough of the three types of storage exposed by Rook, see the guides for:

    • Block: Create block storage to be consumed by a pod
    • Object: Create an object store that is accessible inside or outside the Kubernetes cluster
    • Shared File System: Create a file system to be shared across multiple pods

    Ceph Dashboard

    Ceph has a dashboard in which you can view the status of your cluster. Please see the dashboard guide for more details.

    Tools

    We have created a toolbox container that contains the full suite of Ceph clients for debugging and troubleshooting your Rook cluster. Please see the toolbox readme for setup and usage information. Also see our advanced configuration document for helpful maintenance and tuning examples.

    Monitoring

    Each Rook cluster has some built in metrics collectors/exporters for monitoring with Prometheus. To learn how to set up monitoring for your Rook cluster, you can follow the steps in the monitoring guide.

    Teardown

    When you are done with the test cluster, see these instructions to clean up the cluster.