Stream logs from pods in selected namespaces on a Kubernetes cluster over WebSocket.
K8s Logs Streamer is a tool designed to facilitate real-time log streaming from pods in specified namespaces within a Kubernetes cluster. This project leverages WebSocket and a simple UI that provide a seamless and efficient log streaming experience.
Before getting started, ensure you have the following:
- Access to a Kubernetes cluster
kubectl
configured to communicate with your cluster- Necessary permissions to create and manage Kubernetes resources
-
Identify Target Namespaces
- Determine the namespaces containing the pods you want to stream logs from.
-
Configure Namespaces
- Add the target namespaces to the ConfigMap in the
k8s-yaml/configmap.yaml
file.
- Add the target namespaces to the ConfigMap in the
-
Set Up RBAC For each namespace, you need to create:
- A ServiceAccount
- A ClusterRole
- A RoleBinding
Use the YAML files provided in the
k8s-yaml
directory as templates. -
Deploy the Service
- Apply the YAML files in the
k8s-yaml
directory to deploy your service:kubectl apply -f k8s-yaml/
- Apply the YAML files in the
Once deployed, you can connect to the WebSocket endpoint to start streaming logs. The exact method of connection will depend on how you've exposed the service (e.g., through an Ingress or LoadBalancer).
Modify the ConfigMap in k8s-yaml/configmap.yaml
to adjust settings such as:
- Target namespaces
If you encounter issues:
- Check that all RBAC resources are correctly applied.
- Verify that the ServiceAccount has the necessary permissions in the target namespaces.
- Examine the logs of the K8s Logs Streamer pod for any error messages.
Contributions are welcome! Please feel free to submit a Pull Request.