Skip to content

Commit

Permalink
Optimize Ingress
Browse files Browse the repository at this point in the history
  • Loading branch information
Victor Getz committed Dec 31, 2023
1 parent 8f65f59 commit cd0b30f
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 25 deletions.
34 changes: 26 additions & 8 deletions infrastructure-charts/blueprints/ingress-values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,29 @@ ingress:
cert-manager.io/cluster-issuer: letsencrypt
traefik.ingress.kubernetes.io/router.entrypoints: websecure
traefik.ingress.kubernetes.io/router.tls: "true"
hosts:
- host: "{{.Values.ingress.host}}"
paths:
- path: #REPLACE_ME
tls:
- hosts:
- "{{.Values.ingress.host}}"
secretName: "myService-cert"
# Creates default Ingress with tls and the given host from .Values.ingress.host
defaultIngress:
enabled: true
## Default values can be overriden
#tls:
# secretName: "myService.fullname"
#path: "/"
#pathType: "Prefix"
#backend:
# name: "myService.fullname" #tpl supported
# port:
# name: "myService.fullname" #tpl supported

## If you don't want to use the default Ingress, you can define it here on your own
#tls:
# - hosts:
# - "{{.Values.ingress.host}}"
# secretName: "myService-cert"
#hosts:
# - host: "{{.Values.ingress.host}}"
# paths:
# - path: "/"
# backend:
# name: "{{include "myService.fullname" $}}"
# port:
# name: "{{include "myService.fullname" $}}"
58 changes: 41 additions & 17 deletions infrastructure-charts/blueprints/ingress.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: {{ include "myService.fullname" $ }}
name: {{ include "iits-ollama-fullstack.fullname" $ }}
{{- with .labels }}
{{- toYaml . | nindent 4 }}
{{- end }}
Expand All @@ -13,10 +13,38 @@ metadata:
{{- end }}
spec:
ingressClassName: {{ .className | default "traefik" }}

{{- if .defaultIngress.enabled | default true }}
{{- $certSecretName := (.defaultIngress.tls).secretName | default (printf "%s-%s" (include "iits-ollama-fullstack.fullname" $) "cert")}}
tls:
- hosts:
- {{ tpl (toYaml .host) $ }}
secretName: {{ $certSecretName }}
rules:
- host: {{ tpl (toYaml .host) $ }}
http:
paths:
- path: {{ .defaultIngress.path | default "/" }}
pathType: {{ .defaultIngress.pathType | default "Prefix"}}
backend:
service:
{{- if (.defaultIngress.backend).name }}
name: {{ tpl (toYaml .defaultIngress.backend.name) $ }}
{{- else }}
name: {{ default (include "iits-ollama-fullstack.fullname" $)}}
{{- end}}
port:
{{- if ((.defaultIngress.backend).port).name }}
name: {{ tpl (toYaml .defaultIngress.backend.port.name) $ }}
{{- else }}
name: {{ default (include "iits-ollama-fullstack.fullname" $)}}
{{- end}}
{{- else }}

{{- if .tls }}
tls:
{{- range .tls }}
{{- $certSecretName := .secretName | default (printf "%s-%s" (include "myService.fullname" $) "cert")}}
{{- $certSecretName := .secretName | default (printf "%s-%s" (include "iits-ollama-fullstack.fullname" $) "cert")}}
{{- if .hosts }}
{{- range .hosts }}
- hosts:
Expand All @@ -27,7 +55,6 @@ spec:
{{- end }}
{{- end }}
rules:
{{- if .hosts }}
{{- range .hosts }}
- host: {{ tpl (toYaml .host) $ }}
http:
Expand All @@ -37,22 +64,19 @@ spec:
pathType: {{ .pathType | default "Prefix"}}
backend:
service:
name: #REPLACE_ME
{{- if (.backend).name }}
name: {{ tpl (toYaml .backend.name) $ }}
{{- else }}
name: {{ default (include "iits-ollama-fullstack.fullname" $)}}
{{- end}}
port:
number: #REPLACE_ME
{{- if ((.backend).port).name }}
name: {{ tpl (toYaml .defaultIngress.backend.port.name) $ }}
{{- else }}
name: {{ default (include "iits-ollama-fullstack.fullname" $)}}
{{- end}}
{{- end }}
{{- end }}
{{- else }}
- host: {{ tpl (toYaml .host) $ }}
http:
paths:
- path: #REPLACE_ME
pathType: "Prefix"
backend:
service:
name: #REPLACE_ME
port:
number: #REPLACE_ME
{{- end }}
{{- end }}
{{- end }}
{{- end }}

0 comments on commit cd0b30f

Please sign in to comment.