This project aims to provide two different types of ComfyUI services on Kubernetes:
- API Service for Production
- Interactive Service for Designers
- [Common] Minikube Cluster for development
- [Common] GPU Sharing (Time Slicing)
- [Common] Ingress Route
- [Common] Monitoring (Dashboard for Metric + Logging)
- [ComfyUI API Service] Cookie-based Session Stickiness with Timeout
- [ComfyUI API Service] Python Test Script for Image Generation
- [ComfyUI API Service] Horizontal Pod Autoscaling
- [ComfyUI API Service] Efficient Routing (Max Use of ComfyUI Cache)
- [ComfyUI Interactive Service] Authentication and Authorization
- [ComfyUI Interactive Service] Custom Docker Image for JupyterHub SingleUser (+ComfyUI)
- [ComfyUI Interactive Service] ComfyUI Extension for Jupyter Server Proxy
- [ComfyUI Interactive Service] Profiles for GPU Env / CPU only Env
- [ComfyUI Interactive Service] Persistent Volume for ComfyUI User Data
- [ComfyUI Interactive Service] Evicting inactive users
- Install Docker & NVIDIA-Container-Toolkit
- Install Kubectl
- Install Minikube
- Install HELM
MODEL_PATH=PATH_TO_MODELS make cluster
# Enable GPU Time-Slicing for multiple replicas.
helm install nvidia-device-plugin charts/nvidia-device-plugin -n kube-system
# Install Ingress.
kubectl create namespace ingress
helm install traefik charts/traefik -n ingress
# Volumes.
kubectl apply -f volumes/minikube.yaml # for minikube env.
Build ComfyUI (Optional)
eval $(minikube docker-env)
make docker-build
make docker-build-jupyter
make docker-push-jupyter
make docker-run-jupyter # for testing
helm install jupyterhub charts/jupyterhub
- login with
id: admin / pw: admin123!@#
![](https://private-user-images.githubusercontent.com/14961526/356188158-251e1c6c-6e46-49c6-9b0a-5f6c58b7d8ef.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkzNDcyNzksIm5iZiI6MTczOTM0Njk3OSwicGF0aCI6Ii8xNDk2MTUyNi8zNTYxODgxNTgtMjUxZTFjNmMtNmU0Ni00OWM2LTliMGEtNWY2YzU4YjdkOGVmLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTIlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjEyVDA3NTYxOVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWQ3Y2U5YWYwYjE2OWVkNjEzOGE1MDk1ODEwM2IxZjJlMWRhNDRmN2JiOGNhN2VmYmE1NTkxY2Y4YWMzZDA4MWUmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.Vok1mLrUZsD21L3s9zU_KTT6AE0KcuQ8_LWPDa50qsI)
This is an on-premise Kubernetes cluster version inspired by comfyui on EKS.
Build ComfyUI (Optional)
make docker-build
make docker-push
make docker-run # for testing
helm install comfyui charts/comfyui
- Create a connection for testing in minikube:
make tunnel
- open http://localhost/comfyui/
cd test
python main.py -s http://host-address/comfyui
Result:
Generation started.
Generation not ready, sleep 1s ...
Generation not ready, sleep 1s ...
Generation finished.
Inference finished.
ClientID: 80e564e7-48ef-44cd-aae0-2a18fa091deb.
PromptID: 8882b193-d7d4-42e4-8003-7cdfe51a465d.
Num of images: 1.
Time spent: 2.17s.
------
- https://github.com/NVIDIA/k8s-device-plugin?tab=readme-ov-file#with-cuda-time-slicing
- https://nyyang.tistory.com/198