Datashim Documentation

repository·master·Indexed 19 days ago

https://github.com/datashim-io/datashim

A Kubernetes framework that simplifies data access for workloads using a 'Dataset' abstraction. Datashim automatically manages the mounting and configuration of S3 and NFS data sources via PVCs and ConfigMaps, supporting integrations with Noobaa, MinIO, and other S3-compatible object storage providers.

Tokens
29.3K
Snippets
107
Records
130
Agent score
67%

What's inside Datashim

  1. Overview of the Dataset Operator

    master
    The Dataset Operator is a Kubernetes operator that introduces the Dataset Custom Resource Definition (CRD) to a cluster. Its primary function is to manage Dataset objects; in its current demonstration mode, the operator automatically creates a pod for every Dataset object defined in the cluster.
  2. What is Datashim and how does it work?

    master

    Datashim is a Kubernetes framework that provides easy access to S3 and NFS Datasets within pods. It introduces a Dataset Custom Resource Definition (CRD) which acts as a pointer to existing S3 or NFS data sources.

    When you define a Dataset, Datashim orchestrates the provisioning of the necessary Persistent Volume Claims (PVCs) and ConfigMaps. This allows users to reference data in their pods without manually configuring, mounting, or tuning data access. The framework is extensible via the Container Storage Interface (CSI) to support additional data sources in the future.

  3. Potential benefits of using Datashim

    master

    Beyond simplifying data access, the Dataset CRD enables higher-level orchestration and future extensions in two key areas:

    • Performance: Datashim provides a pluggable caching interface. An example implementation is the Ceph Caching Plugin.
    • Security: The framework is exploring a common access management layer to handle credentials across different types of data sources uniformly.
  4. Understand the Datashim Dataset abstraction

    master

    Datashim introduces a new Custom Resource Definition (CRD) called the Dataset. This abstraction provides a declarative way to reference existing data sources (currently supporting S3 and NFS) without requiring users to manually manage complex CSI (Container Storage Interface) configurations.

    When a Dataset is created, the Datashim Operator automatically handles the following:

    1. Invokes the appropriate CSI plugin for the data source.
    2. Configures and provisions a Persistent Volume Claim (PVC).
    3. Provides a mount-point in the user's pod for the data.
    4. Exposes an interface for caching mechanisms to leverage.
  5. Configure the S3 mounter in the StorageClass

    master

    Since S3 is not a native filesystem, the driver uses different mounters to provide varying levels of POSIX compatibility. You can specify the mounter as a parameter in your StorageClass definition.

    Supported mounters:

    • rclone: High POSIX compatibility (depends on caching mode). Files are viewable via standard S3 clients.
    • s3fs: Large subset of POSIX. Does not support appends or random writes. Files are viewable via standard S3 clients.
    • goofys: Performance-oriented with weak POSIX compatibility. Does not support appends or random writes. Files are viewable via standard S3 clients.
    • s3backer (experimental): Represents a block device on S3. Supports appends and allows use of a real filesystem, but files are not readable with other S3 clients.

    Note on s3backer: It is experimental and can cause volume corruption during unexpected shutdowns. To use it, you must use the <version>-full docker image tag as the standard image does not bundle the binary.

  6. How Datashim relates to CSI and COSI

    master

    Datashim is designed as a meta-framework for CSI plugins rather than a replacement for them.

    • Relationship to CSI: Datashim sits on top of existing CSI implementations. Every data source supported by Datashim uses its own standalone CSI driver. Datashim simplifies the user experience by automating the invocation and configuration of these drivers.
    • Relationship to COSI: Datashim does not compete with the Container Object Storage Interface (COSI) proposal. While COSI manages the full lifecycle of a bucket (provisioning, access configuration, etc.), Datashim focuses specifically on providing a mount-point for existing COS buckets.
  7. Mount a Dataset to a Kubernetes Pod

    master

    To mount a Datashim Dataset into a Pod, add specific labels to the Pod's metadata. The labels follow the pattern dataset.<index>.id and dataset.<index>.useas.

    For example, to mount a dataset named model-weights as a volume, use:

    • dataset.0.id: "model-weights"
    • dataset.0.useas: "mount"

    Once mounted, the files from the object storage bucket will be available at /mnt/datasets/<dataset-name>/ within the container.

    apiVersion: v1
    kind: Pod
    metadata:
      name: text-generation-inference
      labels:
        dataset.0.id: "model-weights"
        dataset.0.useas: "mount"
    spec:
      containers:
        - name: text-generation-inference
          # ...
  8. How Datashim works

    master

    Datashim is a Kubernetes framework that provides easy access to S3 and NFS Datasets within pods. It uses a Dataset Custom Resource Definition (CRD) which acts as a pointer to existing S3 or NFS data sources.

    When you define a Dataset, Datashim orchestrates the provisioning of the necessary Persistent Volume Claims (PVCs) and ConfigMaps. This allows users to reference datasets in their pods without manually configuring, mounting, or tuning data access. The system is extensible via the Container Storage Interface (CSI) to support additional data sources.

  9. Create a feature branch and submit a Pull Request

    master

    Datashim follows a workflow similar to the Kubernetes project:

    1. Issue Creation: Before starting work, create an issue in the main Datashim repository describing the feature or fix. Assign the issue to yourself and note the issue number (nnn).
    2. Branching: Create a new branch using the pattern nnn-short-title, where nnn is the issue number and short-title is a 2-3 word summary of the issue.
    3. Committing: Make your changes and commit them. Note: You must always sign your commits.
    4. Pushing: Push your branch to your personal fork.
    5. Pull Request: Visit your fork on GitHub and click Compare and Pull Request to submit your changes for review.
    6. Finalizing: After review, squash your commits to prepare the PR for merging.
    # Create a branch named after an issue (e.g., issue 123)
    git checkout -b 123-short-title
    
    # Commit with a signed signature (-s)
    git commit -s -m "short descriptive message"
    
    # Push to your fork
    git push $your_remote 123-short-title
  10. Enable Pod Labeling Functionality

    master

    To use the pod labeling method (e.g., dataset.0.id), you must label the namespace(s) where your pods reside to enable the Datashim pod labeling functionality.

    Example for the default namespace:

    kubectl label namespace default monitor-pods-datasets=enabled
  11. Build a model container for TFJob

    master

    To run a distributed training job as a TFJob, you must build a Docker image containing your model code (e.g., model.py) and a Dockerfile. Use the following commands to build and push the image to your registry:

    cd examples/kubeflow
    docker build -t {MY-REGISTRY}/mnist-model -f Dockerfile.model .
    docker push {MY-REGISTRY}/mnist-model

    If using an authenticated registry, ensure your Docker credentials are configured.

  12. Create a Datashim Dataset from Object Storage

    master

    To access data stored in an S3-compatible bucket, you must perform two steps:

    1. Create a Kubernetes Secret containing your access credentials (accessKeyID and secretAccessKey).
    2. Create a Dataset object of type COS that references that secret and defines the bucket and endpoint.

    In the example, the Dataset is named model-weights and uses the local.provision: "true" setting to enable mounting.

    apiVersion: v1
    kind: Secret
    metadata:
      name: model-weights-secret
    stringData:
      accessKeyID: "ACCESS_KEY"
      secretAccessKey: "SECRET_KEY"
    ---
    apiVersion: datashim.io/v1alpha1
    kind: Dataset
    metadata:
      name: model-weights
    spec:
      local:
        provision: "true"
        bucket: my-model
        endpoint: http://minio.minio.svc.cluster.local:9000
        secret-name: model-weights-secret
        type: COS