Mutual TLS (mTLS) Authentication
Talos requires mutual TLS for all API communications:- Server authentication: Client verifies the server’s identity
- Client authentication: Server verifies the client’s identity
- Encryption: All data is encrypted in transit
- No passwords: Authentication is certificate-based only
How mTLS Works
Steps:- TLS Handshake: Client and server exchange certificates
- Certificate Verification: Both sides verify certificates against their trusted CA
- Role Extraction: Server extracts roles from client certificate’s Organization field
- Authorization: Server checks if roles permit the requested operation
- Encrypted Communication: All data is encrypted with TLS 1.3
internal/app/apid/main.go:95 verifies client certificates.
Certificate Requirements
Client certificates must have:- Issuer: Signed by the Talos OS CA
- Extended Key Usage: Client Authentication
- Organization: One or more Talos roles (e.g.,
os:admin) - Validity: Not expired
Talosconfig File
Thetalosconfig file stores client credentials and cluster configuration:
Structure
Example talosconfig:pkg/machinery/config/generate/talosconfig.go:12
Fields:
context: Active context namecontexts: Map of named contextsendpoints: Talos API endpoints (control plane nodes)nodes: Target nodes for commands (defaults to endpoints)ca: Talos OS CA certificate for verifying server certificatescrt: Client certificate for authenticationkey: Client private key
The
endpoints should point to control plane nodes, while nodes can be any nodes in the cluster. If nodes is omitted, commands will target the endpoints.Talosconfig Location
By default,talosctl looks for talosconfig in:
--talosconfigflag$TALOSCONFIGenvironment variable~/.talos/config(default location)
Multiple Contexts
Manage multiple clusters in one talosconfig:Merging Talosconfigs
Merge multiple talosconfigs:- Add new contexts to your config
- Rename contexts if there are conflicts (e.g.,
prodbecomesprod-1) - Preserve your current context
pkg/machinery/client/config/config.go:211 for merge implementation.
Role-Based Access Control
Talos implements RBAC using certificate-based roles:Built-in Roles
Defined inpkg/machinery/role/role.go:14:
os:admin
Full administrative access- All API operations
- Read/write access
- Access to secrets and sensitive data
- Reboot, upgrade, reset operations
os:operator
Operational access without secrets- Most management APIs
- Reboot, cordon, drain operations
- View logs and metrics
- Cannot access secrets or sensitive configuration
os:reader
Read-only access to non-sensitive data- View system status
- Read logs (non-sensitive)
- View resource state
- Cannot modify system or access secrets
os:etcd:backup
Permission to create etcd backups- Create etcd snapshots
- Download etcd backups
- Limited to backup operations
os:impersonator
Ability to impersonate other roles- Used internally by Talos
- Can be granted to users for role delegation
- Use with extreme caution
Role Hierarchy
How Roles Work
Roles are encoded in the certificate’s Organization field: Certificate with os:admin role:pkg/machinery/role/role.go:101):
- Extract Organization fields from client certificate
- Parse into role set
- Check if role set includes required role for API
- Allow if authorized, reject if not
Generating Talosconfig
During Cluster Creation
Generate talosconfig with cluster configs:controlplane.yaml- Control plane node configworker.yaml- Worker node configtalosconfig- Admin talosconfig withos:adminrole
From Existing Secrets
Generate talosconfig from secrets bundle:With Custom Roles
Generate talosconfig with specific roles:pkg/machinery/config/generate/talosconfig.go:13
With Custom TTL
Generate short-lived certificates:Default certificate TTL is 365 days. Consider shorter TTLs for enhanced security, but ensure you have a renewal process in place.
API Access Control
Every API method requires specific roles:Example API Permissions
| API Method | Required Role | Description |
|---|---|---|
MachineService/Reboot | os:operator or os:admin | Reboot a node |
MachineService/Dmesg | os:reader or higher | View kernel logs |
MachineService/EtcdSnapshot | os:etcd:backup or os:admin | Create etcd backup |
MachineService/GenerateConfiguration | os:admin | Generate configs |
MachineService/ApplyConfiguration | os:admin | Apply config changes |
pkg/grpc/middleware/authz.
Security Best Practices
Certificate Management
Do:- Generate separate talosconfigs for different users/teams
- Use the principle of least privilege (grant minimum required roles)
- Rotate certificates regularly
- Store talosconfig securely (encrypt at rest)
- Use short-lived certificates for sensitive operations
- Share talosconfig files between users
- Commit talosconfig to version control
- Use
os:adminrole whenos:operatororos:readeris sufficient - Distribute talosconfig over insecure channels
Access Control
Use os:admin only for:- Initial cluster setup
- Configuration changes
- Cluster upgrades
- Emergency recovery
- Day-to-day operations
- Rebooting nodes
- Draining nodes
- Routine maintenance
- Monitoring and observability
- Troubleshooting (non-sensitive)
- Audit and compliance
- Developer access to logs
Credential Storage
Encrypt talosconfig at rest:- HashiCorp Vault
- AWS Secrets Manager
- Azure Key Vault
- SOPS-encrypted files in git
Audit and Monitoring
Monitor API access:Troubleshooting
Authentication Failed
Symptoms:-
Check endpoint connectivity:
-
Verify talosconfig:
-
Check certificate validity:
Certificate Verification Failed
Symptoms:- Ensure the
cafield in talosconfig matches the cluster’s Talos OS CA - Regenerate talosconfig from the correct secrets bundle:
Missing Permissions
Symptoms:-
Check current roles:
Look for
O=os:*fields. -
Generate talosconfig with required roles:
Wrong Endpoint/Node
Symptoms: Commands fail or target wrong nodes Resolution:Advanced Topics
Service Accounts
For automation and CI/CD:Custom Roles
Talos supports custom roles for forward compatibility:os: prefix) are preserved but not enforced by current Talos versions.
Programmatic Access
Use Talos Go client library:pkg/machinery/client/config/config.go for the config implementation.
Related Resources
Certificates
Learn about PKI and certificate management
Security Overview
Understand the overall security model
Hardening
Security best practices and hardening