Talos Linux Documentation

repository·main·Indexed 27 days ago

https://github.com/siderolabs/talos

Talos is a modern, secure, and immutable operating system purpose-built for Kubernetes. It is managed entirely via an API, eliminating traditional shell access to reduce the attack surface. Key features include API-driven management with mutual TLS (mTLS) authentication, immutable infrastructure to prevent configuration drift, and a Signer API for SecureBoot and PCR signing. The repository also includes tools like the imager CLI for boot assets, the installer for system upgrades, and custom golangci-lint plugins such as kubeimportlinter and loglinter.

Tokens
127K
Snippets
307
Records
816
Agent score
93%

What's inside Talos

  1. Overview of Talos Linux

    main

    Talos is a modern, secure, immutable, and minimal operating system designed specifically for running Kubernetes.

    Key characteristics:

    • API-Driven Management: All system management is performed via an API. There is no shell or interactive console available.
    • Security: The attack surface is minimized through hardening and immutability. All API access is secured using mutual TLS (mTLS) authentication.
    • Predictability: Employs immutable infrastructure principles to eliminate configuration drift and provides atomic updates.
    • Evolvability: Designed to simplify architecture and provide current stable versions of Kubernetes and Linux.
  2. Use the Signer API for SecureBoot and PCR signing

    main

    The Signer API is a gRPC service that allows the Talos imager to delegate SecureBoot and PCR signing tasks to an out-of-process signer. This architecture enables the use of external hardware or specialized signing processes during image creation.

    An example implementation using a YubiKey is available for reference.

  3. Understand Talos Linux machine configuration structure

    main

    Talos Linux is configured using a single YAML file known as the machine configuration. This file can contain multiple configuration documents separated by --- (three dashes) lines.

    Document Types

    • v1alpha1 document: This is the mandatory document containing the majority of configuration options. It uses a legacy structure.
    • Named documents: Documents that include a name: field. You can include multiple named documents in a single file as long as each has a unique name.
    • Unnamed documents: Documents without a name: field. You can only include one unnamed document per configuration file.

    Standard Document Fields

    Except for the v1alpha1 document, all other configuration documents must follow this schema:

    apiVersion: v1alpha1 # version of the document
    kind: NetworkRuleConfig # type of document
    name: rule1 # only for named documents
    apiVersion: v1alpha1
    kind: NetworkRuleConfig
    name: rule1
  4. Use inline exceptions in Go code

    main

    You can suppress specific loglinter issues using comments. The comment must be on the same line or the immediately preceding line.

    Single rule suppression

    // loglint:ignore <rule_name> <reason>
    log.Printf("allowed here")

    Multiple rule suppression

    Separate rules with a comma:

    // loglint:ignore rule1,rule2 reason

    Suppress all rules

    Use all to suppress every rule for the line:

    // loglint:ignore all reason
  5. Configure RawVolumeConfig for CSI provisioners

    main

    Use RawVolumeConfig to create partitions without formatting them. Raw volumes are specifically intended for use with CSI provisioners. Note that the partition label is automatically generated as r-<name>. For local storage use cases, user volumes are generally a better choice than raw volumes.

    Example configuration:

    apiVersion: v1alpha1
    kind: RawVolumeConfig
    name: local-data
    provisioning:
        diskSelector:
            match: disk.transport == "nvme"
        maxSize: 50GiB
    apiVersion: v1alpha1
    kind: RawVolumeConfig
    name: local-data # Name of the volume.
    
    # The provisioning describes how the volume is provisioned.
    provisioning:
        # The disk selector expression.
        diskSelector:
            match: disk.transport == "nvme" # The Common Expression Language (CEL) expression to match the disk.
        maxSize: 50GiB # The maximum size of the volume, if not specified the volume can grow to the size of the
  6. Configure the vmimport role for AWS

    main

    Before using the cloud-image-uploader, you must pre-create the vmimport IAM role in AWS. This requires creating the role with a specific trust policy and then attaching the necessary permissions policy.

    Ensure you have the trust-policy.json and role-policy.json files available in your working directory before running these commands.

    aws iam create-role --role-name vmimport --assume-role-policy-document file://trust-policy.json
    aws iam put-role-policy --role-name vmimport --policy-name vmimport --policy-document file://role-policy.json
  7. Configure VolumeConfig for system volumes

    main

    Use VolumeConfig to manage system volume configurations. Supported volume names are STATE, EPHEMERAL, IMAGECACHE, ETCD, CRI, KUBELET, and LOG.

    Important Note: The ETCD, CRI, KUBELET, and LOG volumes default to a directory under EPHEMERAL. They can be placed on a dedicated partition by specifying provisioning. This choice (directory vs. dedicated partition) can only be made at cluster creation time; changing it on an already-provisioned node is not supported.

    apiVersion: v1alpha1
    kind: VolumeConfig
    name: EPHEMERAL
  8. Generate bash autocompletion for talosctl

    main

    To enable autocompletion for the bash shell, you must have the bash-completion package installed.

    To load completions in your current session:

    source <(talosctl completion bash)

    To persist completions for every new session:

    Linux:

    talosctl completion bash > /etc/bash_completion.d/talosctl

    macOS:

    talosctl completion bash > $(brew --prefix)/etc/bash_completion.d/talosctl

    Note: You will need to start a new shell for the setup to take effect.

    talosctl completion bash
  9. Get support and join the Talos community

    main

    If you have questions, bugs, or feature requests, or want to join the community, use the following channels:

  10. Enable the loglinter plugin in .golangci.yml

    main

    To use loglinter, add it to the linters.enable list and define it under linters.settings.custom as a module type.

    Example configuration:

    version: "2"
    
    linters:
      enable:
        - loglinter
      settings:
        custom:
          loglinter:
            type: module
            description: checks logging conventions
            settings:
              exclude:
                - "**/*_test.go"
                - "_out/**"
                - "vendor/**"
              rules:
                slog_imports:
                  allow:
                    - "internal/app/machined/pkg/runtime/v1alpha1/platform/vmware/vmware_supported.go"
  11. Provide machine configuration via `talos.config.early` or `talos.config.inline`

    main

    These parameters allow providing the initial machine configuration directly on the kernel command line. This is suitable for small configuration documents due to the ~2000 byte kernel command line limit.

    Loading Order:

    1. Persisted configuration from STATE partition (if exists).
    2. talos.config.early.
    3. Platform-specific source (e.g., talos.config for metal).
    4. talos.config.inline.

    Format: The configuration must be zstd compressed and base64-encoded.

    Example (preparing a config):

    cat config.yaml | zstd --compress --ultra -22 | base64 -w 0