This is unreleased documentation for SUSE® Virtual Clusters v1.3.0 (Dev).

How to: Create an HCP (Hosted Control Plane) Virtual Cluster

In HCP (Hosted Control Plane) mode, K3k runs an agentless K3s control plane inside the host cluster, while you provide your own external worker nodes that join the cluster using the standard K3s installer script.

This is different from shared and virtual modes:

  • In shared mode, workloads run on the host cluster through the Virtual Kubelet.

  • In virtual mode, both the control plane and worker nodes run as pods inside the host cluster.

  • In hcp mode, only the control plane runs inside the host cluster — worker nodes live outside it, on machines that you manage.

See Architecture: HCP Mode for a deeper explanation, and Choosing a Mode for guidance on when to pick HCP.

You can create an HCP virtual cluster with a Cluster resource, with k3kcli, or from the SUSE® Rancher Prime UI. For the UI flow, see Create an HCP virtual cluster from the Rancher UI.

Prerequisites

  • A K3k controller installed on the host cluster (see Quick Start).

  • An externally reachable endpoint for the virtual cluster’s apiserver, exposed via nodePort, loadBalancer, or ingress. Without one, the apiserver is only reachable from inside the host cluster and external workers won’t be able to join.

  • One or more external Linux machines that can reach that endpoint over the network. They need curl and systemd, the same as a standard K3s installation.

  • Each external worker must have a unique hostname and a unique routable IP. Workers behind NAT that share the same address will register as a single node.

Step 1: Create the HCP cluster

CRD Method

apiVersion: k3k.io/v1beta1
kind: Cluster
metadata:
  name: hcp-server
spec:
  mode: hcp
  tlsSANs:
    - "<externally-reachable-node-ip-or-dns>"
  servers: 1
  version: v1.33.1-k3s1
  expose:
    nodePort: {}

The tlsSANs field MUST include at least one non-loopback host (IP or DNS) that your external workers can reach. This entry is added to the apiserver certificate so workers can establish a TLS connection.

One of expose.nodePort, expose.loadBalancer, or expose.ingress is required so the apiserver is reachable from outside the host cluster.

agents is not used in HCP mode — worker nodes are external and join via the K3s installer.

CLI Method

k3kcli cluster create \
  --mode hcp \
  --tls-sans <externally-reachable-node-ip-or-dns> \
  hcp-server

The CLI waits for the cluster to become ready and adds a <namespace>/hcp-server context to your current kubeconfig. It then prints the instructions you’ll need for Steps 2 and 3.

Step 2: Fetch the join token

The join token is stored in a Secret in the cluster’s namespace and is intentionally not embedded in CLI output. Retrieve it with:

kubectl get secret -n <namespace> <cluster-name>-token -o jsonpath='{.data.token}' | base64 -d

The token secret is named <cluster-name>-token. For the example above it would be hcp-server-token.

k3kcli cluster create and k3kcli kubeconfig generate print the exact command for your cluster, with the correct namespace and secret name. The command is printed after the context is added to your kubeconfig.

Step 3: Join an external worker

On each external worker machine, run:

curl -sfL https://get.k3s.io | K3S_URL=<serverURL> K3S_TOKEN=<TOKEN> sh -

