github.com/qsunny/k8s@v0.0.0-20220101153623-e6dca256d5bf/examples-master/volumes/rbd/README.md (about)

     1  # How to Use it?
     2  
     3  Install Ceph on the Kubernetes host. For example, on Fedora 21
     4  
     5      # yum -y install ceph-common
     6  
     7  If you don't have a Ceph cluster, you can set up a [containerized Ceph cluster](https://github.com/ceph/ceph-docker)
     8  
     9  Then get the keyring from the Ceph cluster and copy it to */etc/ceph/keyring*.
    10  
    11  Once you have installed Ceph and new Kubernetes, you can create a pod based on my examples [rbd.yaml](rbd.yaml)  [rbd-with-secret.yaml](rbd-with-secret.yaml). In the pod JSON, you need to provide the following information.
    12  
    13  - *monitors*:  Ceph monitors.
    14  - *pool*: The name of the RADOS pool, if not provided, default *rbd* pool is used.
    15  - *image*: The image name that rbd has created.
    16  - *user*: The RADOS user name. If not provided, default *admin* is used.
    17  - *keyring*: The path to the keyring file. If not provided, default */etc/ceph/keyring* is used.
    18  - *secretName*: The name of the authentication secrets. If provided, *secretName* overrides *keyring*. Note, see below about how to create a secret.
    19  - *fsType*: The filesystem type (ext4, xfs, etc) that formatted on the device.
    20  - *readOnly*: Whether the filesystem is used as readOnly.
    21  
    22  # Use Ceph Authentication Secret
    23  
    24  If Ceph authentication secret is provided, the secret should be first be *base64 encoded*, then encoded string is placed in a secret yaml. For example, getting Ceph user `kube`'s base64 encoded secret can use the following command:
    25  
    26  ```console
    27    # grep key /etc/ceph/ceph.client.kube.keyring |awk '{printf "%s", $NF}'|base64
    28  QVFBTWdYaFZ3QkNlRGhBQTlubFBhRnlmVVNhdEdENGRyRldEdlE9PQ==
    29  ```
    30  
    31  An example yaml is provided [here](secret/ceph-secret.yaml). Then post the secret through ```kubectl``` in the following command.
    32  
    33  ```console
    34      # kubectl create -f examples/volumes/rbd/secret/ceph-secret.yaml
    35  ```
    36  
    37  # Get started
    38  
    39  Here are my commands:
    40  
    41  ```console
    42      # kubectl create -f examples/volumes/rbd/rbd.yaml
    43      # kubectl get pods
    44  ```
    45  
    46  On the Kubernetes host, I got these in mount output
    47  
    48  ```console
    49      #mount |grep kub
    50  	/dev/rbd0 on /var/lib/kubelet/plugins/kubernetes.io/rbd/rbd/kube-image-foo type ext4 (ro,relatime,stripe=4096,data=ordered)
    51  	/dev/rbd0 on /var/lib/kubelet/pods/ec2166b4-de07-11e4-aaf5-d4bed9b39058/volumes/kubernetes.io~rbd/rbdpd type ext4 (ro,relatime,stripe=4096,data=ordered)
    52  ```
    53  
    54   If you ssh to that machine, you can run `docker ps` to see the actual pod and `docker inspect` to see the volumes used by the container.
    55  
    56  
    57  <!-- BEGIN MUNGE: GENERATED_ANALYTICS -->
    58  [![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/examples/volumes/rbd/README.md?pixel)]()
    59  <!-- END MUNGE: GENERATED_ANALYTICS -->