About this task
Remember: Storage classes are cluster-wide resources.
Procedure
-
Log in to Red Hat
OpenShift Container Platform as a user with sufficient permissions to
complete the
task.
${OC_LOGIN}
Remember:
OC_LOGIN is an alias for the oc login command.
- Set the following environment variables:
- Set the
NUTANIX_SECRET environment variable to the name that you want
to use for the secret that contains your Nutanix credentials.
export NUTANIX_SECRET=<secret-name>
- Set the
CSI_DRIVER_NS environment variable to the project where you
installed the Nutanix CSI driver.
export CSI_DRIVER_NS=<project-name>
- Set the
NUTANIX_PE_CREDENTIALS environment variable to the Nutanix Prism Element virtual IP credentials.
The credentials have the following format:
PE-Virtual-IP:Port:UserName:Passwordexport NUTANIX_PE_CREDENTIALS=<credentials>
- Set the
NUTANIX_FILE_SERVER_CREDENTIALS environment variable to the
credentials of the REST API user of the file server. You can specify the file server
credentials with either of the following formats:
File-Server-FQDN:REST-API-Username:Password
File-Server-IP:REST-API-Username:Password
export NUTANIX_FILE_SERVER_CREDENTIALS=<credentials>
- Set the
NUTANIX_NFS_SERVER_NAME environment variable to the name that
you want to use to identify the Nutanix
file server:
export NUTANIX_NFS_SERVER_NAME=<server-name>
- Set the
NUTANIX_NFS_SERVER_LOCATION environment variable to the IP
address or fully qualified domain name (FQDN) of the Nutanix file server:
export NUTANIX_NFS_SERVER_LOCATION=<server-address>
- Set the
NUTANIX_NFS_PATH environment variable to the exported path
where you want the provisioner to create sub-directories.
export NUTANIX_NFS_PATH=<path>
- Set the
STORAGE_CONTAINER_NAME environment variable to the name of
the storage container where you want to store volume data.
You can use default or the name of a storage container that you created when you
installed Nutanix.
export STORAGE_CONTAINER_NAME=<name>
- Set the
PE_UUID environment variable to the unique identifier of the
Nutanix Prism Element cluster where you want
to provision the volume storage.
Tip: You can run the following command from the
Nutanix CLI to get the
UUID:
ncli cluster info
export PE_UUID=<uuid>
- Create a secret to connect to the file server and Nutanix Prism Element:
cat <<EOF |oc apply -f -
apiVersion: v1
kind: Secret
metadata:
name: ${NUTANIX_SECRET}
namespace: ${CSI_DRIVER_NS}
stringData:
key: "${NUTANIX_PE_CREDENTIALS}"
files-key: "${NUTANIX_FILE_SERVER_CREDENTIALS}"
EOF
- Create a file storage class with the required settings.
The following command uses the recommended storage class name, nutanix-file:
cat <<EOF |oc apply -f -
kind: StorageClass
apiVersion: storage.k8s.io/v1
metadata:
name: nutanix-file
provisioner: csi.nutanix.com
parameters:
dynamicProv: ENABLED
nfsServerName: ${NUTANIX_NFS_SERVER_NAME}
nfsServer: ${NUTANIX_NFS_SERVER_LOCATION}
nfsPath: ${NUTANIX_NFS_PATH}
csi.storage.k8s.io/controller-expand-secret-name: ${NUTANIX_SECRET}
csi.storage.k8s.io/controller-expand-secret-namespace: ${CSI_DRIVER_NS}
csi.storage.k8s.io/node-publish-secret-name: ${NUTANIX_SECRET}
csi.storage.k8s.io/node-publish-secret-namespace: ${CSI_DRIVER_NS}
csi.storage.k8s.io/provisioner-secret-name: ${NUTANIX_SECRET}
csi.storage.k8s.io/provisioner-secret-namespace: ${CSI_DRIVER_NS}
storageType: NutanixFiles
allowVolumeExpansion: true
reclaimPolicy: Retain
volumeBindingMode: Immediate
EOF
- Create a block storage class with the required settings.
The following command uses the recommended storage class name, nutanix-volume:
cat <<EOF |oc apply -f -
kind: StorageClass
apiVersion: storage.k8s.io/v1
metadata:
name: nutanix-volume
provisioner: csi.nutanix.com
parameters:
csi.storage.k8s.io/fstype: ext4
storageType: NutanixVolumes
computeAffinity: DISABLED
flashMode: DISABLED
storageContainer: ${STORAGE_CONTAINER_NAME}
prismElementRef: ${PE_UUID}
allowVolumeExpansion: true
reclaimPolicy: Delete
volumeBindingMode: Immediate
EOF
- Create a volume snapshot storage class.
The following command uses the recommended storage class name,
volumesnapshotclass-nutanix:
cat <<EOF |oc apply -f -
kind: VolumeSnapshotClass
apiVersion: storage.k8s.io/v1
driver: csi.nutanix.com
metadata:
name: volumesnapshotclass-nutanix
provisioner:
parameters:
csi.storage.k8s.io/snapshotter-secret-name: ${NUTANIX_SECRET}
csi.storage.k8s.io/snapshotter-secret-namespace: ${CSI_DRIVER_NS}
deletionPolicy: Retain
EOF