Substitute:

  • <serverURL> — the externally reachable apiserver URL. This is the server: value in the generated kubeconfig, and k3kcli prints the exact K3S_URL=…​ to use. The port depends on how you exposed the apiserver: the assigned NodePort for nodePort (for example https://203.0.113.10:30001), or the host on 443 for loadBalancer/ingress.

  • <TOKEN> — the value retrieved in Step 2.

Repeat on each worker you want to join. Make sure each one has a unique hostname; cloud-init’s set-hostname or the --node-name flag to the K3s installer both work.

Verify

List the nodes of the virtual cluster using the context that k3kcli cluster create added to your kubeconfig:

kubectl --context <namespace>/hcp-server get nodes

If the context is missing, add it with k3kcli kubeconfig generate --no-out <namespace>/hcp-server. For more information, see Managing kubeconfig contexts.

Each external worker should appear in the output with status Ready.

Create an HCP virtual cluster from the Rancher UI

The Virtual Clusters UI extension for SUSE® Rancher Prime can provision an HCP virtual cluster and display the registration command for your external worker nodes. The result is the same as with the CLI and CRD methods:

  • The control plane runs in the host cluster.

  • The API server is exposed outside the host cluster.

  • You join external worker nodes with the K3s installer.

Prerequisites

  • SUSE® Rancher Prime. The Virtual Clusters UI extension is only available in SUSE® Rancher Prime.

  • The Virtual Clusters UI extension installed, at a version that includes HCP mode. The v1.3.0 extension requires SUSE® Rancher Prime v2.16.0 or later.

  • A host cluster managed by SUSE® Rancher Prime with the K3k controller v1.2.0 or later installed. The HCP (Hosted Control Plane) mode option is not shown for host clusters that run an earlier K3k version.

  • Permission to read resources in the host cluster. The registration command is read from the host cluster. Without access, the Registration tab shows You do not have access to the host cluster, so the registration command cannot be shown.

  • External Linux machines that meet the requirements listed in Prerequisites.

Create the cluster

  1. In SUSE® Rancher Prime, select Cluster Management  Clusters and click Create.

  2. Under Create a Virtual Cluster, click K3K.

  3. Enter a name for the cluster.

  4. In the Basics section, configure the following fields:

    1. Host cluster: select the host cluster that runs the K3k controller.

    2. Virtual Cluster Policy: select No policy, or a policy whose allowed mode is HCP.

      When you select a policy, the Virtual cluster mode option is hidden and the policy sets the mode.

    3. K3s Version: optionally select a K3s version.

      By default, the virtual cluster uses the same Kubernetes version as the host cluster.

    4. Virtual cluster mode: select HCP (Hosted Control Plane).

      In HCP mode, the form shows Not available in HCP mode for settings that do not apply to external worker nodes. These settings include Resource Synchronization, Agents, and Agent Scheduling.

  5. In the Server and Agents section, under Server, set Number of Server Pods.

    This field corresponds to spec.servers. Agent pod settings are not available, because worker nodes are external.

  6. In the Networking section, under Certificates, click Add alternative name.

  7. Enter a non-loopback IP address or DNS name of the host cluster that your external workers can reach.

    This value is added to spec.tlsSANs.

    Workers need a reachable TLS Subject Alternative Name

    External workers only accept the API server certificate for hosts listed in the TLS Subject Alternative Names. Without a reachable entry, workers fail TLS verification and cannot join.

    Add at least one non-loopback host that the workers can reach.

  8. Under Direct API Server Exposure, select Ingress, Load Balancer, or Node Port.

    HCP mode requires one of these options. If you leave Not Exposed selected, the form shows In HCP mode, worker nodes outside the host cluster must be able to reach the API server. Select Ingress, Load Balancer or Node Port.

    • Node Port: optionally set Server Port.

    • Load Balancer: optionally set Server Port. A custom server port requires K3k v1.3.0 or later on the host cluster. With earlier versions, the field is disabled.

    • Ingress: set Ingress Class Name. With this option, TLS Subject Alternative Names is mandatory.

  9. Optionally, configure the remaining sections, such as Topology > Server Scheduling and Advanced.

  10. Click Create.

After the cluster is created, SUSE® Rancher Prime opens the cluster detail page instead of the cluster list.

Register external worker nodes

  1. On the cluster detail page, select the Registration tab.

    This tab is only shown for HCP virtual clusters.

    While the cluster provisions, the tab shows Waiting for the virtual cluster to provision. The command will be available when its token, K3s version and server address are ready. The command is displayed automatically when it is ready.

  2. Optionally, expand Advanced command options to add per-node settings to the command. These values often differ for each node, so update them before you copy the command for each worker:

    • Node name: adds --node-name.

    • Node public IP: adds --node-external-ip.

    • Node private IP: adds --node-ip.

    • Node labels: click Add node label to add --node-label key=value.

    • Taints: click Add taint to add --node-taint key=value:effect. The default effect is NoSchedule.

    • Insecure: adds --insecure to curl, which skips TLS verification when downloading the install script.

  3. Click the command under Registration command to copy it.

    Do not select the command text manually. A manual selection can join the arguments without spaces.

    The command has the following form:

    curl -sfL https://get.k3s.io | INSTALL_K3S_VERSION=<k3s-version> K3S_URL=https://<host>:<port> K3S_TOKEN=<token> sh -
    • INSTALL_K3S_VERSION matches the K3s version of the virtual cluster.

    • <host> is the load balancer address when the API server is exposed with Load Balancer. Otherwise, it is the first non-loopback entry of the TLS Subject Alternative Names. If there is no such entry, it is the internal IP of a host node that runs a server pod. This IP must be listed in the server certificate.

    • <port> is the node port when the API server is exposed with Node Port. Otherwise, it is the service port.

    • <token> is the join token of the virtual cluster. You do not need to retrieve it from the Secret.

  4. Run the copied command on each external Linux machine you want to register. Only worker nodes can be registered.

If the UI finds no address that external workers can reach, the tab shows No server address reachable by external workers was found. Expose the API server with an ingress, load balancer or node port, and add an address the workers can reach to the virtual cluster’s TLS SANs. Edit the cluster to add an exposure option or a TLS Subject Alternative Name.

Verify

  1. In SUSE® Rancher Prime, open the virtual cluster and go to its Nodes list.

  2. Confirm that each external worker is listed and runs the expected K3s version.

You can also download the kubeconfig of the virtual cluster from SUSE® Rancher Prime and run kubectl get nodes. Each external worker should be listed with status Ready.

Troubleshooting

No external endpoint configured
If the Cluster spec has no expose.nodePort, expose.loadBalancer, or expose.ingress, the apiserver is only reachable from inside the host cluster and external workers can’t join. Add one of those expose options, and make sure tlsSANs includes the external host the workers use.

Workers can’t connect to the apiserver
Confirm that tlsSANs contains the exact host the workers use to reach the apiserver, and that the host:port is reachable from the worker network. A TLS handshake error or x509: certificate is valid for …​, not …​ message in journalctl -u k3s-agent indicates a missing SAN.

Multiple workers register as a single node
The workers are sharing an IP (typically NAT). Give each worker a unique routable IP on a network segment the apiserver can reach back to, and a unique hostname.

Need a fresh kubeconfig or to re-print the join instructions
Run k3kcli kubeconfig generate <namespace>/<cluster> again — the context in your kubeconfig is updated and the join instructions are re-printed each time.