Categorygithub.com/smartxworks/cluster-api-provider-virtink

# README

Kubernetes Cluster API Provider Virtink

build Go Report Card

Kubernetes-native declarative infrastructure for Virtink.

What is the Cluster API Provider Virtink

The Cluster API brings declarative, Kubernetes-style APIs to cluster creation, configuration and management. Cluster API Provider Virtink is a concrete implementation of Cluster API for Virtink.

The API itself is shared across multiple cloud providers allowing for true Virtink hybrid deployments of Kubernetes. It is built atop the lessons learned from previous cluster managers such as kops and kubicorn.

Launching a Kubernetes cluster on Virtink

Check out the getting started guide for launching a cluster on Virtink.

Note: For clusterctl versions prior to v1.2.1, you'll need to add this provider manually to the clusterctl configuration file ($HOME/.cluster-api/clusterctl.yaml), as shown below:

providers:
  - name: "virtink"
    url: "https://github.com/smartxworks/cluster-api-provider-virtink/releases/latest/infrastructure-components.yaml"
    type: "InfrastructureProvider"

An external Virtink cluster is recommended for infrastructure, further details can be found in the external cluster documentation. For an internal Virtink cluster, use clusterctl generate cluster --infrastructure virtink --flavor internal capi-quickstart to generate workload cluster configuration.

Environment Variables

Except for the common variables provided by Cluster API, you can further customize your workload cluster on Virtink with following environment variables:

Variable nameNote
KUBERNETES_VERSIONOnly support Kubernetes versions that corresponding rootfs image smartxworks/capch-rootfs-$KUBERNETES_VERSION exists
VIRTINK_INFRA_CLUSTER_SECRET_NAMEThe name of secret in the management cluster that contains the kubeconfig of the Virtink infrastructure cluster
VIRTINK_INFRA_CLUSTER_SECRET_NAMESPACEThe namespace of secret in the management cluster that contains the kubeconfig of the Virtink infrastructure cluster
VIRTINK_INFRA_CLUSTER_RESOURCES_NAMESPACEThe namespace of resources(such as VM, DataVolume) to be created in the infrastructural cluster, make sure it exists before create the workload cluster (default $NAMESPACE)
POD_NETWORK_CIDRRange of IP addresses for the pod network (default 192.168.0.0/16)
SERVICE_CIDRRange of IP address for service VIPs (default 10.96.0.0/12)
VIRTINK_CONTROL_PLANE_SERVICE_TYPEThe type of control plane service (default NodePort)
VIRTINK_CONTROL_PLANE_MACHINE_CPU_CORESThe CPU cores of each control plane machine (default 2)
VIRTINK_CONTROL_PLANE_MACHINE_MEMORY_SIZEThe memory size of each control plane machine (default 4Gi)
VIRTINK_CONTROL_PLANE_MACHINE_KERNEL_IMAGEThe kernel image of control plane machine (default smartxworks/capch-kernel-5.15.12)
VIRTINK_CONTROL_PLANE_MACHINE_ROOTFS_IMAGEThe rootfs image of control plane machine (default smartxworks/capch-rootfs-1.24.0)
VIRTINK_CONTROL_PLANE_MACHINE_ROOTFS_SIZEThe rootfs size of each control plane machine (default 4Gi)
VIRTINK_WORKER_MACHINE_CPU_CORESThe CPU cores of each worker machine (default 2)
VIRTINK_WORKER_MACHINE_MEMORY_SIZEThe memory size of each worker machine (default 4Gi)
VIRTINK_WORKER_MACHINE_KERNEL_IMAGEThe kernel image of worker machine (default smartxworks/capch-kernel-5.15.12)
VIRTINK_WORKER_MACHINE_ROOTFS_IMAGEThe rootfs image of worker machine (default smartxworks/capch-rootfs-1.24.0)
VIRTINK_WORKER_MACHINE_ROOTFS_SIZEThe rootfs size of each worker machine (default 4Gi)

Launching a Kubernetes cluster on Virtink with persistent storage

By default cluster-api-provider-virtink created Kubernetes Node is a Virtink VirtualMachine with emptyDir as storage, that means when a Virtink VirtualMachine failed all data on it will lose and the Node can't be recovered. cluster-api-provider-virtink can provide Node with persistent storage by Virtink dataVolume volume and CNI that support specify IP and MAC address for Pod.

Variable nameNote
VIRTINK_CONTROL_PLANE_MACHINE_ROOTFS_CDI_IMAGEThe rootfs image for CDI of control plane machine (default smartxworks/capch-rootfs-cdi-1.24.0)
VIRTINK_WORKER_MACHINE_ROOTFS_CDI_IMAGEThe rootfs image for CDI of worker machine (default smartxworks/capch-rootfs-cdi-1.24.0)
VIRTINK_IP_POOL_NAMEThe IPPool for machines to get IP address from

This is an example to generate workload cluster configuration with persistent storage for an internal Virtink cluster that use Calico as CNI. You should be familiar with Calico IP reservation, Calico use-specific-ip for pod, and Calico use-specific-mac-address for pod.

Download cluster-template-cdi-internal.yaml and update VirtinkMachineTemplate.spec.template.metadata.annotations as below, $IP_ADDRESS and $MAC_ADDRESS are placeholders which will be replaced by allocated IP and MAC.

spec:
  template:
    metadata:
      annotations:
        cni.projectcalico.org/hwAddr: $MAC_ADDRESS
        cni.projectcalico.org/ipAddrs: '["$IP_ADDRESS"]'

We use ip-address-manager to manage the allocattion of IP addresses, so you need to create an IPPool resource.

# replace to created IPPool name.
export VIRTINK_IP_POOL_NAME='capi-quickstart'
clusterctl generate cluster --infrastructure virtink --flavor cdi-internal capi-quickstart

License

This project is distributed under the Apache License, Version 2.0.

# Packages

No description provided by the author
No description provided by the author
No description provided by the author