The Ceph COSI driver provisions buckets for object storage. This document instructs on enabling the driver and consuming a bucket from a sample application.
Above step will be automated in future by the Rook operator.
### Create a BucketClass and BucketAccessClass
The BucketClass and BucketAccessClass are CRDs defined by COSI. The BucketClass defines the storage class for the bucket. The BucketAccessClass defines the access class for the bucket. The BucketClass and BucketAccessClass are defined as below:
The `objectStoreUserSecretName` and `objectStoreUserSecretNamespace` are the name and namespace of the CephObjectStoreUser created in the previous step.
## User Operations
### Create a Bucket
To create a bucket, use the BucketClass to pointing the required object store and then define BucketClaim request as below:
```yaml
kind:BucketClaim
apiVersion:objectstorage.k8s.io/v1alpha1
metadata:
name:sample-bc
namespace:default# any namespace can be used
spec:
bucketClassName:sample-bcc
protocols:
- s3
```
```console
kubectl create -f bucketclaim.yaml
```
### Bucket Access
Define access to the bucket by creating the BucketAccess resource:
```yaml
kind:BucketAccess
apiVersion:objectstorage.k8s.io/v1alpha1
metadata:
name:sample-access
namespace:default# any namespace can be used
spec:
bucketAccessClassName:sample-bac
bucketClaimName:sample-bc
protocol:s3
# Change to the name of the secret where access details are stored
credentialsSecretName:sample-secret-name
```
```console
kubectl create -f bucketaccess.yaml
```
The secret will be created which contains the access details for the bucket in JSON format in the namespace of BucketAccess:
To access the bucket from an application pod, mount the secret for accessing the bucket:
```yaml
volumes:
- name: cosi-secrets
secret:
# Set the name of the secret from the BucketAccess
secretName: sample-secret-name
spec:
containers:
- name: sample-app
volumeMounts:
- name: cosi-secrets
mountPath: /data/cosi
```
The Secret will be mounted in the pod in the path: `/data/cosi/BucketInfo`. The app must parse the JSON object to load the bucket connection details.
Another approach is the json data can be parsed by the application to access the bucket via init container. Following is a sample init container which parses the json data and creates a file with the access details: