tool-containers
Menu
GitHub (opens in new tab)

Run T3 Code with Kubernetes

deployment.yaml runs T3 Code as a Deployment named t3code with a ClusterIP Service of the same name on port 3773.

Images
  • GHCRghcr.io/hambn/t3code
  • Docker Hubdocker.io/hambn/t3code
Use case
Shared cluster instance from plain manifests
Upstream
github.com/pingdotgg/t3code (opens in new tab)
Source
tools/ai/t3code/docs/kubernetes (opens in new tab)
On this page

Prerequisites

  • A Kubernetes cluster and kubectl configured for it.

Run T3 Code

Shell
kubectl apply -f deployment.yaml
kubectl rollout status deploy/t3code
kubectl logs deploy/t3code | grep Token:
kubectl port-forward svc/t3code 3773:3773

Open http://localhost:3773/pair#token=<token> to pair your browser, then sign in to an agent from the UI. The token expires after five minutes; for a new pair URL, run:

Shell
kubectl exec deploy/t3code -- t3 auth pairing create --base-url http://localhost:3773

Workspace

/workspace is an emptyDir: it survives container restarts but not a new pod. T3 Code's state and the agent logins are in the container's home directory, which resets whenever the container restarts. Mount a PersistentVolumeClaim at /workspace, and at /home/sysadmin/.t3 if you need them to last. The pod runs as UID 1000 with all capabilities dropped.

The Service is cluster-internal. Put an authenticating Ingress in front before you expose it.

Files

  • deployment.yaml defines the Deployment, with HTTP probes on /, and the t3code Service.

Cleanup

Shell
kubectl delete -f deployment.yaml

File contents

deployment.yaml67 lines
# T3 Code as a one-replica Deployment and a ClusterIP Service on port 3773.
# kubectl port-forward svc/t3code 3773:3773, then pair with the token from kubectl logs deploy/t3code.
apiVersion: apps/v1
kind: Deployment
metadata:
  name: t3code
  labels: { app: t3code }
spec:
  replicas: 1
  selector:
    matchLabels: { app: t3code }
  template:
    metadata:
      labels: { app: t3code }
    spec:
      securityContext:
        runAsNonRoot: true
        runAsUser: 1000
        runAsGroup: 1000
        fsGroup: 1000
        seccompProfile:
          type: RuntimeDefault
      containers:
        - name: t3
          image: ghcr.io/hambn/t3code:ubuntu-browser
          imagePullPolicy: Always
          securityContext:
            allowPrivilegeEscalation: false
            capabilities:
              drop: ["ALL"]
          resources:
            requests:
              cpu: 100m
              memory: 256Mi
            limits:
              cpu: "2"
              memory: 2Gi
          ports:
            - containerPort: 3773
          livenessProbe:
            httpGet:
              path: /
              port: 3773
            initialDelaySeconds: 15
            periodSeconds: 20
          readinessProbe:
            httpGet:
              path: /
              port: 3773
            initialDelaySeconds: 5
            periodSeconds: 10
          volumeMounts:
            - name: workspace
              mountPath: /workspace
      volumes:
        - name: workspace
          emptyDir: {}
---
apiVersion: v1
kind: Service
metadata:
  name: t3code
spec:
  selector: { app: t3code }
  ports:
    - port: 3773
      targetPort: 3773

Topics