A web-based dashboard for monitoring logs from multiple Kubernetes pods and containers in real-time. This tool allows you to open up to 4 separate log windows, each streaming logs from a specific pod and container, with proper isolation between streams.
- Real-Time Log Streaming: View logs from Kubernetes pods and containers in real-time.
- Multiple Log Windows: Open up to 4 log windows simultaneously, each streaming logs from a different container.
- Namespace Filtering: Load pods from a specific namespace.
- Search Logs: Filter logs in each window using a search input.
- Dynamic Container Selection: Prevents selecting the same container in multiple windows.
- Responsive Design: Works well on both desktop and mobile devices.
- Cluster Name Display: Displays the Kubernetes cluster name in the dashboard header.
- Spinner for Loading: A spinner is displayed while loading pods.
- Kubernetes Cluster: Ensure you have access to a running Kubernetes cluster.
- Python 3.8+: Required to run the FastAPI backend.
- kubectl: Ensure
kubectlis configured to access your Kubernetes cluster. Alternatively, for testing purposes, you can setTEST_MODE=trueto use mock data. - Docker: Required if you want to run the application in a container.
git clone https://github.com/esysc/kube-dashboard.git
cd kube-dashboardpip install -r requirements.txtpython app.py --port 5000The port argument is optional, defaults to 5000, and can also be passed as an environment variable:
export PORT=5000Navigate to:
http://localhost:5000
You can also run the application using Docker:
docker build -t kube-dashboard .docker run -p 5000:5000 -e PORT=5000 kube-dashboardor if you want to use mock data:
docker run -p 5000:5000 -e PORT=5000 -e TEST_MODE=true kube-dashboardOpen your browser and navigate to:
http://localhost:5000
To test the application without connecting to a real Kubernetes cluster, you can enable TEST_MODE:
export TEST_MODE=true
python app.py --port 5000In this mode:
- Mock Kubernetes pods and containers are used.
- The application simulates log streaming for testing purposes.
- Start the FastAPI server:
python app.py --port 5000
- Open your browser and navigate to
http://localhost:5000. - Verify that you can:
- Load pods from a Kubernetes namespace.
- Open up to 4 log windows.
- Stream logs in real-time for selected pods and containers.
- Filter logs using the search input.
- Dynamically select containers without duplication.
- Ensure
kubectlis configured correctly and can access your Kubernetes cluster. - Test the interaction between the FastAPI backend and the Kubernetes API by loading pods and streaming logs.
- Test the dashboard on multiple browsers (e.g., Chrome, Firefox, Edge) to ensure compatibility.
- Verify that the dashboard works well on both desktop and mobile devices.
- Test scenarios where the Kubernetes cluster is unreachable or invalid inputs are provided to ensure proper error messages are displayed.
- Enter the desired Kubernetes namespace in the input field and click Load Pods.
- Click Add Log Window to open a new log window.
- Select a pod and container from the dropdown menus in the log window.
- View real-time logs for the selected container.
- Use the search input to filter logs by keywords.
- Close a log window by clicking the × button.
The application was migrated from Flask to FastAPI for better performance and asynchronous support. Key changes include:
- FastAPI Lifespan: Used to manage application lifecycle and resources.
- Socket.IO Integration: The
socketio.ASGIAppis used to integrate Socket.IO with FastAPI. - Static Files: Static files (CSS and JS) are served using
fastapi.staticfiles.StaticFiles.
When TEST_MODE=true is set as an environment variable:
- Mock Kubernetes pods and containers are created using
unittest.mock. - The application simulates log streaming for testing purposes.
Contributions are welcome! Please follow these steps:
- Fork the repository.
- Create a new branch for your feature or bugfix.
- Commit your changes and push the branch.
- Open a pull request.