Talos Cloud Controller Manager
repository·main·Indexed 40 days ago
https://github.com/siderolabs/talos-cloud-controller-managerA Kubernetes Cloud Controller Manager (CCM) implementation for Talos that enables multi-cloud management. It integrates Kubernetes with cloud infrastructure to manage resources like persistent volumes and load balancers, featuring specialized controllers including cloud-node, cloud-node-lifecycle, node-ipam-controller, and node-csr-approval.
What's inside Talos CCM
- Talos Cloud Controller Manager (CCM) is designed to facilitate multi-cloud Kubernetes solutions by allowing multiple CCMs to run within a single cluster without interference. It integrates Kubernetes with underlying cloud infrastructure to manage resources like persistent volumes, load balancers, and networking. It is particularly useful for hybrid cloud approaches where a single cluster spans multiple cloud providers.
How Talos Cloud Controller Manager works
mainThe Talos CCM manages the lifecycle of nodes in the following sequence:
- Node Join: A Kubelet with
--cloud-provider=externaljoins the cluster. TheNodeobject is created with thenode.cloudprovider.kubernetes.io/uninitializedtaint, thealpha.kubernetes.io/provided-node-ipannotation, andnodeInfo. - Detection: CCM detects the new node and requests the node configuration from the Talos API.
- Update: CCM updates the
Nodeobject with necessary labels, taints, and theproviderIDfield. - Initialization: CCM removes the
node.cloudprovider.kubernetes.io/uninitializedtaint, making the node ready for use.
Warning: If the Kubelet is not configured with
--cloud-provider=external, it will attempt to manage its own lifecycle, causing the CCM to skip the node and fail to initialize it.- Node Join: A Kubelet with
Use the cloud-node-controller
mainThe
cloud-node-controlleris enabled by default. It detects new cloud instances and registers them as Kubernetes nodes, assigning labels and taints based on cloud metadata.Labels applied to nodes:
topology.kubernetes.io/regiontopology.kubernetes.io/zonenode.kubernetes.io/instance-typenode.cloudprovider.kubernetes.io/clustername(Talos specific)node.cloudprovider.kubernetes.io/platform(Talos specific)node.cloudprovider.kubernetes.io/lifecycle(Talos specific - e.g., spot instance type)
Node Specs:
providerIDmagic stringInternalIPandExternalIPaddresses
# Enable specifically via CLI flag --controllers=cloud-nodeUse Platform Metadata Variables in Transformations
mainWithin transformation rules (annotations, labels, or platformMetadata), you can use Go templates to access platform-specific metadata. These variables are case-sensitive.
Available variables include:
Platform: The Talos platform (e.g.,aws,gcp,azure,openstack,metal).Hostname: The node's hostname.Region: The cloud region (e.g.,us-east-1).Zone: The cloud zone (e.g.,us-west-1f).InstanceType: The instance type (e.g.,t2.micro).InstanceID: The cloud instance ID.ProviderID: The cloud provider ID.Spot: Boolean indicating if it is a spot instance.InternalDNS: Internal DNS name.ExternalDNS: External DNS name.
You can inspect these values using the
talosctlcommand:talosctl get PlatformMetadatas -oyamlUse System Information Variables in Transformations
mainTransformation rules can also access hardware-level system information via Go templates. These variables are case-sensitive.
Available variables include:
Manufacturer: Hardware manufacturer.ProductName: Product name.Version: Hardware version.SerialNumber: Hardware serial number.UUID: Hardware UUID.WakeUpType: Wake-up type.SKUNumber: System SKU number.
You can inspect these values using the
talosctlcommand:talosctl get SystemInformation -oyamlSupported Talos CCM Controllers
mainTalos CCM provides several specialized controllers to manage different aspects of cloud-integrated Kubernetes nodes:
- cloud-node: Updates the Kubernetes
Noderesource with cloud metadata and assigns labels and taints based on cloud metadata and specific configuration. - cloud-node-lifecycle: Handles the cleanup of the
Noderesource when a cloud instance is deleted. - node-ipam-controller: Manages the allocation and assignment of CIDR addresses to pods across all nodes in the cluster.
- node-csr-approval: Automatically approves Certificate Signing Requests (CSRs) for kubelet server certificates.
- cloud-node: Updates the Kubernetes
Use the cloud-node-lifecycle-controller (GCP Spot Instances)
mainThe
cloud-node-lifecycle-controlleris currently optimized for GCP. It handles GCP spot instance evictions by catching the event and removing the node resource from the cluster. This allows the node to re-initialize and join the cluster cleanly after the instance is recreated.# Enable via CLI flag --controllers=node-lifecycle-controllerConfigure Node IPAM (IP Address Management)
mainThe
node-ipam-controllermanages the allocation of CIDR addresses to pods across nodes. It is particularly useful in hybrid environments to solve IPv6 CIDR allocation problems by allowing each node to have a unique IPv6 CIDR range based on cloud metadata.Key Concepts:
- Pod CIDR Allocation: Based on
--node-cidr-mask-size-ipv4and--node-cidr-mask-size-ipv6. - Allocator Types:
RangeAllocator: The default Kubernetes CIDR allocator.CloudAllocator: A custom allocator that uses Talos/Cloud metadata to allocate ranges.
Recommended CLI Arguments: To enable the
CloudAllocatorand set specific mask sizes, use:--controllers=node-ipam-controller \ --allocate-node-cidrs \ --node-cidr-mask-size-ipv4=24 \ --node-cidr-mask-size-ipv6=80 \ --cidr-allocator-type=CloudAllocator# Example CLI invocation for Node IPAM --controllers=node-ipam-controller \ --allocate-node-cidrs \ --node-cidr-mask-size-ipv4=24 \ --node-cidr-mask-size-ipv6=80 \ --cidr-allocator-type=CloudAllocator- Pod CIDR Allocation: Based on
Install Talos Cloud Controller Manager
mainYou can install the Talos Cloud Controller Manager using one of three methods:
Method 1: Talos Machine Config
Integrate the installation directly into your Talos cluster configuration by enabling the
externalCloudProviderfeature and providing the manifest URL.Method 2: kubectl
Apply the deployment manifests directly using
kubectl. You can choose between the latest release or the latest stable (edge) version.Method 3: Helm Chart
Deploy using the official Helm chart via OCI registry. This is the recommended method for production environments.
# Method 1: Talos machine config cluster: externalCloudProvider: enabled: true manifests: - https://raw.githubusercontent.com/siderolabs/talos-cloud-controller-manager/main/docs/deploy/cloud-controller-manager.yml# Method 2: kubectl (Latest) kubectl apply -f https://raw.githubusercontent.com/siderolabs/talos-cloud-controller-manager/main/docs/deploy/cloud-controller-manager.yml # Method 2: kubectl (Edge) kubectl apply -f https://raw.githubusercontent.com/siderolabs/talos-cloud-controller-manager/main/docs/deploy/cloud-controller-manager-edge.yml # Method 3: Helm helm upgrade -i -n kube-system talos-cloud-controller-manager oci://ghcr.io/siderolabs/charts/talos-cloud-controller-managerConfigure Talos machine configuration for CCM
mainTo use the Talos Cloud Controller Manager (CCM), you must configure your Talos machine configuration to allow an external cloud provider and enable specific API access features.
Control Plane Configuration
Set the following in your control plane configuration to enable external cloud provider support, server certificate rotation, and Talos API access for the
kube-systemnamespace:machine: kubelet: extraArgs: cloud-provider: external rotate-server-certificates: true features: kubernetesTalosAPIAccess: enabled: true allowedRoles: - os:reader allowedKubernetesNamespaces: - kube-systemWorker Node Configuration
Worker nodes must be configured to use the external cloud provider and enable certificate rotation:
machine: kubelet: extraArgs: cloud-provider: external rotate-server-certificates: trueInstall Talos Cloud Controller Manager via Helm
mainYou can deploy the Talos CCM using the provided Helm chart. It is recommended to use a custom
values.yamlfile to configure the number of replicas and the specific controllers you wish to enable.Deployment Example
- Create a configuration file (e.g.,
talos-ccm.yaml):
replicaCount: 2 enabledControllers: - cloud-node - node-csr-approval- Run the Helm upgrade command:
helm upgrade -i --namespace=kube-system -f talos-ccm.yaml \ talos-cloud-controller-manager charts/talos-cloud-controller-managerhelm upgrade -i --namespace=kube-system -f talos-ccm.yaml \ talos-cloud-controller-manager charts/talos-cloud-controller-manager- Create a configuration file (e.g.,
Verify container image signatures
mainUse Cosign keyless verification to validate container images. Depending on the image type, use the corresponding GitHub Action identity and workflow reference.
Edge version
To verify the
edgeimage, use thebuild-edge.yamlworkflow identity.Releases
To verify a specific release tag, use the workflow identity associated with that specific tag (e.g.,
release.yaml@refs/tags/v1.4.1).# Verify Edge version cosign verify ghcr.io/siderolabs/talos-cloud-controller-manager:edge --certificate-identity https://github.com/siderolabs/talos-cloud-controller-manager/.github/workflows/build-edge.yaml@refs/heads/main --certificate-oidc-issuer https://token.actions.githubusercontent.com # Verify a specific Release cosign verify ghcr.io/siderolabs/talos-cloud-controller-manager:v1.4.1 --certificate-identity https://github.com/siderolabs/talos-cloud-controller-manager/.github/workflows/release.yaml@refs/tags/v1.4.1 --certificate-oidc-issuer https://token.actions.githubusercontent.com