### Install Prerequisites with Homebrew Source: https://github.com/siderolabs/contrib/blob/main/examples/terraform/oci/README.md Installs necessary command-line tools for Oracle Cloud, Terraform, and Talos using Homebrew. Ensure Homebrew is installed and updated before running this command. ```bash brew install oci-cli hashicorp/tap/terraform siderolabs/tap/talosctl qemu ``` -------------------------------- ### Pulumi CLI Commands for GCP Deployment Source: https://context7.com/siderolabs/contrib/llms.txt These bash commands demonstrate how to initialize, configure, deploy, and access a Talos cluster on GCP using the Pulumi CLI. Ensure you have Pulumi installed and authenticated with GCP. ```bash # Initialize and configure cd examples/pulumi/gcp pulumi stack init production pulumi config set gcp:project my-gcp-project pulumi config set region us-west1 pulumi config set zone us-west1-a # Deploy infrastructure pulumi up --yes # Get cluster access KUBECONFIG_DATA=$(pulumi stack output kubeconfig --show-secrets) echo "$KUBECONFIG_DATA" > kubeconfig.yaml export KUBECONFIG=./kubeconfig.yaml # Verify cluster kubectl get nodes -o wide kubectl cluster-info ``` -------------------------------- ### Terraform AWS Deployment Initialization Source: https://context7.com/siderolabs/contrib/llms.txt This snippet demonstrates the initial steps for deploying a Talos cluster on AWS using Terraform. It involves navigating to the example directory and initializing the Terraform working environment. This prepares the project for subsequent configuration and deployment commands. ```bash # Clone and navigate to AWS example cd examples/terraform/aws # Initialize Terraform terraform init ``` -------------------------------- ### Talos Cluster Configuration and Deployment using talosctl Source: https://context7.com/siderolabs/contrib/llms.txt This section details the command-line usage of 'talosctl' for configuring and deploying a Talos cluster. It covers generating initial configurations, applying various patches for network, storage, and application manifests, bootstrapping the cluster, and verifying the deployment. The commands assume a single-node setup and require specific IP addresses and disk paths. ```bash # Generate base configuration for single node talosctl gen config omni-seed https://192.168.1.10:6443 \ --install-disk /dev/sda # Apply network, storage, and app patches talosctl apply-config --insecure \ --nodes 192.168.1.10 \ --file controlplane.yaml \ --config-patch @omni-network-config.yaml \ --config-patch @omni-storage-config.yaml \ --config-patch @omni-single-node-options.yaml \ --config-patch @omni-app-manifests.yaml # Bootstrap the cluster talosctl bootstrap --nodes 192.168.1.10 # Verify Omni is running talosctl kubeconfig --nodes 192.168.1.10 kubectl get pods -n omni-system kubectl logs -n omni-system deployment/omni # Access Omni at https://192.168.1.20 (or your configured OMNI_DOMAIN) # Login with the initial user email specified in OMNI_INITIAL_USER_EMAIL ``` -------------------------------- ### Initialize Terraform Providers Source: https://github.com/siderolabs/contrib/blob/main/examples/terraform/basic/README.md Initializes the Terraform working directory, downloading the necessary providers for the project. Run this command from the project's root directory. ```bash terraform init ``` -------------------------------- ### Install Prerequisites using Homebrew Source: https://github.com/siderolabs/contrib/blob/main/examples/terraform/hcloud/README.md Installs necessary command-line tools like hcloud, talosctl, packer, and terraform using Homebrew. Ensure you have Homebrew installed and check the latest versions of talosctl from its GitHub repository. ```bash # hcloud cli brew install hcloud # talosctl, check for latest version https://github.com/siderolabs/talos sudo curl -Lo /usr/local/bin/talosctl https://github.com/siderolabs/talos/releases/download/v1.3.0/talosctl-$(uname -s | tr "[:upper:]" "[:lower:]")-amd64 sudo chmod +x /usr/local/bin/talosctl # hashicorp packer brew tap hashicorp/tap brew install hashicorp/tap/packer # hashicrop terraform brew install hashicorp/tap/terraform ``` -------------------------------- ### Sync Cluster Template with Omni CLI Source: https://github.com/siderolabs/contrib/blob/main/examples/omni/README.md This command synchronizes the cluster template configuration with the Omni instance. It requires the `omnictl` CLI tool and a `cluster-template.yaml` file. Omni then provisions machines, installs Talos, and bootstraps the Kubernetes cluster. ```bash omnictl cluster template sync --file cluster-template.yaml ``` -------------------------------- ### Deploy Talos Cluster with Terraform Source: https://context7.com/siderolabs/contrib/llms.txt This sequence of commands uses Terraform to plan and apply the deployment of a Talos Linux cluster. It first generates a plan, then applies it to create the infrastructure, and finally extracts credentials for Talos and Kubernetes administration. Dependencies include Terraform installed and configured. ```bash # Plan deployment terraform plan -out=tfplan # Deploy cluster terraform apply tfplan # Extract credentials terraform output -raw talosconfig > ~/.talos/config terraform output -raw kubeconfig > ~/.kube/config ``` -------------------------------- ### Argo CD ApplicationSet for Git-Based Deployment Source: https://context7.com/siderolabs/contrib/llms.txt This ApplicationSet generator uses a Git repository to define applications. It looks for directories matching 'apps/*/*' and deploys them to the Kubernetes cluster. It automatically handles application synchronization and namespace creation. ```yaml apiVersion: argoproj.io/v1alpha1 kind: ApplicationSet metadata: name: cluster-bootstrap namespace: argocd spec: goTemplate: true generators: - git: repoURL: https://github.com/your-org/your-repo.git revision: HEAD directories: - path: apps/*/* template: metadata: name: '{{.path.basename}}' spec: project: default source: repoURL: https://github.com/your-org/your-repo.git targetRevision: HEAD path: '{{.path.path}}' destination: server: https://kubernetes.default.svc namespace: '{{index .path.segments 1}}' syncPolicy: automated: prune: true selfHeal: true syncOptions: - CreateNamespace=true ``` -------------------------------- ### Terraform Commands for Oracle Cloud Deployment Source: https://github.com/siderolabs/contrib/blob/main/examples/terraform/oci/README.md Standard Terraform commands to initialize, plan, apply, and destroy resources for the Oracle Cloud Kubernetes deployment. Use -var-file=.tfvars to specify your configuration. ```bash terraform init ``` ```bash terraform plan -var-file=.tfvars ``` ```bash terraform apply -var-file=.tfvars ``` ```bash terraform output -raw talosconfig > ./talosconfig ``` ```bash terraform output -raw kubeconfig > ./kubeconfig ``` ```bash terraform destroy -var-file=.tfvars -target=random_pet.worker ``` ```bash terraform destroy -var-file=.tfvars ``` -------------------------------- ### Pulumi: Deploy and Manage Azure Infrastructure Source: https://context7.com/siderolabs/contrib/llms.txt This snippet outlines the CLI commands for deploying a Talos cluster on Azure using Pulumi and Go. It includes initializing a Pulumi stack, configuring deployment settings like the Azure location, deploying the infrastructure with `pulumi up`, and exporting the stack outputs. It also shows how to verify the deployment using `kubectl`. ```bash # Initialize Pulumi project cd examples/pulumi/azure pulumi stack init prod # Configure Azure location pulumi config set location eastus # Deploy infrastructure pulumi up # Export outputs pulumi stack output loadBalancerIP pulumi stack output talosConfig --show-secrets > ~/.talos/config # Verify deployment kubectl --kubeconfig <(pulumi stack output kubeconfig --show-secrets) get nodes ``` -------------------------------- ### Output Talos Cluster Kubeconfig Source: https://github.com/siderolabs/contrib/blob/main/examples/terraform/basic/README.md Retrieves the kubeconfig file for the provisioned Talos cluster and saves it to a specified file path. This allows you to interact with the cluster using kubectl. ```bash terraform output -raw kubeconfig > ``` -------------------------------- ### Output Talos Cluster Talosconfig Source: https://github.com/siderolabs/contrib/blob/main/examples/terraform/basic/README.md Retrieves the talosconfig file for the provisioned Talos cluster and saves it to a specified file path. This configuration is used for managing the Talos cluster itself. ```bash terraform output -raw talosconfig > ``` -------------------------------- ### Terraform Configuration Variables for Oracle Cloud Source: https://github.com/siderolabs/contrib/blob/main/examples/terraform/oci/README.md Example of a .tfvars file to configure Terraform authentication and resource naming for Oracle Cloud. Replace placeholder values with your specific Oracle Cloud credentials and identifiers. ```hcl tenancy_ocid = "TENANCY OCID : https://cloud.oracle.com/tenancy" user_ocid = "YOUR USER OCID : https://cloud.oracle.com/identity/domains/my-profile" private_key_path = "YOUR PRIVATE KEY PATH : https://cloud.oracle.com/identity/domains/my-profile/api-keys" fingerprint = "THE FINGERPRINT FOR YOUR PRIVATE KEY : ^^" region = "YOUR PREFERRED REGION : https://cloud.oracle.com/regions" compartment_ocid = "YOUR COMPARTMENT OCID : https://cloud.oracle.com/identity/compartments" talos_image_oci_bucket_url = "YOUR DEDICATED BUCKET OBJECT URL : https://cloud.oracle.com/object-storage/buckets" ``` -------------------------------- ### Omni CLI for Cluster Management Source: https://context7.com/siderolabs/contrib/llms.txt These commands illustrate the process of syncing cluster templates, monitoring cluster creation, accessing cluster credentials, and verifying deployed applications using the 'omnictl' command-line interface. It covers syncing, listing, showing, and obtaining kubeconfig for clusters, as well as checking pod status across different namespaces. ```bash # Sync cluster template to Omni omnictl cluster template sync --file infra/cluster-template.yaml # Monitor cluster creation omnictl cluster list omnictl cluster show omni-contrib # Access cluster once ready omnictl kubeconfig omni-contrib > kubeconfig export KUBECONFIG=./kubeconfig # Verify applications are deployed kubectl get pods -n argocd kubectl get pods -n kube-system kubectl get pods -n monitoring # Access Hubble UI via Omni workload proxy # Navigate to: https:///omni/workload-proxy/omni-contrib/kube-system/hubble-ui ``` -------------------------------- ### Apply Terraform Configuration to Create Cluster Source: https://github.com/siderolabs/contrib/blob/main/examples/terraform/basic/README.md Applies the Terraform configuration to create a default Talos cluster. You must provide the `cluster_name` and `cluster_endpoint` variables. The `cluster_endpoint` should be in the format 'https://:6443'. ```bash terraform apply -var="cluster_name=" -var="cluster_endpoint=https://:6443" ``` -------------------------------- ### Terraform: Deploy Talos Cluster and Retrieve Credentials Source: https://context7.com/siderolabs/contrib/llms.txt This snippet shows how to use Terraform to deploy a Talos cluster and then output the kubeconfig and talosconfig. It requires Terraform to be initialized and the cluster to be applied with specific variables. The output is directed to standard output for easy redirection to configuration files. ```bash # Initialize Terraform terraform init # Deploy the cluster terraform apply \ -var="cluster_name=talos-prod" \ -var="cluster_endpoint=https://10.5.0.2:6443" # Extract kubeconfig terraform output -raw kubeconfig > ~/.kube/config # Extract talosconfig terraform output -raw talosconfig > ~/.talos/config # Verify cluster health kubectl get nodes ``` -------------------------------- ### Cilium Helm Chart Configuration Source: https://context7.com/siderolabs/contrib/llms.txt This YAML configuration defines the Helm chart for Cilium, a network security solution for Kubernetes. It specifies the chart version, repository, and custom values for IPAM, kube-proxy replacement, and Hubble. ```yaml # apps/kube-system/cilium/Chart.yaml apiVersion: v2 name: cilium version: 1.0.0 dependencies: - name: cilium version: 1.16.5 repository: https://helm.cilium.io/ # apps/kube-system/cilium/values.yaml cilium: ipam: mode: kubernetes kubeProxyReplacement: true k8sServiceHost: localhost k8sServicePort: 7445 securityContext: privileged: true cgroup: autoMount: enabled: false hostRoot: /sys/fs/cgroup hubble: enabled: true ui: enabled: true ``` -------------------------------- ### Repack Talos Image for Oracle Cloud Source: https://github.com/siderolabs/contrib/blob/main/examples/terraform/oci/README.md Commands to decompress, convert, and repack a Talos Linux disk image for Oracle Cloud. This process involves preparing the raw image and bundling it with metadata. ```bash xz --decompress DISK_IMAGE.raw.xz ``` ```bash qemu-img convert -f raw -O qcow2 oracle-arm64.raw oracle-arm64.qcow2 ``` ```bash tar zcf oracle-arm64.oci oracle-arm64.qcow2 image_metadata.json ``` -------------------------------- ### Pulumi Go Program for GCP Talos Cluster Deployment Source: https://context7.com/siderolabs/contrib/llms.txt This Go program uses Pulumi to provision infrastructure on GCP for a Talos cluster. It handles creating storage buckets, compute images, networks, IP addresses, firewall rules, and VM instances, then bootstraps the Talos cluster. It requires the Pulumi CLI and GCP credentials. ```go // main.go package main import ( "github.com/pulumi/pulumi-gcp/sdk/v6/go/gcp/compute" "github.com/pulumi/pulumi-gcp/sdk/v6/go/gcp/storage" "github.com/pulumi/pulumi/sdk/v3/go/pulumi" "github.com/pulumi/pulumi/sdk/v3/go/pulumi/config" "github.com/siderolabs/pulumi-provider-talos/sdk/go/talos" ) const ( ClusterName = "talos" TalosVersion = "v1.11.5" ControlPlaneNodesCount = 3 WorkerNodesCount = 2 ) type ResourceInfo struct { PulumiConfig *config.Config BucketLocation string Region string Zone string Bucket *storage.Bucket Image *compute.Image Network *compute.Network CPInstances []*compute.Instance CPAddresses map[string]*compute.Address WorkerAddresses map[string]*compute.Address LBAddress *compute.GlobalAddress TalosClusterConfig *talos.ClusterConfig TalosClusterSecrets *talos.ClusterSecrets } func main() { pulumi.Run(func(ctx *pulumi.Context) error { ri := ResourceInfo{ CPInstances: []*compute.Instance{}, CPAddresses: map[string]*compute.Address{}, WorkerAddresses: map[string]*compute.Address{}, } ri.PulumiConfig = config.New(ctx, "") region := ri.PulumiConfig.Get("region") if region == "" { region = "us-central1" } ri.Region = region zone := ri.PulumiConfig.Get("zone") if zone == "" { zone = "us-central1-a" } ri.Zone = zone // Create GCS bucket for Talos image if err := ri.createStorage(ctx); err != nil { return err } // Upload Talos image and create compute image if err := ri.createImage(ctx); err != nil { return err } // Create VPC network if err := ri.createNetworks(ctx); err != nil { return err } // Reserve static IPs for control plane if err := ri.createCPAddresses(ctx); err != nil { return err } // Reserve static IPs for workers if err := ri.createWorkerAddresses(ctx); err != nil { return err } // Reserve global IP for load balancer if err := ri.createLBAddress(ctx); err != nil { return err } // Setup firewall rules if err := ri.createFirewalls(ctx); err != nil { return err } // Generate Talos configurations if err := ri.createConfigs(ctx); err != nil { return err } // Create control plane instances if err := ri.createCPVMs(ctx); err != nil { return err } // Create worker instances if err := ri.createWorkerVMs(ctx); err != nil { return err } // Create Kubernetes API load balancer if err := ri.createLB(ctx); err != nil { return err } // Bootstrap cluster if err := ri.bootstrapTalos(ctx); err != nil { return err } // Export outputs for _, ip := range ri.CPAddresses { ctx.Export("controlPlaneIP", ip.Address) } ctx.Export("loadBalancerIP", ri.LBAddress.Address) ctx.Export("talosConfig", ri.TalosClusterSecrets.TalosConfig) return nil }) } ``` -------------------------------- ### Destroy Terraform Managed Talos Cluster Source: https://github.com/siderolabs/contrib/blob/main/examples/terraform/basic/README.md Destroys the Talos cluster created by the Terraform configuration. This command will remove all resources managed by the Terraform project. ```bash terraform destroy ``` -------------------------------- ### Kubernetes Manifests for Omni and Dex Source: https://context7.com/siderolabs/contrib/llms.txt This YAML file defines Kubernetes resources for deploying the Omni application and Dex Identity Services. It includes a namespace, deployments for Omni and Dex, and associated configurations for networking, storage, and application-specific settings. Dependencies include Docker images for Omni and Dex, and Kubernetes secrets for TLS certificates and OIDC client secrets. ```yaml apiVersion: v1 kind: Namespace metadata: name: omni-system --- apiversion: apps/v1 kind: Deployment metadata: name: omni namespace: omni-system spec: replicas: 1 selector: matchLabels: app: omni template: metadata: labels: app: omni spec: hostNetwork: true containers: - name: omni image: ghcr.io/siderolabs/omni:v0.45.0 ports: - containerPort: 443 hostPort: 443 hostIP: 192.168.1.20 env: - name: OMNI_ACCOUNT_ID value: "01234567-89ab-cdef-0123-456789abcdef" - name: OMNI_NAME value: "Production Omni" - name: OMNI_AUTH_AUTH0_ENABLED value: "false" - name: OMNI_AUTH_OIDC_ENABLED value: "true" - name: OMNI_AUTH_OIDC_URL value: "https://auth.example.com/dex" - name: OMNI_AUTH_OIDC_CLIENT_ID value: "omni" - name: OMNI_AUTH_OIDC_CLIENT_SECRET valueFrom: secretKeyRef: name: omni-secrets key: oidc-client-secret - name: OMNI_INITIAL_USER_EMAIL value: "admin@example.com" volumeMounts: - name: omni-data mountPath: /var/lib/omni - name: omni-certs mountPath: /etc/ssl/omni readOnly: true volumes: - name: omni-data hostPath: path: /var/omni/data type: DirectoryOrCreate - name: omni-certs secret: secretName: omni-tls --- apiversion: apps/v1 kind: Deployment metadata: name: dex namespace: omni-system spec: replicas: 1 selector: matchLabels: app: dex template: metadata: labels: app: dex spec: hostNetwork: true containers: - name: dex image: ghcr.io/dexidp/dex:v2.41.1 command: ["/usr/local/bin/dex"] args: ["serve", "/etc/dex/config.yaml"] ports: - containerPort: 443 hostPort: 443 hostIP: 192.168.1.21 volumeMounts: - name: dex-config mountPath: /etc/dex - name: dex-certs mountPath: /etc/ssl/dex readOnly: true volumes: - name: dex-config secret: secretName: dex-config - name: dex-certs secret: secretName: dex-tls ``` -------------------------------- ### Pulumi Go: Deploy Talos Cluster on Azure Source: https://context7.com/siderolabs/contrib/llms.txt This Go program uses Pulumi to deploy a complete Talos cluster on Azure. It defines constants for cluster configuration and includes detailed steps for creating Azure resources like resource groups, storage accounts, virtual networks, and virtual machines. The program exports essential outputs such as the load balancer IP and Talos configuration. ```go // main.go package main import ( "github.com/pulumi/pulumi-azure/sdk/v5/go/azure/compute" "github.com/pulumi/pulumi-azure/sdk/v5/go/azure/core" "github.com/pulumi/pulumi-azure/sdk/v5/go/azure/lb" "github.com/pulumi/pulumi-azure/sdk/v5/go/azure/network" "github.com/pulumi/pulumi-azure/sdk/v5/go/azure/storage" "github.com/pulumi/pulumi/sdk/v3/go/pulumi" "github.com/pulumi/pulumi/sdk/v3/go/pulumi/config" "github.com/siderolabs/pulumi-provider-talos/sdk/go/talos" ) const ( ClusterName = "talos" TalosVersion = "v1.11.5" ControlPlaneNodesCount = 3 WorkerNodesCount = 2 ) type ResourceInfo struct { Location string ResourceGroup *core.ResourceGroup StorageAcct *storage.Account StorageContainer *storage.Container Image *compute.Image Subnet *network.Subnet CPSecurityGroup *network.NetworkSecurityGroup CPNics map[string]*network.NetworkInterface CPPubIPs pulumi.StringArray WorkerSecurityGroup *network.NetworkSecurityGroup WorkerNics map[string]*network.NetworkInterface LBPubIP *lb.PublicIp LBBackendPool *lb.BackendAddressPool TalosClusterConfig *talos.ClusterConfig TalosClusterSecrets *talos.ClusterSecrets } func (ri *ResourceInfo) createRG(ctx *pulumi.Context) error { resourceGroup, err := core.NewResourceGroup( ctx, ClusterName+"-rg", &core.ResourceGroupArgs{ Location: pulumi.String(ri.Location), Name: pulumi.String(ClusterName + "-rg"), }, ) if err != nil { return err } ri.ResourceGroup = resourceGroup return nil } func main() { pulumi.Run(func(ctx *pulumi.Context) error { ri := ResourceInfo{ CPNics: map[string]*network.NetworkInterface{}, WorkerNics: map[string]*network.NetworkInterface{}, } c := config.New(ctx, "") location := c.Get("location") if location == "" { location = "centralus" } ri.Location = location // Create Azure Resource Group if err := ri.createRG(ctx); err != nil { return err } // Create Storage Account and upload Talos image if err := ri.createStorage(ctx); err != nil { return err } // Create Talos VM image from uploaded blob if err := ri.createImage(ctx); err != nil { return err } // Setup network security groups if err := ri.createSecurityGroups(ctx); err != nil { return err } // Create virtual networks and subnets if err := ri.CreateNetworks(ctx); err != nil { return err } // Setup load balancer for Kubernetes API if err := ri.createLB(ctx); err != nil { return err } // Create network interfaces for control plane if err := ri.createCPNics(ctx); err != nil { return err } // Create network interfaces for workers if err := ri.createWorkerNics(ctx); err != nil { return err } // Generate Talos machine configurations if err := ri.createConfigs(ctx); err != nil { return err } // Create control plane VMs if err := ri.createCPVMs(ctx); err != nil { return err } // Create worker VMs if err := ri.createWorkerVMs(ctx); err != nil { return err } // Bootstrap Talos cluster if err := ri.bootstrapTalos(ctx); err != nil { return err } // Export outputs ctx.Export("loadBalancerIP", ri.LBPubIP.IpAddress) ctx.Export("controlPlaneIPs", ri.CPPubIPs) ctx.Export("talosConfig", ri.TalosClusterSecrets.TalosConfig) return nil }) } ``` -------------------------------- ### Retrieve Kubeconfig and Talosconfig Source: https://github.com/siderolabs/contrib/blob/main/examples/terraform/azure/README.md These commands use `terraform output` to retrieve the generated kubeconfig and talosconfig files for the deployed Talos cluster. The output is redirected to specified file paths for easy access and use with kubectl and Talosctl. ```shell terraform output -raw kubeconfig > ``` ```shell terraform output -raw talosconfig > ``` -------------------------------- ### Deploy Talos Cluster with Terraform Source: https://github.com/siderolabs/contrib/blob/main/examples/terraform/hcloud/README.md Initializes Terraform, plans the deployment, and applies the configuration to create the Talos cluster on Hetzner Cloud. This example uses `three_workers.tfvars` to define a cluster with three worker nodes. ```bash cd terraform terraform init # example with three worker nodes terraform plan -var-file=three_workers.tfvars terraform apply -var-file=three_workers.tfvars ``` -------------------------------- ### Talos Machine Storage Configuration for Omni Source: https://context7.com/siderolabs/contrib/llms.txt This YAML snippet outlines the storage configuration for a Talos machine running Omni. It defines disk partitions, including a dedicated mount point for Omni data, and configures kubelet to bind-mount the Omni data directory. This ensures persistent storage for Omni. ```yaml # omni-storage-config.yaml machine: disks: - device: /dev/disk/by-id/scsi-0DO_Volume_data partitions: - mountpoint: /var/omni size: 10GB kubelet: extraMounts: - destination: /var/omni type: bind source: /var/omni options: - bind - rshared - rw ``` -------------------------------- ### CNI Configuration Patch for Omni Cluster Source: https://context7.com/siderolabs/contrib/llms.txt This YAML patch configures the CNI (Container Network Interface) for the Omni cluster. It sets the CNI to 'none', indicating that no specific CNI plugin will be managed by Talos. ```yaml # infra/patches/cni.yaml - op: add path: /cluster/network/cni value: name: none ``` -------------------------------- ### Download Talos Azure Disk Image Source: https://github.com/siderolabs/contrib/blob/main/examples/terraform/azure/README.md This command downloads the latest release of the Talos disk image for Azure (amd64 architecture) and extracts it. This image is required to be provided as a storage blob in Azure for the Terraform deployment. ```bash curl -sL https://github.com/siderolabs/talos/releases/latest/download/azure-amd64.tar.gz | tar -xz ``` -------------------------------- ### Terraform Basic Talos Cluster Deployment Source: https://context7.com/siderolabs/contrib/llms.txt Deploys a basic Talos Linux Kubernetes cluster using Terraform. It configures machine secrets, control plane and worker node configurations, applies them to existing machines, bootstraps the cluster, and generates a kubeconfig. Requires the Talos Terraform provider. ```terraform # main.tf terraform { required_providers { talos = { source = "siderolabs/talos" version = "0.10.0-beta.0" } } } # Generate machine secrets for cluster resource "talos_machine_secrets" "this" {} # Generate control plane configuration data "talos_machine_configuration" "controlplane" { cluster_name = var.cluster_name cluster_endpoint = var.cluster_endpoint machine_type = "controlplane" machine_secrets = talos_machine_secrets.this.machine_secrets } # Generate worker configuration data "talos_machine_configuration" "worker" { cluster_name = var.cluster_name cluster_endpoint = var.cluster_endpoint machine_type = "worker" machine_secrets = talos_machine_secrets.this.machine_secrets } # Apply configuration to control plane nodes resource "talos_machine_configuration_apply" "controlplane" { client_configuration = talos_machine_secrets.this.client_configuration machine_configuration_input = data.talos_machine_configuration.controlplane.machine_configuration for_each = var.node_data.controlplanes node = each.key config_patches = [ templatefile("${path.module}/templates/install-disk-and-hostname.yaml.tmpl", { hostname = each.value.hostname == null ? format("%s-cp-%s", var.cluster_name, index(keys(var.node_data.controlplanes), each.key)) : each.value.hostname install_disk = each.value.install_disk }), file("${path.module}/files/cp-scheduling.yaml"), ] } # Apply configuration to worker nodes resource "talos_machine_configuration_apply" "worker" { client_configuration = talos_machine_secrets.this.client_configuration machine_configuration_input = data.talos_machine_configuration.worker.machine_configuration for_each = var.node_data.workers node = each.key config_patches = [ templatefile("${path.module}/templates/install-disk-and-hostname.yaml.tmpl", { hostname = each.value.hostname == null ? format("%s-worker-%s", var.cluster_name, index(keys(var.node_data.workers), each.key)) : each.value.hostname install_disk = each.value.install_disk }) ] } # Bootstrap the cluster resource "talos_machine_bootstrap" "this" { depends_on = [talos_machine_configuration_apply.controlplane] client_configuration = talos_machine_secrets.this.client_configuration node = [for k, v in var.node_data.controlplanes : k][0] } # Generate kubeconfig resource "talos_cluster_kubeconfig" "this" { depends_on = [talos_machine_bootstrap.this] client_configuration = talos_machine_secrets.this.client_configuration node = [for k, v in var.node_data.controlplanes : k][0] } # variables.tf variable "cluster_name" { description = "A name to provide for the Talos cluster" type = string } variable "cluster_endpoint" { description = "The endpoint for the Talos cluster" type = string } variable "node_data" { description = "A map of node data" type = object({ controlplanes = map(object({ install_disk = string hostname = optional(string) })) workers = map(object({ install_disk = string hostname = optional(string) })) }) default = { controlplanes = { "10.5.0.2" = { install_disk = "/dev/sda" } "10.5.0.3" = { install_disk = "/dev/sda" } "10.5.0.4" = { install_disk = "/dev/sda" } } workers = { "10.5.0.5" = { hostname = "worker-1", install_disk = "/dev/nvme0n1" } "10.5.0.6" = { hostname = "worker-2", install_disk = "/dev/nvme0n1" } } } } ``` -------------------------------- ### Terraform HCL Configuration Snippet Source: https://github.com/siderolabs/contrib/blob/main/examples/terraform/basic/README.md This is a snippet of a Terraform HCL configuration file that defines resources for creating and managing a Talos cluster. It includes requirements, providers, and resource definitions for cluster creation, machine configuration, and secret management. ```hcl terraform { required_providers { talos = { source = "siderolabs/talos" version = "0.10.0-beta.0" } } } provider "talos" { version = "0.10.0-beta.0" } resource "talos_cluster_kubeconfig" "this" { # ... resource configuration ... } resource "talos_machine_bootstrap" "this" { # ... resource configuration ... } resource "talos_machine_configuration_apply" "controlplane" { # ... resource configuration ... } resource "talos_machine_configuration_apply" "worker" { # ... resource configuration ... } resource "talos_machine_secrets" "this" { # ... resource configuration ... } data "talos_client_configuration" "this" { # ... data source configuration ... } data "talos_machine_configuration" "controlplane" { # ... data source configuration ... } data "talos_machine_configuration" "worker" { # ... data source configuration ... } ``` -------------------------------- ### Terraform Azure and Talos Provider Usage Source: https://github.com/siderolabs/contrib/blob/main/examples/terraform/azure/README.md This section lists the providers used in the Terraform configuration, including azurerm for Azure resources and talos for Talos-specific configurations. It specifies the exact versions of these providers being utilized. ```hcl provider "azurerm" { features {} } provider "talos" { version = "0.10.0-beta.0" } ``` -------------------------------- ### Define Talos Image Metadata for Oracle Cloud Source: https://github.com/siderolabs/contrib/blob/main/examples/terraform/oci/README.md Defines metadata for a Talos Linux image to be used with Oracle Cloud. This JSON file specifies launch options, operating system details, and shape compatibilities. ```json { "version": 2, "externalLaunchOptions": { "firmware": "UEFI_64", "networkType": "PARAVIRTUALIZED", "bootVolumeType": "PARAVIRTUALIZED", "remoteDataVolumeType": "PARAVIRTUALIZED", "localDataVolumeType": "PARAVIRTUALIZED", "launchOptionsSource": "PARAVIRTUALIZED", "pvAttachmentVersion": 2, "pvEncryptionInTransitEnabled": true, "consistentVolumeNamingEnabled": true }, "imageCapabilityData": null, "imageCapsFormatVersion": null, "operatingSystem": "Talos", "operatingSystemVersion": "1.8.0", "additionalMetadata": { "shapeCompatibilities": [ { "internalShapeName": "VM.Standard.A1.Flex", "ocpuConstraints": null, "memoryConstraints": null } ] } } ``` -------------------------------- ### Terraform Azure Provider Configuration Source: https://github.com/siderolabs/contrib/blob/main/examples/terraform/azure/README.md This block defines the required Terraform version and the Azure Resource Manager (azurerm) provider, specifying version constraints. It ensures that the correct Terraform and azurerm provider versions are used for the deployment. ```hcl terraform { required_providers { azurerm = { source = "hashicorp/azurerm" version = "~> 3.0" } } required_version = ">= 1.3" } ``` -------------------------------- ### Omni Cluster Template for Talos Deployment Source: https://context7.com/siderolabs/contrib/llms.txt This YAML configuration defines a managed Talos cluster using Sidero Omni. It specifies cluster-level settings, control plane and worker machine classes, and applies patches for CNI, Cilium, ArgoCD, and monitoring. ```yaml # infra/cluster-template.yaml kind: Cluster name: omni-contrib talos: version: v1.11.5 kubernetes: version: 1.34.2 features: enableWorkloadProxy: true patches: - name: cni file: patches/cni.yaml --- kind: ControlPlane machineClass: name: omni-contrib-controlplane size: 3 patches: - name: cilium file: patches/cilium.yaml - name: argocd file: patches/argocd.yaml - name: monitoring file: patches/monitoring.yaml --- kind: Workers name: workers machineClass: name: omni-contrib-workers size: unlimited ``` -------------------------------- ### Terraform Apply Command Source: https://github.com/siderolabs/contrib/blob/main/examples/terraform/azure/README.md The `terraform apply` command is used to create the Talos cluster on Azure. It provisions all necessary resources defined in the Terraform configuration. This command may occasionally need to be re-run if Azure resources are not immediately available. ```shell terraform apply ``` -------------------------------- ### Create terraform.tfvars for Talos Cluster Deployment Source: https://context7.com/siderolabs/contrib/llms.txt This snippet defines the configuration for a Talos Linux cluster in AWS using Terraform. It specifies cluster details, instance types, network CIDRs, and tags for control plane and worker nodes. Dependencies include Terraform and a configured AWS provider. ```terraform cat > terraform.tfvars < ``` -------------------------------- ### Retrieve and Configure Talos/Kubeconfig Source: https://github.com/siderolabs/contrib/blob/main/examples/terraform/hcloud/README.md Retrieves the `talosconfig` and `kubeconfig` from Terraform outputs and sets them as environment variables. It then verifies cluster member and node status using `talosctl` and `kubectl` respectively. ```bash terraform output -raw talosconfig > ~/hcloud-dev-cluster/talosconfig terraform output -raw kubeconfig > ~/hcloud-dev-cluster/kubeconfig export TALOSCONFIG=~/hcloud-dev-cluster/talosconfig export KUBECONFIG=~/hcloud-dev-cluster/kubeconfig # check if all nodes are available, target the control plane (default 10.0.0.3 set in variables.tf) talosctl get members -n 10.0.0.3 # check nodes kubectl get nodes -o wide ``` -------------------------------- ### Export Hetzner Cloud Token Source: https://github.com/siderolabs/contrib/blob/main/examples/terraform/hcloud/README.md Sets the HCLOUD_TOKEN environment variable, which is required for the hcloud CLI and Terraform to authenticate with your Hetzner Cloud account. ```bash export HCLOUD_TOKEN= ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.