diff --git a/Documentation/ceph-examples.md b/Documentation/ceph-examples.md index 94bed7afd..6de8ee275 100644 --- a/Documentation/ceph-examples.md +++ b/Documentation/ceph-examples.md @@ -34,6 +34,8 @@ After the common resources are created, the next step is to create the Operator - `oc create -f operator-openshift.yaml` - `operator-with-csi.yaml`: Includes configuration for testing ceph-csi while the integration is still in progress. See the [CSI Drivers](ceph-csi-drivers.md) topic for more details. - `kubectl create -f operator-with-csi.yaml` +- `operator-openshift-with-csi.yaml`: Includes configuration for testing ceph-csi in an OpenShift environment + - `oc create -f operator-openshift-with-csi.yaml` Settings for the operator are configured through environment variables on the operator deployment. The individual settings are documented in `operator.yaml`. diff --git a/cluster/examples/kubernetes/ceph/operator-openshift-with-csi.yaml b/cluster/examples/kubernetes/ceph/operator-openshift-with-csi.yaml new file mode 100644 index 000000000..8dd3ca620 --- /dev/null +++ b/cluster/examples/kubernetes/ceph/operator-openshift-with-csi.yaml @@ -0,0 +1,161 @@ +################################################################################################################# +# Create the rook operator with ceph-csi driver and necessary security context constraints for running +# Rook in an OpenShift cluster. +# kubectl create -f common.yaml +# kubectl create -f operator-openshift-with-csi.yaml +# kubectl create -f cluster.yaml +################################################################################################################# +kind: SecurityContextConstraints +# older versions of openshift have "apiVersion: v1" +apiVersion: security.openshift.io/v1 +metadata: + name: rook-ceph +allowPrivilegedContainer: true +allowHostNetwork: true +allowHostDirVolumePlugin: true +priority: +allowedCapabilities: [] +allowHostPorts: true +allowHostPID: true +allowHostIPC: true +readOnlyRootFilesystem: false +requiredDropCapabilities: [] +defaultAddCapabilities: [] +runAsUser: + type: RunAsAny +seLinuxContext: + type: MustRunAs +fsGroup: + type: MustRunAs +supplementalGroups: + type: RunAsAny +allowedFlexVolumes: + - driver: "ceph.rook.io/rook" + - driver: "ceph.rook.io/rook-ceph" +volumes: + - configMap + - downwardAPI + - emptyDir + - flexVolume + - hostPath + - persistentVolumeClaim + - projected + - secret +users: + # A user needs to be added for each rook service account. + # This assumes running in the default sample "rook-ceph" namespace. + # If other namespaces or service accounts are configured, they need to be updated here. + - system:serviceaccount:rook-ceph:rook-ceph-system + - system:serviceaccount:rook-ceph:default + - system:serviceaccount:rook-ceph:rook-ceph-mgr + - system:serviceaccount:rook-ceph:rook-ceph-osd +kind: SecurityContextConstraints +# older versions of openshift have "apiVersion: v1" +apiVersion: security.openshift.io/v1 +metadata: + name: rook-ceph-csi +allowPrivilegedContainer: true +allowHostNetwork: true +allowHostDirVolumePlugin: true +priority: +allowedCapabilities: ['*'] +allowHostPorts: true +allowHostPID: true +allowHostIPC: true +readOnlyRootFilesystem: false +requiredDropCapabilities: [] +defaultAddCapabilities: [] +runAsUser: + type: RunAsAny +seLinuxContext: + type: RunAsAny +fsGroup: + type: RunAsAny +supplementalGroups: + type: RunAsAny +allowedFlexVolumes: + - driver: "ceph.rook.io/rook" + - driver: "ceph.rook.io/rook-ceph" +volumes: ['*'] +users: + # A user needs to be added for each rook service account. + # This assumes running in the default sample "rook-ceph" namespace. + # If other namespaces or service accounts are configured, they need to be updated here. + - system:serviceaccount:rook-ceph:rook-csi-rbd-plugin-sa + - system:serviceaccount:rook-ceph:rook-csi-rbd-provisioner-sa + - system:serviceaccount:rook-ceph:rook-csi-rbd-attacher-sa + - system:serviceaccount:rook-ceph:rook-csi-cephfs-plugin-sa + - system:serviceaccount:rook-ceph:rook-csi-cephfs-provisioner-sa +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: rook-ceph-operator + namespace: rook-ceph + labels: + operator: rook + storage-backend: ceph +spec: + selector: + matchLabels: + app: rook-ceph-operator + replicas: 1 + template: + metadata: + labels: + app: rook-ceph-operator + spec: + serviceAccountName: rook-ceph-system + containers: + - name: rook-ceph-operator + image: rook/ceph:master + args: ["ceph", "operator"] + volumeMounts: + - mountPath: /var/lib/rook + name: rook-config + - mountPath: /etc/ceph + name: default-config-dir + env: + - name: ROOK_CURRENT_NAMESPACE_ONLY + value: "true" + # CSI enablement + - name: ROOK_CSI_ENABLE_CEPHFS + value: "true" + - name: ROOK_CSI_CEPHFS_IMAGE + value: "quay.io/cephcsi/cephfsplugin:v1.0.0" + - name: ROOK_CSI_ENABLE_RBD + value: "true" + - name: ROOK_CSI_RBD_IMAGE + value: "quay.io/cephcsi/rbdplugin:v1.0.0" + - name: ROOK_CSI_REGISTRAR_IMAGE + value: "quay.io/k8scsi/csi-node-driver-registrar:v1.0.2" + - name: ROOK_CSI_PROVISIONER_IMAGE + value: "quay.io/k8scsi/csi-provisioner:v1.0.1" + - name: ROOK_CSI_SNAPSHOTTER_IMAGE + value: "quay.io/k8scsi/csi-snapshotter:v1.0.1" + - name: ROOK_CSI_ATTACHER_IMAGE + value: "quay.io/k8scsi/csi-attacher:v1.0.1" + - name: ROOK_HOSTPATH_REQUIRES_PRIVILEGED + value: "true" + - name: FLEXVOLUME_DIR_PATH + value: "/etc/kubernetes/kubelet-plugins/volume/exec" + # The name of the node to pass with the downward API + - name: NODE_NAME + valueFrom: + fieldRef: + fieldPath: spec.nodeName + # The pod name to pass with the downward API + - name: POD_NAME + valueFrom: + fieldRef: + fieldPath: metadata.name + # The pod namespace to pass with the downward API + - name: POD_NAMESPACE + valueFrom: + fieldRef: + fieldPath: metadata.namespace + volumes: + - name: rook-config + emptyDir: {} + - name: default-config-dir + emptyDir: {}