Before deploying this Stable Diffusion WebUI application, ensure you have:
- Kubernetes cluster with sufficient resources (minimum 4GB RAM per pod)
- kubectl configured to access your cluster
- Docker registry access (GitHub Container Registry recommended)
- Ingress controller installed (if using external access)
-
Fork or clone this repository:
git clone <your-repo-url> cd stable-diffution-rcom
-
Update configuration:
- Edit
k8s/deployment.yamland replaceyour-usernamewith your actual GitHub username:image: ghcr.io/YOUR-USERNAME/stable-diffution-rcom:latest
- Update the ingress host in
k8s/deployment.yaml:host: stable-diffusion.your-domain.com
- Edit
-
Push to GitHub:
git add . git commit -m "Initial setup" git push origin main
-
Monitor the build:
- Go to your repository's "Actions" tab
- Watch the "Build and Push Docker Image" workflow
- Ensure it completes successfully
-
Build locally:
docker build -t ghcr.io/YOUR-USERNAME/stable-diffution-rcom:latest . -
Login to GitHub Container Registry:
echo $GITHUB_TOKEN | docker login ghcr.io -u YOUR-USERNAME --password-stdin
-
Push the image:
docker push ghcr.io/YOUR-USERNAME/stable-diffution-rcom:latest
-
Apply the deployment:
kubectl apply -f k8s/deployment.yaml
-
Verify deployment:
# Check if pods are running kubectl get pods -l app=stable-diffusion-webui # Check deployment status kubectl get deployment stable-diffusion-webui # Check service kubectl get service stable-diffusion-webui-service
-
Monitor pod startup (this may take several minutes):
kubectl logs -f deployment/stable-diffusion-webui
kubectl port-forward service/stable-diffusion-webui-service 7860:80Then open http://localhost:7860 in your browser.
-
Ensure ingress controller is installed:
# For NGINX Ingress Controller kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/controller-v1.8.1/deploy/static/provider/cloud/deploy.yaml -
Check ingress status:
kubectl get ingress stable-diffusion-webui-ingress
-
Access via your domain: Navigate to
http://stable-diffusion.your-domain.com
You can customize the application by modifying environment variables in k8s/deployment.yaml:
env:
- name: COMMANDLINE_ARGS
value: "--listen --port 7860 --api --cors-allow-origins=*"Common options:
--api: Enable API access--cors-allow-origins=*: Allow CORS from any origin--share: Create a public link (not recommended for production)--xformers: Use xformers for better performance
Adjust resources based on your needs:
resources:
requests:
memory: "8Gi" # Increase for larger models
cpu: "2000m" # Increase for better performance
limits:
memory: "16Gi"
cpu: "4000m"Scale the number of replicas:
kubectl scale deployment stable-diffusion-webui --replicas=3-
ImagePullBackOff Error:
# Check if image exists and is accessible kubectl describe pod <pod-name> # Verify image URL in deployment kubectl get deployment stable-diffusion-webui -o yaml | grep image:
-
Pod Stuck in Pending:
# Check resource availability kubectl describe pod <pod-name> kubectl top nodes
-
Application Not Starting:
# Check application logs kubectl logs deployment/stable-diffusion-webui # Check events kubectl get events --sort-by=.metadata.creationTimestamp
-
Out of Memory:
# Increase memory limits kubectl patch deployment stable-diffusion-webui -p '{"spec":{"template":{"spec":{"containers":[{"name":"stable-diffusion-webui","resources":{"limits":{"memory":"16Gi"}}}]}}}}'
Monitor application health:
# Check readiness
kubectl get pods -l app=stable-diffusion-webui
# Test health endpoint manually
kubectl exec -it deployment/stable-diffusion-webui -- curl http://localhost:7860-
Network Policies:
apiVersion: networking.k8s.io/v1 kind: NetworkPolicy metadata: name: stable-diffusion-netpol spec: podSelector: matchLabels: app: stable-diffusion-webui policyTypes: - Ingress ingress: - from: - namespaceSelector: matchLabels: name: ingress-nginx
-
Resource Quotas:
apiVersion: v1 kind: ResourceQuota metadata: name: stable-diffusion-quota spec: hard: requests.memory: "32Gi" requests.cpu: "8" limits.memory: "64Gi" limits.cpu: "16"
-
Add monitoring labels:
metadata: labels: app: stable-diffusion-webui monitoring: "true"
-
Prometheus metrics (if available):
annotations: prometheus.io/scrape: "true" prometheus.io/port: "7860" prometheus.io/path: "/metrics"
For model storage persistence:
spec:
template:
spec:
volumes:
- name: models-storage
persistentVolumeClaim:
claimName: stable-diffusion-models
containers:
- name: stable-diffusion-webui
volumeMounts:
- name: models-storage
mountPath: /app/modelsTo remove the deployment:
kubectl delete -f k8s/deployment.yaml- Set up monitoring with Prometheus/Grafana
- Configure persistent storage for models
- Implement backup strategies for generated content
- Set up alerting for application health
- Configure auto-scaling based on load
- Check the main README.md for general information
- Review logs:
kubectl logs deployment/stable-diffusion-webui - Check Kubernetes events:
kubectl get events - Consult the Stable Diffusion WebUI documentation