1. Xelon Docs
  2. Kubernetes Service

Storage Solution: Xelon CSI

In this article, you’ll get an overview of the Xelon Container Storage Interface (Xelon CSI).

Intro

The Xelon Container Storage Interface (CSI) is an in-house developed solution that allows Cloud providers, like us, to seamlessly integrate with Kubernetes storage. It provides an easy-to-use storage solution for stateful workloads in Kubernetes. You can find the source code and latest releases on GitHub: GitHub - Xelon

This service is currently in early-access mode. Please contact us to get access.

Prerequisists

There are no prerequisites, as we pre-deploy all necessary configurations to your Xelon Kubernetes cluster. However, if you prefer to run your own Kubernetes distribution in our Cloud, you can still set up this CSI for a straightforward storage solution.

Components

The Xelon CSI has two main components, which are described below. Additionally, the Xelon CSI must authenticate with Xelon HQ using credentials stored in the secret named “xelon-api-credentials” in the kube-system namespace.

Statefulset: xelon-csi-controller

The Xelon CSI controller listens for events from the kube-apiserver related to volumes. It uses this metadata to send instructions to the HQ management platform or the xelon-csi-node component. These instructions can include actions such as moving a disk from one node to another, resizing a volume, creating a new volume, and more.

Daemonset: xelon-csi-node

The Xelon CSI Node is a daemon set that runs on all worker nodes, responsible for mounting volumes and performing other crucial tasks. It not only attaches volumes to the nodes but also manages operations such as resizing, creating, and deleting volumes. Additionally, it communicates with the Xelon HQ management platform to execute commands and monitors volume health to ensure smooth and reliable storage operations within the Kubernetes cluster.

How to use the Xelon CSI

1. To ensure you have the "xelon-persistent-storage" available on your cluster, run the following command: kubectl get storageclasses


2. Deploy the following manifest using:

kubectl apply -f <filename>
Here's the manifest:
apiVersion: apps/v1
kind: Deployment
metadata:
  name: code-server
spec:
  replicas: 1
  strategy:
    type: Recreate
  selector:
    matchLabels:
      app: code-server
  template:
    metadata:
      labels:
        app: code-server
    spec:
      containers:
      - name: code-server
        image: lscr.io/linuxserver/code-server:latest
        env:
        - name: PUID
          value: "1000"
        - name: PGID
          value: "1000"
        - name: TZ
          value: "Europe/Zurich"
        - name: PASSWORD
          value: "password" #optional
        - name: SUDO_PASSWORD
          value: "sudopassword" #optional
        - name: DEFAULT_WORKSPACE
          value: "/config/workspace" #optional
        ports:
        - containerPort: 8443
          name: https
        volumeMounts:
        - mountPath: /config
          name: code-server-config
      restartPolicy: Always
      volumes:
      - name: code-server-config
        persistentVolumeClaim:
          claimName: code-server-pvc

---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: code-server-pvc
spec:
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 5Gi
  storageClassName: "xelon-persistent-storage"

---
apiVersion: v1
kind: Service
metadata:
  name: code-server-service
spec:
  type: ClusterIP
  ports:
  - port: 8443
    targetPort: 8443
    protocol: TCP
    name: https
  selector:
    app: code-server

This manifest creates three resources:

a. Deployment runs the Visual Studio Code server (accessible via a web browser) and mounts a volume at /config.

b. PersistentVolumeClaim rerequests a 5Gi volume, which will be created by the Xelon CSI if it doesn’t already exist.

c. Service a allows access to the VS Code server. Forward the service port to your machine with:

kubectl port-forward svc/code-server-service 8443:8443

You can now access the VS Code instance at http://localhost:8443 using the password set in the environment variables.


How to test the volume migration

Here’s a step-by-step guide to ensure your volume migration is successful:


1. Create a File in VS Code:

  • Open the VS Code instance in your browser at http://localhost:8443.
  • Create a new file and add some content.
  • Save the file to ensure it is stored in the persistent volume.

2. Drain the Node:

  • List the pods and their nodes to identify where the VS Code instance is running:
kubectl get pods -o wide
  • Drain the node where the VS Code instance is running:
kubectl drain <node name> --delete-emptydir-data --ignore-daemonsets

3. Reopen Port-Forward:

Since the endpoint will be migrated, you need to set up port-forwarding again:

kubectl port-forward svc/code-server-service 8443:8443

4. Verify File Existence:

Access the VS Code instance again at http://localhost:8443 and check if the file you created earlier still exists. This indicates that the volume has successfully migrated.

5. Verify Pod Location:

  • Check which node the VS Code pod is now running on:

kubectl uncordon <node name>

6. Uncordon the Previously Drained Node:

  • Once the migration is confirmed, you can uncordon the previously drained node to make it schedulable again:
kubectl uncordon <node name>

 

Limitations: Currently, Xelon CSI volumes only support the "ReadWriteOnce" access mode. This means that each volume can be attached to only one pod at a time.