teleport machine ID kubernetes
- User
teleport machine ID kubernetes
Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
teleport machine ID kubernetes
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
Teleport Machine ID is a feature of the Teleport access platform that provides secure, short-lived, automatically-rotated credentials [PASSWORD] and SSH certificates) for machine-to-machine authentication. When deployed in Kubernetes, Machine ID enables workloads, CI/CD jobs, and automation tools to securely access infrastructure resources—such as Kubernetes clusters, databases, and servers—without relying on static secrets or long-lived credentials[1][2][6].
Below is a comprehensive guide to deploying and using Teleport Machine ID with Kubernetes.
tbot, a lightweight agent that runs as a Kubernetes deployment or sidecar. It authenticates to the Teleport Auth Service and generates short-lived credentials, which are stored in Kubernetes Secrets or mounted as files for use by other pods or applications[1][2][7].kubernetes join method, where tbot authenticates using a Kubernetes ServiceAccount JWT, validated by the Teleport Auth Service using the cluster's JWKS public key[1][7].Create a ServiceAccount, Role, and RoleBinding to allow tbot to manage secrets in the desired namespace:
apiVersion: v1
kind: ServiceAccount
metadata:
name: tbot
namespace: default
---
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: secrets-admin
namespace: default
rules:
- apiGroups: [""]
resources: ["secrets"]
verbs: ["*"]
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: tbot-secrets-admin
namespace: default
subjects:
- kind: ServiceAccount
name: tbot
roleRef:
kind: Role
name: secrets-admin
apiGroup: rbac.authorization.k8s.io
Apply with:
kubectl apply -f k8s-rbac.yaml[1][7]
Example role:
kind: role
version: v7
metadata:
name: example-role
spec:
allow:
kubernetes_labels:
'*': '*'
kubernetes_groups:
- editor
kubernetes_resources:
- kind: "*"
namespace: "*"
name: "*"
verbs: ["*"]
Assign the role to the bot using tctl bots update[2][7].
kubectl proxy -p 8080
curl http://localhost:8080/openid/v1/jwks
kind: token
version: v2
metadata:
name: example-bot
spec:
roles: [Bot]
bot_name: example
join_method: kubernetes
kubernetes:
type: static_jwks
static_jwks:
jwks: |
{"keys":[...]}
allow:
- service_account: "default:tbot"
Apply with:
tctl create -f bot-token.yaml[1][7]
tbot configuration.tbot as a deployment, mounting the config and ServiceAccount token.Example ConfigMap:
apiVersion: v1
kind: ConfigMap
metadata:
name: tbot-config
namespace: default
data:
tbot.yaml: |
version: v2
onboarding:
join_method: kubernetes
token: example-bot
storage:
type: memory
proxy_server: teleport.example.com:443
outputs:
- type: identity
destination:
type: kubernetes_secret
name: identity-output
Example Deployment:
apiVersion: apps/v1
kind: Deployment
metadata:
name: tbot
namespace: default
spec:
replicas: 1
selector:
matchLabels:
app.kubernetes.io/name: tbot
template:
metadata:
labels:
app.kubernetes.io/name: tbot
spec:
containers:
- name: tbot
image: public.ecr.aws/gravitational/tbot-distroless:17.4.3
args:
- start
- -c
- /config/tbot.yaml
env:
- name: POD_NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
- name: KUBERNETES_TOKEN_PATH
value: /var/run/secrets/tokens/join-sa-token
volumeMounts:
- mountPath: /config
name: config
- mountPath: /var/run/secrets/tokens
name: join-sa-token
serviceAccountName: tbot
volumes:
- name: config
configMap:
name: tbot-config
- name: join-sa-token
projected:
sources:
- serviceAccountToken:
path: join-sa-token
expirationSeconds: 600
audience: teleport.example.com
Apply with:
kubectl apply -f k8s-deployment.yaml[1][7]
Other pods can mount the generated Kubernetes Secret to access Teleport-issued credentials:
apiVersion: v1
kind: Pod
metadata:
name: tsh
namespace: default
spec:
containers:
- name: tsh
image: public.ecr.aws/gravitational/teleport-distroless:17.4.3
command: ["tsh"]
args: ["-i", "/identity-output/identity", "--proxy", "teleport.example.com:443", "ls"]
volumeMounts:
- name: identity-output
mountPath: /identity-output
volumes:
- name: identity-output
secret:
secretName: identity-output
This allows the pod to authenticate to Teleport-protected resources using the short-lived credentials[1][7].
| Component | Purpose |
|---|---|
| tbot | Generates and rotates credentials for workloads |
| ServiceAccount | Kubernetes identity for tbot |
| Teleport Bot | Teleport identity for machine access |
| Role/RoleBinding | Grants tbot access to manage secrets in Kubernetes |
| Join Token | Authorizes tbot to join Teleport using Kubernetes JWT |
| ConfigMap | Stores tbot configuration |
| Secret | Stores generated credentials for consumption by workloads |
By following these steps, you can securely automate machine-to-machine access in Kubernetes using Teleport Machine ID, eliminating static secrets and gaining robust auditability and policy control.