Skip to content

Instantly share code, notes, and snippets.

@justinmarwad
Created November 15, 2024 20:50
Show Gist options
  • Select an option

  • Save justinmarwad/67de465038df01dfd375f38e4a4c7378 to your computer and use it in GitHub Desktop.

Select an option

Save justinmarwad/67de465038df01dfd375f38e4a4c7378 to your computer and use it in GitHub Desktop.
Self-signed TLS K8s configuration file for open-webui
## NAMESPACE ##
---
apiVersion: v1
kind: Namespace
metadata:
name: open-webui
## STORAGE ##
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
labels:
app: open-webui
name: open-webui-pvc
namespace: open-webui
spec:
accessModes: ["ReadWriteOnce"]
resources:
requests:
storage: 2Gi
## WEB UI DEPLOYMENT ##
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: open-webui-deployment
namespace: open-webui
spec:
replicas: 1
selector:
matchLabels:
app: open-webui
template:
metadata:
labels:
app: open-webui
spec:
containers:
- name: open-webui
image: ghcr.io/open-webui/open-webui:main
ports:
- containerPort: 8080
# resources:
# requests:
# cpu: "500m"
# memory: "500Mi"
# limits:
# cpu: "1000m"
# memory: "1Gi"
env:
- name: OLLAMA_BASE_URL
value: "http://192.168.1.123:11434"
tty: true
volumeMounts:
- name: webui-volume
mountPath: /app/backend/data
volumes:
- name: webui-volume
persistentVolumeClaim:
claimName: open-webui-pvc
## WEB UI SERVICE ##
---
apiVersion: v1
kind: Service
metadata:
name: open-webui-service
namespace: open-webui
spec:
type: NodePort # Use LoadBalancer if you're on a cloud that supports it
selector:
app: open-webui
ports:
- protocol: TCP
port: 8080
targetPort: 8080
# If using NodePort, you can optionally specify the nodePort:
# nodePort: 30000
## WEB UI INGRESS ##
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: open-webui-ingress
namespace: open-webui
#annotations:
# Use appropriate annotations for your Ingress controller, e.g., for NGINX:
# nginx.ingress.kubernetes.io/rewrite-target: /
spec:
rules:
- host: chat.homelab.local
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: open-webui-service
port:
number: 8080
### TLS PROXY ###
# 1. Install cert-manager: kubectl apply -f https://github.com/cert-manager/cert-manager/releases/download/v1.16.1/cert-manager.yaml
# 2. Verify: kubectl get pods --namespace cert-manager
###
## CERT-MANAGER ISSUER ##
---
apiVersion: cert-manager.io/v1
kind: Issuer
metadata:
name: selfsigned-issuer
namespace: open-webui
spec:
selfSigned: {}
## CERTIFICATE ##
---
apiVersion: cert-manager.io/v1
kind: Certificate
metadata:
name: open-webui-cert
namespace: open-webui
spec:
secretName: open-webui-tls
duration: 2160h # 90 days
renewBefore: 360h # 15 days
dnsNames:
- chat.homelab.local
issuerRef:
name: selfsigned-issuer
kind: Issuer
## WEB UI INGRESS ##
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: open-webui-ingress
namespace: open-webui
annotations:
cert-manager.io/cluster-issuer: "selfsigned-issuer"
nginx.ingress.kubernetes.io/rewrite-target: /
nginx.ingress.kubernetes.io/ssl-redirect: "true"
spec:
tls:
- hosts:
- chat.homelab.local
secretName: open-webui-tls
rules:
- host: chat.homelab.local
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: open-webui-service
port:
number: 8080
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment