Show examples as

Kubernetes

Showing CLI examples. Use the toggle above for YAML or Terraform.

Showing YAML manifests. Use the toggle above for CLI or Terraform.

Showing Terraform examples from provider kcorehypervisor/kcore 0.8.0. Day-2 CA rotation and etcd backup are kctl only.

kcore creates a Kubernetes cluster on nodes that are already members of the kcore cluster. The first apply stores the cluster, generates certificates, and deploys kubelet, etcd, and the API server. Put every member in that first manifest.

Addresses on this page are examples. Pick free addresses on your own network.

Create a cluster

Apply needs cluster-admin. kctl prints the plan, including blocking issues, then asks y/n. Answering y creates the cluster. A later apply of the same name updates it. There is no flag-only create. The manifest is the input.

kctl kubernetes apply -f cluster.yaml
kctl kubernetes get lab
kctl kubernetes list
kctl kubernetes health lab

The manifest below is the whole cluster. Apply it with kctl kubernetes apply -f cluster.yaml (or kctl apply -f; both route this kind).

One resource for create and upgrade: kcore_kubernetes_cluster. Set version (for example 1.36.6) and apply; change version and apply again to upgrade in place. Do not use kcore_cluster_version or kcore_cluster_update here — those roll the kcoreOS hosts, not Kubernetes.

resource "kcore_kubernetes_cluster" "lab" {
  name                      = "lab"
  cluster_cidr              = "10.244.0.0/16"
  service_cidr              = "10.96.0.0/12"
  api_server_endpoint       = "192.168.40.220:6443"
  schedule_on_control_plane = true
  version                   = "1.36.6"

  control_plane_node {
    node_id           = "node-107"
    advertise_address = "192.168.40.107"
    initial_cluster   = true
  }

  cilium {
    load_balancer_ip_pool = ["192.168.40.220/29"]
  }

  local_provisioner {
    enabled            = true
    mode               = "shared"
    storage_class_name = "local-path"

    volume {
      name          = "kcore-kdata"
      node_id       = "node-107"
      storage_class = "lvm"
      size_bytes    = "53687091200"
      fs_type       = "ext4"
      role          = "filesystem"
    }
  }
}
kind: KubernetesCluster
metadata:
  name: lab
spec:
  version: "1.36.6"
  clusterCidr: 10.244.0.0/16
  serviceCidr: 10.96.0.0/12
  clusterDns: 10.96.0.10
  apiServerEndpoint: 192.168.40.200:6443
  cni: cilium
  cilium:
    mode: native-routing
    mtu: 1500
    tunnel: disabled
    autoDirectNodeRoutes: true
    loadBalancerIpPools:
      - 192.168.40.220/29
  controlPlaneNodes:
    - nodeId: node-105
      advertiseAddress: 192.168.40.105
      iface: enp6s0
    - nodeId: node-107
      advertiseAddress: 192.168.40.107
      iface: enp6s0
  workerNodes:
    - nodeId: node-103
      advertiseAddress: 192.168.40.103
      iface: enp6s0
  highAvailability:
    enabled: true
    vipAddress: 192.168.40.200
    vipInterface: enp6s0
  scheduleOnControlPlane: true
  localProvisioner:
    enabled: true
    storageClassName: local-path
    mode: shared
    volumes:
      - name: kcore-kdata
        nodeId: node-105
        storageClass: lvm
        sizeBytes: 53687091200
        fsType: ext4
        role: filesystem
      - name: kcore-kdata
        nodeId: node-107
        storageClass: lvm
        sizeBytes: 53687091200
        fsType: ext4
      - name: kcore-kdata
        nodeId: node-103
        storageClass: lvm
        sizeBytes: 53687091200
        fsType: ext4

kind: kubernetes-cluster and kind: kubernetes_cluster are accepted. Fields are camelCase.

What create does

Fields

