1. Dynamic Volume Provisioning for ML Workloads with OpenEBS


    Dynamic volume provisioning in Kubernetes is a feature that allows you to automatically create storage volumes on-demand. For machine learning workloads that may require scalable and persistent storage, using OpenEBS can be a valuable approach. OpenEBS provisions and manages containerized storage volumes, enabling the simplified and automated management of persistent state with Kubernetes workloads.

    To provision dynamic volumes using OpenEBS with Pulumi and Kubernetes, you typically need to:

    1. Set up a Kubernetes cluster.

    2. Install the OpenEBS operator into your cluster, which can manage the storage resources.

    3. Create a StorageClass resource that specifies OpenEBS as the provisioner and defines volume reclaim policies and other storage configurations.

    4. Use the created StorageClass in a PersistentVolumeClaim (PVC) to request the dynamic provisioning of a volume.

    Below is a Pulumi program in Python that demonstrates how you might create a StorageClass for OpenEBS and a PersistentVolumeClaim that provisions a storage volume dynamically.

    import pulumi import pulumi_kubernetes as k8s # Apply OpenEBS operator (This presumes OpenEBS operator YAML is available at "openebs-operator.yaml"). # This step deploys all components required for OpenEBS, like the API server, local provisioner, # storage class templates, and all the necessary CRDs. openebs_operator = k8s.yaml.ConfigFile( "openebs-operator", file="openebs-operator.yaml" ) # Define a StorageClass for OpenEBS storage_class = k8s.storage.k8s.io.v1.StorageClass( "openebs-sc", metadata=k8s.meta.v1.ObjectMetaArgs(name="openebs-jiva-default"), provisioner="openebs.io/provisioner-iscsi", # Or use "openebs.io/local" for local volumes parameters={ "openEBS.io/storage-pool": "default", # Define the storage pool to use "openEBS.io/jiva-replica-count": "1", # Set the replica count for the Jiva engine }, volume_binding_mode="Immediate", # Immediate indicates that volume binding and dynamic provisioning occurs once the PVC is created. reclaim_policy="Delete" # Delete indicates the volume will be deleted upon PVC deletion. ) # Define a PersistentVolumeClaim that requests a volume via the StorageClass defined above persistent_volume_claim = k8s.core.v1.PersistentVolumeClaim( "openebs-pvc", metadata=k8s.meta.v1.ObjectMetaArgs(name="openebs-jiva-pvc"), spec=k8s.core.v1.PersistentVolumeClaimSpecArgs( access_modes=["ReadWriteOnce"], # This access mode indicates the volume can be mounted as read-write by a single node storage_class_name=storage_class.metadata.name, # Use the StorageClass for OpenEBS resources=k8s.core.v1.ResourceRequirementsArgs( requests={ "storage": "5Gi" # Request a volume with the size of 5 GiB } ) ) ) # Export the name of the Persistent Volume Claim to be used by other resources pulumi.export('pvc_name', persistent_volume_claim.metadata.name)

    In the program above:

    • The first step with k8s.yaml.ConfigFile is a placeholder, assuming you have the OpenEBS operator YAML ready at the specified location ("openebs-operator.yaml"). This is a file that contains the necessary Kubernetes resources for OpenEBS, and applying it sets up OpenEBS in your cluster.

    • We then define an openebs-sc StorageClass, specifying OpenEBS as the provisioner. The provisioner could be openebs.io/provisioner-iscsi for iSCSI volumes or openebs.io/local for local volumes. The StorageClass also includes other parameters, like the storage pool to use and the number of replicas.

    • The PersistentVolumeClaim (openebs-pvc) is then created to make use of the StorageClass. This PVC specifies the amount of storage required and the access modes.

    • Finally, we export the name of the PVC, which can be useful for other resources or outputs that may need to reference the PVC.

    To run this Pulumi program, you should:

    • Have openebs-operator.yaml file at the specified file path or change the path to the location where you have your OpenEBS operator YAML.
    • Have Pulumi installed and set up with a Kubernetes cluster as your target environment. Your cluster should be configured with kubectl or have a kubeconfig file reachable by Pulumi.
    • Run pulumi up to apply this configuration to your cluster.

    Please note that the program assumes a very basic setup and adjustments might be needed for production-level deployments like setting up appropriate selectors, node affinities, and replica counts based on the cluster configuration and workload requirements.