Stream Kubernetes Pod events to Coder startup logs
- Easily determine the reason for a pod provision failure, or why a pod is stuck pending
- Visibility into when pods are OOMKilled or evicted
- Filter by namespace, field selector, and label selector to reduce Kubernetes API load
Deploy via Helm chart:
helm repo add coder-logstream-kube https://helm.coder.com/logstream-kube helm install coder-logstream-kube coder-logstream-kube/coder-logstream-kube \ --namespace coder \ --set url=<your-coder-url>
For additional customization (image, pull secrets, annotations, etc.), see the values.yaml file.
By default, coder-logstream-kube will watch all namespaces in the cluster. To limit which namespaces are monitored, you can specify them in the values.yaml file:
# Watch specific namespaces only namespaces: ["default", "kube-system"] # Watch all namespaces (default) namespaces: []
When namespaces is empty or not specified, the service will monitor all namespaces in the cluster.
Note For additional customization (such as customizing the image, pull secrets, annotations, etc.), you can use the values.yaml file directly.
| Flag | Env Var | Description |
|---|---|---|
--coder-url, -u |
CODER_URL |
URL of the Coder instance (required) |
--namespaces, -n |
CODER_NAMESPACES |
Comma-separated list of namespaces to watch |
--field-selector, -f |
CODER_FIELD_SELECTOR |
Kubernetes field selector for filtering pods |
--label-selector, -l |
CODER_LABEL_SELECTOR |
Kubernetes label selector for filtering pods |
--kubeconfig, -k |
- | Path to kubeconfig file (default: ~/.kube/config) |
SSL_CERT_FILE: Path to an SSL certificate fileSSL_CERT_DIR: Directory to check for SSL certificate files
Your Coder template should use a kubernetes_deployment resource with wait_for_rollout set to false:
resource "kubernetes_deployment" "hello_world" { count = data.coder_workspace.me.start_count wait_for_rollout = false ... }
This ensures all pod events are captured during initialization and startup.
make help # Show all available targets make build # Build the project make test # Run unit tests make test/integration # Run integration tests (requires KinD) make lint # Run golangci-lint and shellcheck make fmt # Format Go and shell code
Integration tests run against a real Kubernetes cluster using KinD.
Prerequisites: Docker, KinD, kubectl
make kind/create # Create KinD cluster make test/integration # Run integration tests make kind/delete # Clean up
Kubernetes provides an informers API that streams pod and event data from the API server.
coder-logstream-kube listens for Pod and ReplicaSet events with containers that have the CODER_AGENT_TOKEN environment variable set. All events are streamed as logs to the Coder API using the agent token for authentication.
Feel free to open an issue if you have questions, run into bugs, or have a feature request.
Join our Discord to provide feedback and chat with the community!