FieldDescription
metadata.nameCluster name.
spec.versionDesired Kubernetes version (for example 1.36.6). Empty uses the host nixpkgs pin (1.35.2 today). Allowed values come from modules/kubernetes-releases.json. Changing it and re-applying upgrades the cluster in place.
spec.clusterCidrPod CIDR. Required.
spec.serviceCidrService CIDR. Required.
spec.clusterDnsCluster DNS address. Default 10.96.0.10.
spec.apiServerEndpointhost:port of the API. Required. Use the VIP when high availability is on.
spec.cniDefault cilium. A port other than 6443 is stored as bridge.
spec.ciliummode, mtu, tunnel, autoDirectNodeRoutes, and loadBalancerIpPools. Defaults are native-routing, 1500, disabled, true, and an empty list. The controller installs Cilium. When the list is not empty, it also applies the pool and the L2 policy.
controlPlaneNodesnodeId, advertiseAddress, and iface (default enp6s0). The first entry bootstraps etcd.
workerNodesSame node fields. Stored as join members.
highAvailabilityenabled, vipAddress, and vipInterface. kctl sets the method to keepalived.
scheduleOnControlPlaneWhen true, control-plane nodes accept pods.
localProvisionerenabled, storageClassName (default local-path), mode (shared or lvm), and volumes. The filesystem behind local-path is a kcore volume in this list. A TopoLVM data volume stays out of this list and is managed in Kubernetes only.

API VIP

highAvailability.enabled starts keepalived on each control plane. Point apiServerEndpoint at vipAddress and the API port. vipAddress and vipInterface are both required when high availability is on.

keepalived does not probe TCP 6443. The VIP moves when advertisements stop, which is when keepalived is down. If only kube-apiserver exits and keepalived stays up, the VIP stays on that node.

When the controller has generated a kubeconfig, the control plane writes it to /etc/kubernetes/admin.conf. Use that file with kubectl. The server is the API endpoint, which is the VIP when high availability is on.

Cilium L2 load balancer

The controller installs Cilium on the primary cluster after the API is ready. The control-plane unit kcore-kubernetes-cilium runs cilium install, then applies CiliumLoadBalancerIPPool and CiliumL2AnnouncementPolicy when loadBalancerIpPools is set. Defaults are native routing, MTU 1500, tunnel disabled, and autoDirectNodeRoutes. A second cluster on the same hosts does not get Cilium.

The host does not run kube-proxy. The install sets kube-proxy replacement, Kubernetes IPAM, and the API address from apiServerEndpoint. Native routing uses clusterCidr. L2 announcements are enabled only when loadBalancerIpPools is not empty. Policy interfaces are the node ifaces. An empty iface is enp6s0. The chart is the one shipped with cilium-cli.

cilium install --namespace kube-system
  --set ipam.mode=kubernetes
  --set kubeProxyReplacement=true
  --set bpf.masquerade=true
  --set routingMode=native
  --set autoDirectNodeRoutes=true
  --set ipv4NativeRoutingCIDR=10.244.0.0/16
  --set mtu=1500
  --set l2announcements.enabled=true
  --set k8sServiceHost=192.168.40.200
  --set k8sServicePort=6443
  --set devices[0]=enp6s0
apiVersion: cilium.io/v2
kind: CiliumLoadBalancerIPPool
metadata:
  name: kcore
spec:
  blocks:
    - cidr: 192.168.40.220/29
---
apiVersion: cilium.io/v2alpha1
kind: CiliumL2AnnouncementPolicy
metadata:
  name: kcore
spec:
  interfaces:
    - enp6s0
  loadBalancerIPs: true

In Terraform, set cilium { load_balancer_ip_pool = […] } on kcore_kubernetes_cluster (see Create above). The controller installs Cilium and applies the L2 CRDs; those CRDs are not Terraform resources.

The pool and the policy are both named kcore. This example uses 192.168.40.220/29. Pick a range that does not overlap the VIP or node addresses. A service is announced when loadBalancerClass is empty or io.cilium/l2-announcer. interfaces is a regular expression. The controller writes this manifest to /etc/kubernetes/cilium-l2.yaml and applies it.

Volumes, LVM and ZFS

Pods get disk in one of two ways.

localProvisioner.enabled is required when volumes are listed. Mode empty or shared is the default. Mode lvm is a thin pool and does not serve claims.

kcore volumes

kcore installs the Rancher local-path provisioner. A claim is a directory on a filesystem. That filesystem is a kcore volume in this manifest. Do not create it with kubectl. Do not point local-path at a directory you mounted yourself.

Shared mode creates one LVM logical volume or one ZFS zvol on the named node, formats it, and mounts it. storageClass is lvm or zfs, and the node's storage backend must already be that class. sizeBytes must be positive. An empty fsType becomes ext4. The other accepted value is xfs. An empty role becomes filesystem. The default mount path is /mnt/kcore/<cluster>/<name>.

