Skip to content

openloft/openloft

Repository files navigation

OpenLoft

License Makefile CI Go Report Card GitHub last commit (branch)


Quick Start (~ 1 minute)

1. Prerequisites

  • Setup a Kubernetes cluster with kind.

    git clone https://github.com/openloft/kind.git
    cd kind
    # Create a cluster with 1 control-plane node and 2 worker nodes,
    # install nginx ingress controller and
    # deploy fake device plugin to provision 8 NVIDIA GPUs on each worker node.
    just a
  • Deploy vCluster Operator.

    kubectl apply -f https://raw.githubusercontent.com/openloft/vcluster-operator/main/deploy/manifests.yaml

2. Deploy OpenLoft

kubectl apply -f https://raw.githubusercontent.com/openloft/openloft/main/deploy/manifests.yaml

3. Create a Cluster Domain

kubectl apply -f https://raw.githubusercontent.com/openloft/openloft/main/config/samples/storage_v1_clusterdomain.yaml

4. Create a vCluster Template

There are two types of vCluster templates in sample, isolated and default. The isolated template will create a vCluster with a resource quota. The default template will create a vCluster with no resource quota.

The below command will create a isolated vCluster template.

kubectl apply -f https://raw.githubusercontent.com/openloft/openloft/main/config/samples/isolated/storage_v1_virtualclustertemplate.yaml

5. Create a vCluster Instance

kubectl apply -f https://raw.githubusercontent.com/openloft/openloft/main/config/samples/isolated/storage_v1_virtualclusterinstance.yaml

By running the above command, a vCluster called isolated-sample would be created in the namespace vc-isolated-sample.

6. Retrieving the kube config from the vCluster secret

The secret is prefixed with vc- and ends with the vCluster name, so a vCluster instance called isolated-sample would create a secret called vc-isolated-sample in the namespace vc-isolated-sample. You can retrieve the kube config after the vCluster has started via:

kubectl get secret vc-isolated-sample -n vc-isolated-sample --template={{.data.config}} | base64 -D > kubeconfig.yaml

The secret will hold a kube config in this format:

apiVersion: v1
clusters:
- cluster:
    certificate-authority-data: LS0t...
        server: https://isolated-sample.openloft.cn
  name: my-vcluster
contexts:
- context:
    cluster: my-vcluster
    user: my-vcluster
  name: my-vcluster
current-context: my-vcluster
kind: Config
preferences: {}
users:
- name: my-vcluster
  user:
    client-certificate-data: LS0tLS...
    client-key-data: LS0tLS...

To be able to access the vCluster, update the hosts file with 127.0.0.1 pointing to the vCluster ingress:

e.g. /etc/hosts on macOS/Linux:

127.0.0.1 isolated-sample.openloft.cn

7. Accessing the vCluster

You can access the vCluster via:

kubectl --kubeconfig kubeconfig.yaml get ns

Contributing