diff --git a/kubernetes/helm/templates/_helpers.tpl b/kubernetes/helm/templates/_helpers.tpl index 16a6f947b..0ed9ddeae 100644 --- a/kubernetes/helm/templates/_helpers.tpl +++ b/kubernetes/helm/templates/_helpers.tpl @@ -5,3 +5,39 @@ {{- define "ollama.name" -}} ollama {{- end -}} + +{{- define "chart.name" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{- define "base.labels" -}} +helm.sh/chart: {{ include "chart.name" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{- define "base.selectorLabels" -}} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end -}} + +{{- define "open-webui.selectorLabels" -}} +{{ include "base.selectorLabels" . }} +app.kubernetes.io/component: {{ .Chart.Name }} +{{- end }} + +{{- define "open-webui.labels" -}} +{{ include "base.labels" . }} +{{ include "open-webui.selectorLabels" . }} +{{- end }} + +{{- define "ollama.selectorLabels" -}} +{{ include "base.selectorLabels" . }} +app.kubernetes.io/component: {{ include "ollama.name" . }} +{{- end }} + +{{- define "ollama.labels" -}} +{{ include "base.labels" . }} +{{ include "ollama.selectorLabels" . }} +{{- end }} diff --git a/kubernetes/helm/templates/ollama-service.yaml b/kubernetes/helm/templates/ollama-service.yaml index a8459b52f..f1512c5a4 100644 --- a/kubernetes/helm/templates/ollama-service.yaml +++ b/kubernetes/helm/templates/ollama-service.yaml @@ -2,11 +2,16 @@ apiVersion: v1 kind: Service metadata: name: {{ include "ollama.name" . }} + labels: + {{- include "ollama.labels" . | nindent 4 }} spec: - type: {{ .Values.ollama.service.type }} selector: - app: ollama + {{- include "ollama.selectorLabels" . | nindent 4 }} +{{- with .Values.ollama.service }} + type: {{ .type }} ports: - protocol: TCP - port: {{ .Values.ollama.servicePort }} - targetPort: {{ .Values.ollama.servicePort }} + name: http + port: {{ .port }} + targetPort: {{ .containerPort }} +{{- end }} diff --git a/kubernetes/helm/templates/ollama-statefulset.yaml b/kubernetes/helm/templates/ollama-statefulset.yaml index dfbf5ba4d..cc37a2316 100644 --- a/kubernetes/helm/templates/ollama-statefulset.yaml +++ b/kubernetes/helm/templates/ollama-statefulset.yaml @@ -2,19 +2,21 @@ apiVersion: apps/v1 kind: StatefulSet metadata: name: {{ include "ollama.name" . }} + labels: + {{- include "ollama.labels" . | nindent 4 }} spec: serviceName: {{ include "ollama.name" . }} replicas: {{ .Values.ollama.replicaCount }} selector: matchLabels: - app: ollama + {{- include "ollama.selectorLabels" . | nindent 6 }} template: metadata: labels: - app: ollama + {{- include "ollama.selectorLabels" . | nindent 8 }} spec: containers: - - name: ollama + - name: {{ include "ollama.name" . }} image: {{ .Values.ollama.image }} ports: - containerPort: {{ .Values.ollama.servicePort }} @@ -27,8 +29,8 @@ spec: - name: NVIDIA_DRIVER_CAPABILITIES value: compute,utility {{- end}} - {{- if .Values.ollama.resources }} - resources: {{- toYaml .Values.ollama.resources | nindent 10 }} + {{- with .Values.ollama.resources }} + resources: {{- toYaml . | nindent 10 }} {{- end }} volumeMounts: - name: ollama-volume diff --git a/kubernetes/helm/templates/webui-deployment.yaml b/kubernetes/helm/templates/webui-deployment.yaml index e62421298..4b08da785 100644 --- a/kubernetes/helm/templates/webui-deployment.yaml +++ b/kubernetes/helm/templates/webui-deployment.yaml @@ -2,23 +2,25 @@ apiVersion: apps/v1 kind: Deployment metadata: name: {{ include "open-webui.name" . }} + labels: + {{- include "open-webui.labels" . | nindent 4 }} spec: replicas: 1 selector: matchLabels: - app: open-webui + {{- include "open-webui.selectorLabels" . | nindent 6 }} template: metadata: labels: - app: open-webui + {{- include "open-webui.selectorLabels" . | nindent 8 }} spec: containers: - name: {{ .Chart.Name }} image: {{ .Values.webui.image }} ports: - containerPort: 8080 - {{- if .Values.webui.resources }} - resources: {{- toYaml .Values.webui.resources | nindent 10 }} + {{- with .Values.webui.resources }} + resources: {{- toYaml . | nindent 10 }} {{- end }} volumeMounts: - name: webui-volume diff --git a/kubernetes/helm/templates/webui-ingress.yaml b/kubernetes/helm/templates/webui-ingress.yaml index 18fcd6cce..9d943c07e 100644 --- a/kubernetes/helm/templates/webui-ingress.yaml +++ b/kubernetes/helm/templates/webui-ingress.yaml @@ -3,9 +3,11 @@ apiVersion: networking.k8s.io/v1 kind: Ingress metadata: name: {{ include "open-webui.name" . }} -{{- if .Values.webui.ingress.annotations }} + labels: + {{- include "open-webui.labels" . | nindent 4 }} +{{- with .Values.webui.ingress.annotations }} annotations: -{{ toYaml .Values.webui.ingress.annotations | trimSuffix "\n" | indent 4 }} + {{- toYaml . | nindent 4 }} {{- end }} spec: rules: diff --git a/kubernetes/helm/templates/webui-pvc.yaml b/kubernetes/helm/templates/webui-pvc.yaml index 2b8d7d1cb..711117fb9 100644 --- a/kubernetes/helm/templates/webui-pvc.yaml +++ b/kubernetes/helm/templates/webui-pvc.yaml @@ -3,7 +3,7 @@ kind: PersistentVolumeClaim metadata: name: {{ include "open-webui.name" . }} labels: - app: open-webui + {{- include "open-webui.labels" . | nindent 4 }} spec: accessModes: [ "ReadWriteOnce" ] resources: diff --git a/kubernetes/helm/templates/webui-service.yaml b/kubernetes/helm/templates/webui-service.yaml index 7ecf796d1..d126968d3 100644 --- a/kubernetes/helm/templates/webui-service.yaml +++ b/kubernetes/helm/templates/webui-service.yaml @@ -2,13 +2,18 @@ apiVersion: v1 kind: Service metadata: name: {{ include "open-webui.name" . }} + labels: + {{- include "open-webui.labels" . | nindent 4 }} spec: - type: {{ .Values.webui.service.type }} # Default: NodePort # Use LoadBalancer if you're on a cloud that supports it selector: - app: open-webui + {{- include "open-webui.selectorLabels" . | nindent 4 }} +{{- with .Values.webui.service }} + type: {{ .type }} ports: - - protocol: TCP - port: {{ .Values.webui.servicePort }} - targetPort: {{ .Values.webui.servicePort }} - # If using NodePort, you can optionally specify the nodePort: - # nodePort: 30000 + - protocol: TCP + port: {{ .port }} + targetPort: {{ .containerPort }} + {{- if .nodePort }} + nodePort: {{ .nodePort }} + {{- end }} +{{- end }}