The node must already be a member of the cluster. The same volume name may be listed on different nodes. The same name twice on one node is rejected. Two volumes on one node cannot share a mount path. After the volume is formatted, a later change of fsType is rejected.

The control plane then applies the Rancher local-path provisioner, image rancher/local-path-provisioner:v0.0.30, from /etc/kubernetes/provisioner.yaml. The oneshot unit is kcore-kubernetes-provisioner. The StorageClass name defaults to local-path. A claim is a directory on that filesystem. The size on the claim is not a quota. To give the directories more room, raise sizeBytes and apply again. Shrinking is rejected. Another volume adds a path to the same StorageClass. It does not create a second StorageClass.

The controller volume name is k8s-<cluster>-<node>-<volume>. The LVM device is /dev/<vg>/<lv>. The ZFS device is /dev/zvol/<pool>/<dataset>.

A ZFS volume uses the same shared provisioner. Set storageClass to zfs on a node whose storage backend is zfs.

      - name: kcore-kdata
        nodeId: node-103
        storageClass: zfs
        sizeBytes: 53687091200
        fsType: ext4

The StorageClass uses volumeBindingMode: WaitForFirstConsumer. The helper creates the claim directory with mode 0777. Deleting the claim deletes that directory. The kcore volume stays mounted. The storage request is recorded and is not a quota.

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: app-data
spec:
  accessModes:
    - ReadWriteOnce
  storageClassName: local-path
  resources:
    requests:
      storage: 10Gi
kubectl apply -f pvc.yaml

PersistentVolumeClaims are Kubernetes objects, not a kcore_* resource. Apply them with kubectl against the cluster kubeconfig.

TopoLVM

Leave that data out of localProvisioner.volumes. Install TopoLVM yourself and manage the data volume with Kubernetes only. kcore does not install TopoLVM and does not create its StorageClass or its pool.

Make the pool with TopoLVM, or with LVM on the node, outside this API. kcore deletes only volumes it created. A logical volume TopoLVM creates is left in place. Install TopoLVM on the primary cluster, the one whose API port is 6443, where pods can reach ClusterIP. An extra cluster uses a bridge and has no kube-proxy, so a chart that calls ClusterIP will not work there. One TopoLVM owns a volume group. A second copy on another cluster on the same hosts would manage the same disks.

mode lvm

mode: lvm creates one thin pool of the declared size. Nothing in Kubernetes consumes that pool. This mode does not install local-path and it is not TopoLVM. Do not use this pool as TopoLVM's pool. Every listed node must use the same name, volume group, size, and filesystem. The role is pool. volumeGroup is required. Leave mountPath empty.

localProvisioner:
  enabled: true
  mode: lvm
  storageClassName: kcore-lvm
  volumes:
    - name: kcore-kdata
      nodeId: node-105
      storageClass: lvm
      sizeBytes: 53687091200
      role: pool
      volumeGroup: vg_kcore

Those volumes are fields of the Kubernetes manifest. In Terraform they are volume blocks inside local_provisioner on kcore_kubernetes_cluster. kcore_volume is a VM data disk, not this local-path filesystem. Example from the provider docs:

resource "kcore_kubernetes_cluster" "pools" {
  name                = "pools"
  cluster_cidr        = "10.245.0.0/16"
  service_cidr        = "10.112.0.0/12"
  api_server_endpoint = "192.168.40.201:7443"

  control_plane_node {
    node_id           = "node-105"
    advertise_address = "192.168.40.105"
    initial_cluster   = true
  }

  high_availability {
    enabled       = true
    vip_address   = "192.168.40.201"
    vip_interface = "enp6s0"
  }

  local_provisioner {
    enabled            = true
    mode               = "lvm"
    storage_class_name = "kcore-lvm"

    volume {
      name          = "kcore-kdata"
      node_id       = "node-105"
      storage_class = "lvm"
      size_bytes    = "53687091200"
      role          = "pool"
      volume_group  = "vg_kcore"
    }
  }
}

Kubernetes version

