An intuituive, simple web application to monitor metrics in your Kubernetes clusters.
- About 0PTIKUBE π³
- Why 0PTIKUBE? π€
- 0PTIKUBE Features π±
- Prerequisite Apps to Use 0PTIKUBE App π¦
- Project Setup βοΈ
- Future Features π
- Contribution Guidelines π
- Contributors π
- License π
0PTIKUBE is a web-based visualization tool that helps users monitor the current CPU and memory usage of their Kubernetes pods and clusters. It offers near real-time historical monitoring and visual metrics views for the last hour, 12 hours, 24 hours, and 7 days.
Accessing Kubernetes cluster and pod resources through terminal commands can be tedious and cumbersome. 0PTIKUBE streamlines this process by consolidating it into a single, user-friendly interface. With our responsive React and D3.jsbased dashboard, you can easily visualize performance metrics without the hassle of navigating through menus or changing context. β¨
- Monitoring: near realtime metrics to monitor a pod or cluster's cpu and memory.
- AI integration: implement AI and rag to get tailored insights into reallocating resoueces for a pod or cluster.
The following installs are required to use 0PTIKUBE. Great news, all of the following, except node, are included in the install sctipt. We've listed the download links as resources.
- Node.js - install the latest version here
- Docker Desktop (included) - link
- Minikube application (included) - link
- Kubectl (included) - link
- Prometheus (included) - link
-
Clone our main branch of the 0PTIKUBE repository on Github.com and then clone it in the terminal.
git clone https://github.com/oslabs-beta/0ptiKube.git cd 0ptikube
-
Install dependendencies for the 0PTIKUBE app
# execute the following command in the root folder of the 0PTIKUBE directory. npm install
-
Run the
minikube-install.sh
file script in the root directory of the 0PTIKUBE folder. This script installs the following programs utilized in our 0PTIKUBE app: Minikube, Docker Desktop, Kubectl, Helm, and Prometheus.# this commands makes the `minikube-install.sh` file an executable: chmod u+x minikube-install.sh # execute the script with the following command: ./minikube-install.sh
-
After the installation sctipt is complete. Run the following commands in your terminal to get Minikube environment started.
a. This following commands enable features used in the minikube cluster.
# Start Minikube with sufficient resources minikube start # Verify Minikube is running and view configuration minikube status minikube config view #cpu should be 3, and memory 3000 by default. # Enable required addons minikube addons enable metrics-server # Aggregates resource usage data for monitoring and autoscaling. minikube addons enable dashboard # Provides a default storage class for dynamic volume provisioning. minikube addons enable ingress # Manages external access to services via HTTP/HTTPS routing. minikube addons enable storage-provisioner # Enables dynamic provisioning of storage for persistent volumes.
b. Next, copy and paste this code block into the same terminal and execute commands. This applies the RBAC, test pod configurations, services and cron jobs.
# Apply RBAC configuration kubectl apply -f k8s-configs/k8s-testpods/stressor-rbac.yaml # Apply Test Pod 1 configurations kubectl apply -f k8s-configs/k8s-testpods/test-pod1.yaml kubectl apply -f k8s-configs/k8s-testpods/test-pod1-service-monitor.yaml kubectl apply -f k8s-configs/k8s-testpods/test-pod1-cronjob.yaml # Apply Test Pod 2 configurations kubectl apply -f k8s-configs/k8s-testpods/test-pod2.yaml kubectl apply -f k8s-configs/k8s-testpods/test-pod2-service-monitor.yaml kubectl apply -f k8s-configs/k8s-testpods/test-pod2-cronjob.yaml # Apply Test Pod 3 configurations kubectl apply -f k8s-configs/k8s-testpods/test-pod3.yaml kubectl apply -f k8s-configs/k8s-testpods/test-pod3-service-monitor.yaml kubectl apply -f k8s-configs/k8s-testpods/test-pod3-cronjob.yaml
c. Next, we are going to containerize our small next.js demo app, that's inside the
load-demo-app
folder. It's associated docker file isDockerfile.load-demo-app
. This will allow us to place the demo app into our kubernetes cluster as a pod. This will allow us to monitor it. Similar to our testpods we created in the previous step.# Navigate to the load-demo-app directory cd load-demo-app # Switch to Minikube's Docker daemon eval $(minikube docker-env) # Build the image (it will now be available in Minikube) docker build -t load-demo-app:latest -f Dockerfile.load-demo-app . # Apply Demo App configurations kubectl apply -f k8s-configs/k8s-demo-app-pod/demoApp-pod.yaml kubectl apply -f k8s-configs/k8s-demo-app-pod/demoApp-service.yaml kubectl apply -f k8s-configs/k8s-demo-app-pod/demoApp-service-monitor.yaml # 5. Verify the deployment kubectl get pods # Check if pod is running kubectl get svc # Check if service is created kubectl get servicemonitors # Check if service monitor is created
-
You are now ready to use our 0PTIKUBE application with all the configurations added π₯³
-
Access your app by running the following commands in a new terminal. We recommend renaming each terminal tab to stay organized:
# --------------Required terminals for 0ptikube web app------------------------- # Terminal 1 - Run the 0PTIKUBE web application # (recommend renaming terminal session '0PTIKUBE web server 3000') npm start # Terminal 2 - Prometheus port forwarding (required for metrics ti display in the webapp) # (recommend renaming 'prom port forward 9090') kubectl port-forward svc/my-kube-prometheus-stack-prometheus 9090:9090 #--------------Optional terminals 3-5 ------------------------- # Terminal 3 - Just for your reference. Monitor the test pods including load-demo-app in terminal. This can be seen easily in our web app. # (recommend renaming terminal 'pod monitor') watch "kubectl top pods | grep -E 'test-pod1|test-pod2|test-pod3|load-demo-app'" # Terminal 4 - View pod and service status for our minikube cluster # (recommend renaming 'k8s status') kubectl get pods,svc,servicemonitors # Terminal 5 - Port forward to access the demo app UI (optional) # (recommend renaming terminal session 'demo app forward 3002') kubectl port-forward service/demoApp-service 3002:3000 #this will allow you to view our demo app's UI through the browser http://localhost:3002
6a. Create .env
file in the root directory of 0PTIKUBE folder.
You'll need to input environment variables nside of the .env file to access features inside our web app.
Copy and paste the following fields from the code block.
# Database connection provided
DATABASE_URL=postgresql:"your supabase uri"
# Prometheus URL provided
PROMETHEUS_BASE_URL="http://localhost:9090"
# Github Oauth setup
GITHUB_ID="your GitHub client ID"
GITHUB_SECRET="your GitHub secret"
NEXTAUTH_URL="http://localhost:3000"
NEXTAUTH_SECRET="your Next Auth secret"
# Openai API setup
OPENAI_API_KEY="your OpenAI key here"
FINE_TUNED_MODEL="your fine tune model key here"
## π SSL Certificate for Database Connection
# To connect to your DB, download the required CA certificate from Supabase.
# Create a folder in root directory with command `mkdir -p certs/`
# Add the downloaded SSL certificate text to a file in the newly created directory called `supabase-ca.pem`. You can add this file to your .gitignore.
# Append "?sslmode=verify-full&sslrootcert=certs/supabase-ca.pem" to the end of your DATABASE_URL in your .env file.
Your information from should be entered after the '=' sign. Here are links on how to attain the following:
-
Useful commands for Minikube.
# Start cluster - started with use of our `minikube.install.sh script` minikube start # Check status of control plane (kubernetes cluster) minikube status # Stop cluster - safe to do. Similar to pausing an action. minikube stop # Delete cluster (after trying our app) # this command is only recommended if you intend to make your own cluster or environment from scratch in the future) minikube delete #if you run out of prometheus resources after days of using our app, you can allocate more resources by using the following terminal commands. helm upgrade my-kube-prometheus-stack prometheus-community/kube-prometheus-stack \ --set prometheus.prometheusSpec.resources.requests.memory=2Gi \ --set prometheus.prometheusSpec.resources.limits.memory=4Gi \ --set prometheus.prometheusSpec.resources.requests.cpu=500m \ --set prometheus.prometheusSpec.resources.limits.cpu=1000m \ --set prometheus.prometheusSpec.retention=5d
-
Useful commands for docker.
# List running containers docker ps # List all containers (including stopped) docker ps -a # List all images docker images
- Real-Time Data Streaming: Explore adding real-time cluster/pod health data visualizations via Kubernetes API access to enhance granularity.
- Real-Time Monitoring Alerts: Enable alerts that notify users when their clusters/pods have surpassed or dropped below certain thresholds, allowing more dynamic response times to under- or over-provisioned deployments.
- AI Improvements: Continue to fine-tune and train the AI model for even more accurate optimization insights based on historical container data and saved AI queries and responses to allow the AI to observe the effects of its recommended resource allocation suggestions over time.
- Historical Analysis: Add trend visualization and comparison of AI recommendations against actual resource usage over time.
- User Customization: Allow users to further customize refresh intervals and to set individual container health indicator thresholds.
- Multi-Cluster Support: Expand the platform to support monitoring multiple Kubernetes clusters simultaneously.
- Support for Visualization of Additional Metrics: Create visualizations that measure additional indicators of cluster/pod health including percentage uptime, latency, etc.
We welcome contributions from the community! π Want to get involved? π§βπ»
-
Fork the Repo Click the "Fork" button at the top-right corner of this repository page.
-
Create a Feature Branch
#run this command in the feature git checkout -b feature/nameOfTheFeature
-
Implement Your Feature Add your code, tests, or documentation.
-
Commit Your Changes
git commit -m "added x feature to file x"
-
Push to Your Branch
git push origin feature/nameOfTheFeature
-
Create a Pull Request (PR) Open a PR to the dev branch of our 0PTIKUBE repo. Our team will review and, once approved, merge it in!
- Jason Stuhmer: GitHub | LinkedIn
- Oliver Fajardo: GitHub | LinkedIn
- Richard Rivera: GitHub | LinkedIn
- Senay Yakut: GitHub | LinkedIn
We would like to thank you for visiting our page, and any future contributors!
Distributed under the MIT License. Please see LICENSE
for more information.
Please drop us a β on GitHub if you enjoy our open source product! Share and help our community grow! π