Skip to content

Create a cluster#

After you install k0smotron as described in the Installation section, you can start creating your Kubernetes control planes.

To create a cluster:

  1. Create the Cluster object:

    cat <<EOF | kubectl create -f-
    apiVersion: k0smotron.io/v1beta1
    kind: Cluster
    metadata:
       name: <cluster-name>
    spec: null
    EOF
    

    This triggers the k0smotron controller manager to set up the control plane in pods.

  2. Once k0smotron finishes setting up the cluster, obtain the admin access kubeconfig:

    kubectl get secret <cluster-name>-kubeconfig -o jsonpath='{.data.value}' | base64 -d > ~/.kube/child.conf
    

    Depending on your configuration, the admin kubeconfig may not be pointing to the correct address. If the kubeconfig does not work by default, set the correct value for <server-URL>:

    apiVersion: v1
    clusters:
    - cluster:
        server: <server-URL>
        certificate-authority-data: <redacted>
      name: k0s
    contexts:
    - context:
        cluster: k0s
        user: admin
      name: k0s
    current-context: k0s
    kind: Config
    preferences: {}
    users:
    - name: admin
      user:
        client-certificate-data: <redacted>
        client-key-data: <redacted>
    

Once your control plane is ready, you can start joining worker nodes into the newly created control plane.