Set spec.version on the same KubernetesCluster manifest. Re-apply with kctl kubernetes apply -f. The controller rolls control planes first, then workers, one node at a time (drain when the node runs pods). Empty version means the host nixpkgs pin. Same resource for create and upgrade. Do not use kcore_cluster_version, kcore_cluster_update, or kind: ClusterUpdate — those are host / kcore OS rollouts. See Host & kcore upgrades.

kind: KubernetesCluster
metadata:
  name: lab
spec:
  version: "1.36.6"
  # …rest of the cluster unchanged…
resource "kcore_kubernetes_cluster" "lab" {
  # …
  version = "1.36.6"
}
# Edit version in the manifest, then:
kctl kubernetes apply -f cluster.yaml
kctl kubernetes get lab

Shipped allowlist today: 1.35.10, 1.36.6, 1.37.2 (plus empty → host pin 1.35.2). Skipping a minor or downgrading needs --force on apply.

Re-apply and scale

A second kctl kubernetes apply updates CIDRs, DNS, the API endpoint, CNI, Cilium settings, the VIP, local volumes, scheduleOnControlPlane, and version. It redeploys node certificates and node configuration. It does not change cluster membership by itself. Success returns the phase to ready when the previous phase was updating or degraded. A volume or deploy error sets the phase to degraded.

kctl kubernetes scale --add-control-plane node-id:address and --add-workers node-id:address record those members and set the phase to scaling. The interface on that command is fixed to enp6s0. The orchestrator only bootstraps clusters in phase bootstrapping, so a scale does not join the new nodes. If the existing etcd quorum and API are already healthy, the phase is set back to ready without adding those nodes. --remove logs the node id and does not delete the membership row. Put every member in the first manifest.

Day-2 operations

After the cluster is ready, use these commands for certificates, backups, and health. Membership is still fixed at create; see Limits.

Dual-CA rotation

Replace the Kubernetes cluster CA (and by default the etcd CA) without a hard cutover. Nodes get a trust bundle that holds the old CA then the new one. --cluster-signing-cert-file stays a single active CA that matches ca.key. There is no Terraform resource for this; use kctl.

# Optional: take an etcd snapshot first (uses the cluster backup policy target)
kctl kubernetes backup create lab

kctl kubernetes rotate-ca lab --step begin --yes
kctl kubernetes certs lab
# Wait until the control-plane-first roll finishes

kctl kubernetes rotate-ca lab --step reissue --yes
kctl kubernetes certs lab

kctl kubernetes rotate-ca lab --step retire --yes
kctl kubernetes certs lab

etcd backups

Configure a backup policy on the cluster with spec.backup (stored as JSON). Targets are local, ceph_volume, or s3. Then take or list snapshots with kctl. There are no --s3-bucket flags on the backup commands.

spec:
  backup:
    interval_secs: 3600
    retain_count: 7
    retain_days: 14
    target:
      kind: s3
      bucket: my-backups
      prefix: etcd/
      credentials_file: /etc/kcore/s3-creds
      endpoint: ""
kctl kubernetes backup create lab
kctl kubernetes backup list lab
kctl kubernetes backup delete lab <snapshot-id> --yes

kctl kubernetes restore exists in the CLI but is not wired yet; the command returns an error until restore ships.

VolumeSnapshot CSI

The controller embeds the VolumeSnapshot CSI CRDs and applies them with the cluster. Use them with a CSI driver that implements snapshots (for example Ceph CSI on a CephCluster). See kcore SAN CSI.

Commands

OperationCommand
Applykctl kubernetes apply -f cluster.yaml
Getkctl kubernetes get lab
Listkctl kubernetes list
Healthkctl kubernetes health lab
Certificateskctl kubernetes certs lab
Rotate leaf certskctl kubernetes rotate-certs lab --yes
Rotate CA (dual-CA)kctl kubernetes rotate-ca lab --step begin|reissue|retire --yes
Rotate encryptionkctl kubernetes rotate-encryption lab --yes
etcd backupkctl kubernetes backup create|list|delete lab …
Upgrade rollbackkctl kubernetes upgrade rollback lab --yes
Replace a memberkctl kubernetes replace-node lab --old node-a --new node-b --yes
Delete the cluster rowkctl kubernetes delete lab
Record a member changekctl kubernetes scale lab --add-workers node-103:192.168.40.103

kctl kubernetes delete lab removes the cluster row from the controller. --force is accepted. Deleting the row does not by itself turn Kubernetes off on the nodes.

Limits