### Python Virtual Environment Setup and Talos Provider Installation Source: https://github.com/pulumiverse/pulumi-talos/blob/main/README.md Demonstrates setting up a Python virtual environment, installing the 'setuptools' package to resolve potential import errors, and then installing the Talos resource provider. Finally, it tests if the import works. ```bash python3 -m venv venv source venv/bin/activate pip install setuptools pip install pulumiverse_talos # Test if the import works python -c "import pulumiverse_talos" ``` -------------------------------- ### Install Talos Provider for Go Source: https://github.com/pulumiverse/pulumi-talos/blob/main/README.md Installs the Talos resource provider for Go using 'go get'. This command fetches the latest version of the library for use in Go projects. ```bash go get github.com/pulumiverse/pulumi-talos/sdk/go/... ``` -------------------------------- ### Install Talos Pulumi Provider Source: https://context7.com/pulumiverse/pulumi-talos/llms.txt Instructions for installing the Talos Pulumi provider package for various programming languages and the provider binary. ```bash # Node.js (npm) npm install @pulumiverse/talos # Node.js (yarn) yarn add @pulumiverse/talos # Python pip install pulumiverse_talos # Go go get github.com/pulumiverse/pulumi-talos/sdk/go/... # .NET dotnet add package Pulumiverse.Talos # Install the provider binary pulumi plugin install resource talos --server github://api.github.com/pulumiverse ``` -------------------------------- ### Install Talos Provider Binary Source: https://github.com/pulumiverse/pulumi-talos/blob/main/docs/installation-configuration.md Installs the Talos provider binary using the Pulumi CLI. Replace `` with the desired version. This command fetches the necessary binary from the specified server. ```bash pulumi plugin install resource talos --server github://api.github.com/pulumiverse ``` -------------------------------- ### Install Talos Provider for .NET Source: https://github.com/pulumiverse/pulumi-talos/blob/main/README.md Installs the Talos resource provider for .NET using the 'dotnet add package' command. This integrates the provider into your .NET project. ```bash dotnet add package Pulumiverse.Talos ``` -------------------------------- ### Provision Talos Linux Machines and Activate Kubernetes Clusters Source: https://github.com/pulumiverse/pulumi-talos/blob/main/docs/_index.md This example demonstrates how to provision Talos Linux machines and activate Kubernetes clusters using the Pulumi Talos provider. It involves generating secrets, configuring machine installations with specific disk paths, applying these configurations, and bootstrapping the cluster. The code also shows how to retrieve the TALOSCONFIG and KUBECONFIG for cluster management. ```typescript import * as pulumi from "@pulumi/pulumi"; import * as talos from "@pulumiverse/talos"; const secrets = new talos.machine.Secrets("secrets", {}); const configuration = talos.machine.getConfigurationOutput({ clusterName: "exampleCluster", machineType: "controlplane", clusterEndpoint: "https://cluster.local:6443", machineSecrets: secrets.machineSecrets, }); const configurationApply = new talos.machine.ConfigurationApply("configurationApply", { clientConfiguration: secrets.clientConfiguration, machineConfigurationInput: configuration.machineConfiguration, node: "10.5.0.2", configPatches: [JSON.stringify({ machine: { install: { disk: "/dev/sdd", }, }, })], }); const bootstrap = new talos.machine.Bootstrap("bootstrap", { node: "10.5.0.2", clientConfiguration: secrets.clientConfiguration, }, { dependsOn: [configurationApply], }); ``` ```python import pulumi import pulumiverse_talos as talos import json import yaml CLUSTER_NAME = "test-cluster" NODE_IP = "192.168.122.241" # To get disks: `talosctl get disks --insecure --nodes ` MAIN_DISK = "/dev/vdb" # --- # Initialize Talos & Kubernetes Secrets # --- secrets = talos.machine.Secrets("secrets") # --- # Configure cluster # --- machine_configuration = talos.machine.get_configuration_output( cluster_name=CLUSTER_NAME, machine_type="controlplane", cluster_endpoint=f"https://{NODE_IP}:6443", machine_secrets=secrets.machine_secrets.apply( lambda ms: { "certs": { "k8sAggregator": ms.certs.k8s_aggregator, "os": ms.certs.os, "etcd": ms.certs.etcd, "k8s": ms.certs.k8s, "k8sServiceaccount": ms.certs.k8s_serviceaccount, }, "secrets": { "bootstrapToken": ms.secrets.bootstrap_token, "secretboxEncryptionSecret": ms.secrets.secretbox_encryption_secret, }, "trustdinfo": ms.trustdinfo, "cluster": { "id": ms.cluster.id, "secret": ms.cluster.secret, }, } ), ) configuration_apply = talos.machine.ConfigurationApply( "configurationApply", client_configuration=secrets.client_configuration, machine_configuration_input=machine_configuration.machine_configuration, node=NODE_IP, config_patches=[ json.dumps( { "machine": { "install": { "disk": MAIN_DISK, }, }, } ) ], ) # --- # Bootstrap cluster # --- bootstrap = talos.machine.Bootstrap( "bootstrap", node=NODE_IP, client_configuration=secrets.client_configuration, opts=pulumi.ResourceOptions(depends_on=[configuration_apply]), ) # --- # Retrieve TALOSCONFIG # --- def write_talosconfig( client_configuration: talos.machine.outputs.ClientConfiguration, context_name: str = "default", ): talosconfig_dict = { "context": context_name, "contexts": { context_name: { "endpoints": [NODE_IP], "nodes": [NODE_IP], "ca": client_configuration.ca_certificate, "crt": client_configuration.client_certificate, "key": client_configuration.client_key, } }, } with open(".secrets/talosconfig", "w") as file_handle: yaml.dump(talosconfig_dict, file_handle, default_flow_style=False) secrets.client_configuration.apply(write_talosconfig) # --- # Retrieve KUBECONFIG # --- kubeconfig = talos.cluster.Kubeconfig( "kubeconfig", client_configuration=secrets.client_configuration, node=NODE_IP, endpoint=NODE_IP, ) kubeconfig.kubeconfig_raw.apply( lambda kubeconfig_raw: open(".secrets/kubeconfig", "w").write(kubeconfig_raw) ) ``` -------------------------------- ### Get Talos Image URLs with getUrls Source: https://context7.com/pulumiverse/pulumi-talos/llms.txt The getUrls function generates URLs for various Talos image formats (ISO, disk images, installers, PXE boot files) from the Image Factory. It requires Talos version, schematic ID, platform, and architecture as input. The output includes URLs for installer, ISO, disk image, PXE, kernel, and initramfs, including secure boot variants. ```typescript import * as pulumi from "@pulumi/pulumi"; import * as talos from "@pulumiverse/talos"; // Get URLs for Talos images with a specific schematic const imageUrls = talos.imageFactory.getUrlsOutput({ talosVersion: "v1.7.5", schematicId: "376567988ad370138ad8b2698212367b8edcb69b5fd68c80be1f2ec7d603b4ba", platform: "metal", architecture: "amd64", }); // Export various image URLs export const installerImage = imageUrls.urls.installer; export const isoUrl = imageUrls.urls.iso; export const diskImageUrl = imageUrls.urls.diskImage; export const pxeUrl = imageUrls.urls.pxe; export const kernelUrl = imageUrls.urls.kernel; export const initramfsUrl = imageUrls.urls.initramfs; // Secure boot variants export const installerSecureBoot = imageUrls.urls.installerSecureboot; export const isoSecureBoot = imageUrls.urls.isoSecureboot; ``` -------------------------------- ### Configure and Bootstrap Talos Machine (Go) Source: https://github.com/pulumiverse/pulumi-talos/blob/main/docs/_index.md Configures a Talos machine by applying a configuration patch and then bootstraps the machine. This example uses Go and assumes a controlplane machine type. ```go package main import ( "encoding/json" "github.com/pulumi/pulumi/sdk/v3/go/pulumi" "github.com/pulumiverse/pulumi-talos/sdk/go/talos/machine" ) func main() { pulumi.Run(func(ctx *pulumi.Context) error { secrets, err := machine.NewSecrets(ctx, "secrets", nil) if err != nil { return err } configuration := machine.GetConfigurationOutput(ctx, machine.GetConfigurationOutputArgs{ ClusterName: pulumi.String("exampleCluster"), MachineType: pulumi.String("controlplane"), ClusterEndpoint: pulumi.String("https://cluster.local:6443"), MachineSecrets: secrets.MachineSecrets, }, nil) tmpJSON0, err := json.Marshal(map[string]interface{}{ "machine": map[string]interface{}{ "install": map[string]interface{}{ "disk": "/dev/sdd", }, }, }) if err != nil { return err } json0 := string(tmpJSON0) configurationApply, err := machine.NewConfigurationApply(ctx, "configurationApply", &machine.ConfigurationApplyArgs{ ClientConfiguration: secrets.ClientConfiguration, MachineConfigurationInput: *pulumi.String(configuration), Node: pulumi.String("10.5.0.2"), ConfigPatches: pulumi.StringArray{ pulumi.String(json0), }, }) if err != nil { return err } _, err = machine.NewBootstrap(ctx, "bootstrap", &machine.BootstrapArgs{ Node: pulumi.String("10.5.0.2"), ClientConfiguration: secrets.ClientConfiguration, }, pulumi.DependsOn([]pulumi.Resource{ configurationApply, })) if err != nil { return err } return nil }) } ``` -------------------------------- ### Install Talos Provider for Python Source: https://github.com/pulumiverse/pulumi-talos/blob/main/README.md Installs the Talos resource provider for Python using pip. This command is used to add the package to your Python environment. ```bash pip install pulumiverse_talos ``` -------------------------------- ### Install Talos Provider for Node.js (npm) Source: https://github.com/pulumiverse/pulumi-talos/blob/main/README.md Installs the Talos resource provider for Node.js using npm. This is the standard package manager for JavaScript and TypeScript projects. ```bash npm install @pulumiverse/talos ``` -------------------------------- ### Configure and Bootstrap Talos Machine (C#) Source: https://github.com/pulumiverse/pulumi-talos/blob/main/docs/_index.md Configures a Talos machine by applying a configuration patch and then bootstraps the machine. This example uses C# and assumes a controlplane machine type. ```csharp using System.Collections.Generic; using System.Linq; using System.Text.Json; using Pulumi; using Talos = Pulumiverse.Talos; return await Deployment.RunAsync(() => { var secrets = new Talos.Machine.Secrets("secrets"); var configuration = Talos.Machine.GetConfiguration.Invoke(new() { ClusterName = "exampleCluster", MachineType = "controlplane", ClusterEndpoint = "https://cluster.local:6443", MachineSecrets = secrets.MachineSecrets, }); var configurationApply = new Talos.Machine.ConfigurationApply("configurationApply", new() { ClientConfiguration = secrets.ClientConfiguration, MachineConfigurationInput = configuration.MachineConfiguration, Node = "10.5.0.2", ConfigPatches = new[] { JsonSerializer.Serialize(new Dictionary { ["machine"] = new Dictionary { ["install"] = new Dictionary { ["disk"] = "/dev/sdd", }, }, }), }, }); var bootstrap = new Talos.Machine.Bootstrap("bootstrap", new() { Node = "10.5.0.2", ClientConfiguration = secrets.ClientConfiguration, }, new CustomResourceOptions { DependsOn = new[] { configurationApply, }, }); }); ``` -------------------------------- ### Install Talos Provider for Node.js (yarn) Source: https://github.com/pulumiverse/pulumi-talos/blob/main/README.md Installs the Talos resource provider for Node.js using yarn. Yarn is an alternative package manager for JavaScript and TypeScript projects. ```bash yarn add @pulumiverse/talos ``` -------------------------------- ### Configure and Bootstrap Talos Machine (YAML) Source: https://github.com/pulumiverse/pulumi-talos/blob/main/docs/_index.md Configures a Talos machine by applying a configuration patch and then bootstraps the machine. This example uses Pulumi YAML. ```yaml name: talos runtime: yaml description: A minimal Talos program in Pulumi YAML variables: configuration: fn::invoke: function: talos:machine/getConfiguration:getConfiguration arguments: clusterName: "exampleCluster" machineType: "controlplane" clusterEndpoint: "https://cluster.local:6443" machineSecrets: ${secrets.machineSecrets} return: machineConfiguration resources: secrets: type: talos:machine/secrets:Secrets configurationApply: type: talos:machine/configurationApply:ConfigurationApply properties: clientConfiguration: ${secrets.clientConfiguration} machineConfigurationInput: ${configuration} node: "10.5.0.2" configPatches: - fn::toJSON: machine: install: disk: "/dev/sdd" bootstrap: type: talos:machine:Bootstrap properties: node: "10.5.0.2" clientConfiguration: ${secrets.clientConfiguration} options: dependsOn: - ${configurationApply} outputs: {} ``` -------------------------------- ### Get Talos Board Overlays with getOverlaysVersions Source: https://context7.com/pulumiverse/pulumi-talos/llms.txt The getOverlaysVersions function retrieves available board overlays for specific hardware platforms from the Image Factory. It requires the Talos version and can filter overlays by name. The output provides information about each overlay, including its name, image, and reference. ```typescript import * as pulumi from "@pulumi/pulumi"; import * as talos from "@pulumiverse/talos"; // Get overlays for a Talos version const overlays = talos.imageFactory.getOverlaysVersionsOutput({ talosVersion: "v1.7.5", filters: { name: "rock4cplus", }, }); export const overlayInfo = overlays.overlaysInfos.apply(o => o.map(overlay => ({ name: overlay.name, image: overlay.image, ref: overlay.ref, })) ); ``` -------------------------------- ### Get Available Talos Versions with getVersions Source: https://context7.com/pulumiverse/pulumi-talos/llms.txt The getVersions function retrieves a list of available Talos versions from the Image Factory. It can optionally filter to include only stable versions. The output is a list of Talos version strings, with an option to export the latest stable version. ```typescript import * as pulumi from "@pulumi/pulumi"; import * as talos from "@pulumiverse/talos"; // Get all available Talos versions const allVersions = talos.imageFactory.getVersionsOutput({}); // Get only stable versions const stableVersions = talos.imageFactory.getVersionsOutput({ filters: { stableVersionsOnly: true, }, }); export const availableVersions = stableVersions.talosVersions; export const latestStable = stableVersions.talosVersions.apply(v => v[0]); ``` -------------------------------- ### Get Talos Extension Versions with getExtensionsVersions Source: https://context7.com/pulumiverse/pulumi-talos/llms.txt The getExtensionsVersions function retrieves available system extensions for a specific Talos version from the Image Factory. It can filter extensions by name or perform exact name matching. The output provides information about each extension, including its name, reference, description, and author. ```typescript import * as pulumi from "@pulumi/pulumi"; import * as talos from "@pulumiverse/talos"; // Get all available extensions for a Talos version const allExtensions = talos.imageFactory.getExtensionsVersionsOutput({ talosVersion: "v1.7.5", }); // Filter extensions by name const filteredExtensions = talos.imageFactory.getExtensionsVersionsOutput({ talosVersion: "v1.7.5", filters: { names: ["amdgpu", "tailscale", "nvidia-container-toolkit"], }, }); // Exact name matching const exactExtensions = talos.imageFactory.getExtensionsVersionsOutput({ talosVersion: "v1.7.5", exactFilters: { names: ["siderolabs/intel-ucode"], }, }); export const extensionsList = filteredExtensions.extensionsInfos.apply(exts => exts.map(ext => ({ name: ext.name, ref: ext.ref, description: ext.description, author: ext.author, })) ); ``` -------------------------------- ### Bootstrap Talos Kubernetes Cluster Source: https://context7.com/pulumiverse/pulumi-talos/llms.txt Initiates the Kubernetes cluster bootstrap process on a Talos control plane node using the Bootstrap resource. This should be run once per cluster on the first control plane node after its configuration is applied. It depends on the ConfigurationApply resource. ```typescript import * as pulumi from "@pulumi/pulumi"; import * as talos from "@pulumiverse/talos"; const secrets = new talos.machine.Secrets("secrets", {}); const configuration = talos.machine.getConfigurationOutput({ clusterName: "exampleCluster", machineType: "controlplane", clusterEndpoint: "https://10.5.0.2:6443", machineSecrets: secrets.machineSecrets, }); const configApply = new talos.machine.ConfigurationApply("configApply", { clientConfiguration: secrets.clientConfiguration, machineConfigurationInput: configuration.machineConfiguration, node: "10.5.0.2", configPatches: [JSON.stringify({ machine: { install: { disk: "/dev/sda" } }, })], }); // Bootstrap the cluster - only run on ONE control plane node const bootstrap = new talos.machine.Bootstrap("bootstrap", { node: "10.5.0.2", clientConfiguration: secrets.clientConfiguration, // Optional: specify endpoint if different from node endpoint: "10.5.0.2", // Optional: timeout configuration timeouts: { create: "10m", }, }, { // Ensure configuration is applied before bootstrapping dependsOn: [configApply], }); ``` -------------------------------- ### Apply Talos Machine Configuration Source: https://context7.com/pulumiverse/pulumi-talos/llms.txt Applies a machine configuration to a Talos node using the ConfigurationApply resource. It handles communication with the node's API and supports various apply modes and destroy behaviors. Dependencies include pulumi and @pulumiverse/talos. ```typescript import * as pulumi from "@pulumi/pulumi"; import * as talos from "@pulumiverse/talos"; const secrets = new talos.machine.Secrets("secrets", {}); const configuration = talos.machine.getConfigurationOutput({ clusterName: "myCluster", machineType: "controlplane", clusterEndpoint: "https://10.5.0.2:6443", machineSecrets: secrets.machineSecrets, }); // Apply configuration to a control plane node const configApply = new talos.machine.ConfigurationApply("controlplane-config", { clientConfiguration: secrets.clientConfiguration, machineConfigurationInput: configuration.machineConfiguration, node: "10.5.0.2", // Optional: specify endpoint if different from node endpoint: "10.5.0.2", // Apply mode: "auto", "staged", "no-reboot", or "staged_if_needing_reboot" applyMode: "auto", // Config patches applied on top of the base configuration configPatches: [JSON.stringify({ machine: { install: { disk: "/dev/nvme0n1", bootloader: true, wipe: false, }, network: { interfaces: [{ interface: "eth0", dhcp: true, }], }, }, })], // Optional: configure behavior on resource destruction onDestroy: { reset: true, // Reset the machine state graceful: true, // Leave etcd gracefully reboot: false, // Don't reboot after reset }, // Optional: timeouts timeouts: { create: "10m", update: "10m", }, }); export const appliedConfig = configApply.machineConfiguration; export const resolvedApplyMode = configApply.resolvedApplyMode; ``` -------------------------------- ### Create Talos Image Factory Schematic (TypeScript) Source: https://context7.com/pulumiverse/pulumi-talos/llms.txt The `Schematic` resource creates a custom image schematic for the Talos Image Factory. Schematics define which system extensions and customizations should be included in the Talos OS image. This allows for tailored Talos OS images with specific tools and configurations. ```typescript import * as pulumi from "@pulumi/pulumi"; import * as talos from "@pulumiverse/talos"; import * as yaml from "yaml"; // Create a schematic for custom image generation const schematic = new talos.imageFactory.Schematic("customSchematic", { schematic: yaml.stringify({ customization: { systemExtensions: { officialExtensions: [ "siderolabs/intel-ucode", "siderolabs/i915-ucode", "siderolabs/iscsi-tools", "siderolabs/util-linux-tools", ], }, }, }), }); // The schematic ID can be used with getUrls to generate image URLs export const schematicId = schematic.id; ``` -------------------------------- ### Deploy Talos Kubernetes Cluster with Pulumi (TypeScript) Source: https://context7.com/pulumiverse/pulumi-talos/llms.txt This TypeScript code deploys a complete Talos Kubernetes cluster. It generates necessary secrets, configures control plane and worker nodes with specific IP addresses, bootstraps the cluster, and retrieves the kubeconfig. Dependencies include the '@pulumi/pulumi' and '@pulumiverse/talos' packages. ```typescript import * as pulumi from "@pulumi/pulumi"; import * as talos from "@pulumiverse/talos"; const config = new pulumi.Config(); const clusterName = config.get("clusterName") || "talos-cluster"; const controlPlaneIp = config.require("controlPlaneIp"); const workerIps = config.requireObject("workerIps"); // Step 1: Generate cluster secrets const secrets = new talos.machine.Secrets("clusterSecrets", { talosVersion: "v1.7.5", }); // Step 2: Generate control plane configuration const controlPlaneConfig = talos.machine.getConfigurationOutput({ clusterName: clusterName, machineType: "controlplane", clusterEndpoint: `https://${controlPlaneIp}:6443`, machineSecrets: secrets.machineSecrets, talosVersion: "v1.7.5", kubernetesVersion: "1.30.0", }); // Step 3: Apply configuration to control plane const controlPlaneApply = new talos.machine.ConfigurationApply("controlplane", { clientConfiguration: secrets.clientConfiguration, machineConfigurationInput: controlPlaneConfig.machineConfiguration, node: controlPlaneIp, configPatches: [JSON.stringify({ machine: { install: { disk: "/dev/sda" } }, cluster: { allowSchedulingOnControlPlanes: true, }, })], }); // Step 4: Bootstrap the cluster const bootstrap = new talos.machine.Bootstrap("bootstrap", { node: controlPlaneIp, clientConfiguration: secrets.clientConfiguration, }, { dependsOn: [controlPlaneApply] }); // Step 5: Deploy worker nodes const workerConfig = talos.machine.getConfigurationOutput({ clusterName: clusterName, machineType: "worker", clusterEndpoint: `https://${controlPlaneIp}:6443`, machineSecrets: secrets.machineSecrets, }); const workerApplies = workerIps.map((ip, i) => new talos.machine.ConfigurationApply(`worker-${i}`, { clientConfiguration: secrets.clientConfiguration, machineConfigurationInput: workerConfig.machineConfiguration, node: ip, configPatches: [JSON.stringify({ machine: { install: { disk: "/dev/sda" } }, })], }, { dependsOn: [bootstrap] }) ); // Step 6: Wait for cluster health const health = talos.cluster.getHealthOutput({ clientConfiguration: secrets.clientConfiguration, controlPlaneNodes: [controlPlaneIp], workerNodes: workerIps, endpoints: [controlPlaneIp], timeouts: { read: "10m" }, }); // Step 7: Retrieve kubeconfig const kubeconfig = new talos.cluster.Kubeconfig("kubeconfig", { clientConfiguration: secrets.clientConfiguration, node: controlPlaneIp, }, { dependsOn: workerApplies }); // Exports export const kubeconfigRaw = kubeconfig.kubeconfigRaw; export const talosClientConfig = secrets.clientConfiguration; ``` -------------------------------- ### Generate Talos Cluster Configuration (TypeScript) Source: https://context7.com/pulumiverse/pulumi-talos/llms.txt The `getConfigurationOutput` function generates a talosconfig file content that can be used with the talosctl CLI tool. This is useful for providing operators with the necessary configuration to interact with the cluster manually. It requires cluster details and client configuration. ```typescript import * as pulumi from "@pulumi/pulumi"; import * as talos from "@pulumiverse/talos"; const secrets = new talos.machine.Secrets("secrets", {}); // Generate talosconfig for CLI usage const talosconfig = talos.client.getConfigurationOutput({ clusterName: "production-cluster", clientConfiguration: secrets.clientConfiguration, nodes: ["10.5.0.2", "10.5.0.3", "10.5.0.4"], endpoints: ["10.5.0.2"], }); // Export the talosconfig content export const talosConfig = talosconfig.talosConfig; // The talosconfig can be written to a file for use with talosctl: // talosctl --talosconfig ./talosconfig cluster show ``` -------------------------------- ### Query Talos Node Disks (TypeScript) Source: https://context7.com/pulumiverse/pulumi-talos/llms.txt The `getDisksOutput` function queries the available disks on a Talos node. While Talos natively supports disk selectors in machine configuration, this function is useful for querying disk information that can be used elsewhere in your infrastructure code. It allows filtering disks using CEL expressions. ```typescript import * as pulumi from "@pulumi/pulumi"; import * as talos from "@pulumiverse/talos"; const secrets = new talos.machine.Secrets("secrets", {}); // Query disks on a node const disks = talos.machine.getDisksOutput({ clientConfiguration: secrets.clientConfiguration, node: "10.5.0.2", // Optional: filter disks using CEL expressions selector: "disk.size > 100u * GB && !disk.cdrom && !disk.readonly", timeouts: { read: "1m", }, }); // Access disk information export const availableDisks = disks.disks.apply(d => d.map(disk => ({ path: disk.devPath, size: disk.prettySize, model: disk.model, serial: disk.serial, rotational: disk.rotational, }))); ``` -------------------------------- ### Export Kubeconfig and Client Configuration Source: https://github.com/pulumiverse/pulumi-talos/blob/main/docs/_index.md Exports the raw kubeconfig string and client configuration to Pulumi outputs. This is useful for accessing cluster credentials after deployment. ```typescript pulumi.export("kubeconfig", kubeconfig.kubeconfig_raw) pulumi.export("clientConfiguration", secrets.client_configuration) ``` -------------------------------- ### Generate Talos Machine Configuration (TypeScript) Source: https://context7.com/pulumiverse/pulumi-talos/llms.txt Generates a complete machine configuration for a Talos node (controlplane or worker) based on node type, cluster endpoint, and machine secrets. Configurations can be customized with patches before being applied. This function is available as an output function. ```typescript import * as pulumi from "@pulumi/pulumi"; import * as talos from "@pulumiverse/talos"; const secrets = new talos.machine.Secrets("secrets", {}); // Generate control plane configuration const controlPlaneConfig = talos.machine.getConfigurationOutput({ clusterName: "production-cluster", machineType: "controlplane", clusterEndpoint: "https://10.0.0.10:6443", machineSecrets: secrets.machineSecrets, // Optional: specify versions kubernetesVersion: "1.30.0", talosVersion: "v1.7.5", // Optional: apply config patches configPatches: [JSON.stringify({ machine: { network: { hostname: "controlplane-1", }, install: { disk: "/dev/sda", image: "ghcr.io/siderolabs/installer:v1.7.5", }, }, cluster: { network: { podSubnets: ["10.244.0.0/16"], serviceSubnets: ["10.96.0.0/12"], }, }, })], }); // Generate worker configuration const workerConfig = talos.machine.getConfigurationOutput({ clusterName: "production-cluster", machineType: "worker", clusterEndpoint: "https://10.0.0.10:6443", machineSecrets: secrets.machineSecrets, configPatches: [JSON.stringify({ machine: { install: { disk: "/dev/sda", }, }, })], }); export const controlPlaneMachineConfig = controlPlaneConfig.machineConfiguration; export const workerMachineConfig = workerConfig.machineConfiguration; ``` -------------------------------- ### Generate Talos Machine Secrets (TypeScript) Source: https://context7.com/pulumiverse/pulumi-talos/llms.txt Generates cryptographic secrets required for a Talos cluster, including certificates for etcd, Kubernetes, and OS communication. This is typically the first resource created, as others depend on these secrets. It exports client configuration for talosctl and the machine secrets themselves. ```typescript import * as pulumi from "@pulumi/pulumi"; import * as talos from "@pulumiverse/talos"; // Generate machine secrets for the cluster const secrets = new talos.machine.Secrets("clusterSecrets", { // Optional: specify Talos version for feature compatibility talosVersion: "v1.7.5", }); // Export the client configuration for use with talosctl export const clientConfiguration = secrets.clientConfiguration; export const machineSecrets = secrets.machineSecrets; // The secrets resource generates: // - clientConfiguration: Contains CA cert, client cert, and client key for talosctl // - machineSecrets: Contains cluster ID, secret, bootstrap token, certificates for etcd, k8s, OS ``` -------------------------------- ### Retrieve Talos Cluster Kubeconfig Source: https://context7.com/pulumiverse/pulumi-talos/llms.txt Retrieves the kubeconfig from a bootstrapped Talos cluster using the Kubeconfig resource. This allows interaction with the Kubernetes cluster via kubectl or other clients. It can optionally configure certificate renewal duration. ```typescript import * as pulumi from "@pulumi/pulumi"; import * as talos from "@pulumiverse/talos"; const secrets = new talos.machine.Secrets("secrets", {}); // ... (configuration and bootstrap resources) // Retrieve kubeconfig from the cluster const kubeconfig = new talos.cluster.Kubeconfig("kubeconfig", { clientConfiguration: secrets.clientConfiguration, node: "10.5.0.2", // Optional: specify a different endpoint for the kubeconfig endpoint: "10.5.0.2", // Optional: certificate renewal duration (default: 720h) certificateRenewalDuration: "8760h", // 1 year timeouts: { create: "5m", update: "5m", }, }); // Export the raw kubeconfig string export const kubeconfigRaw = kubeconfig.kubeconfigRaw; // Access individual kubernetes client configuration components export const k8sHost = kubeconfig.kubernetesClientConfiguration.host; export const k8sCaCert = kubeconfig.kubernetesClientConfiguration.caCertificate; export const k8sClientCert = kubeconfig.kubernetesClientConfiguration.clientCertificate; ``` -------------------------------- ### Wait for Talos Cluster Health (TypeScript) Source: https://context7.com/pulumiverse/pulumi-talos/llms.txt The `getHealthOutput` function waits for and verifies the health of a Talos cluster, checking both control plane and worker nodes. It can optionally skip Kubernetes component checks to only verify that nodes are booted and running. This is useful for ensuring cluster readiness before deploying other resources. ```typescript import * as pulumi from "@pulumi/pulumi"; import * as talos from "@pulumiverse/talos"; const secrets = new talos.machine.Secrets("secrets", {}); // ... (other resources like bootstrap) // Wait for cluster health before proceeding const clusterHealth = talos.cluster.getHealthOutput({ clientConfiguration: secrets.clientConfiguration, controlPlaneNodes: ["10.5.0.2", "10.5.0.3", "10.5.0.4"], workerNodes: ["10.5.0.10", "10.5.0.11"], endpoints: ["10.5.0.2"], // Use at least one control plane endpoint // Skip k8s checks to only verify nodes are running skipKubernetesChecks: false, timeouts: { read: "15m", // Wait up to 15 minutes for cluster health }, }); // Use health check as a dependency for other resources const postHealthResource = new SomeResource("post-health", { // ... properties }, { dependsOn: [clusterHealth], }); ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.