Skip to content

Commit

Permalink
Merge pull request #34 from techops-services/common-hosts
Browse files Browse the repository at this point in the history
common: ability to specify multiple Ingress hosts
  • Loading branch information
eskp authored Feb 29, 2024
2 parents 807fa69 + e97710c commit 2c72ccf
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 23 deletions.
2 changes: 1 addition & 1 deletion charts/common/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ type: application
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.0.28
version: 0.0.29

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
Expand Down
4 changes: 1 addition & 3 deletions charts/common/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
1. Get the application URL by running these commands:
{{- if .Values.ingress.enabled }}
{{- range $host := .Values.ingress.hosts }}
{{- range .paths }}
http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ .path }}
{{- end }}
http{{ if $.Values.service.tls }}s{{ end }}://{{ $host }}
{{- end }}
{{- else if and .Values.service.enabled (contains "NodePort" .Values.service.type) }}
export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "common.fullname" . }})
Expand Down
10 changes: 7 additions & 3 deletions charts/common/templates/ingress.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,21 @@ metadata:
{{- $middlewares = append $middlewares (printf "%s-%s-http-www-redirect@kubernetescrd" .Release.Namespace $fullName) }}
{{- end }}
{{- if ne (len $middlewares) 0 }}
traefik.ingress.kubernetes.io/router.middlewares: {{ join "," $middlewares }}
traefik.ingress.kubernetes.io/router.middlewares: {{ join ", " $middlewares }}
{{- end }}
spec:
ingressClassName: {{ .Values.ingressClassName }}
{{- if .Values.service.tls.enabled }}
tls:
- hosts:
- {{ .Values.ingress.host }}
{{- range .Values.ingress.hosts }}
- {{ . | quote }}
{{- end }}
secretName: {{ $fullName }}-tls
{{- end }}
rules:
- host: {{ .Values.ingress.host }}
{{- range .Values.ingress.hosts }}
- host: {{ . | quote }}
http:
paths:
- backend:
Expand All @@ -37,4 +40,5 @@ spec:
name: http
path: /
pathType: ImplementationSpecific
{{- end }}
{{- end }}
2 changes: 1 addition & 1 deletion charts/common/templates/middleware-httpBasicAuth.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ stringData:
{{ $item }}
{{- end }}
---
apiVersion: traefik.io/v1alpha1
apiVersion: traefik.containo.us/v1alpha1
kind: Middleware
metadata:
name: {{ $fullName }}-http-basic-auth
Expand Down
4 changes: 2 additions & 2 deletions charts/common/templates/middleware-httpWwwRedirect.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{{- if .Values.httpWwwRedirect.enabled }}
{{- $fullName := include "common.fullname" . -}}
---
apiVersion: traefik.io/v1alpha1
apiVersion: traefik.containo.us/v1alpha1
kind: Middleware
metadata:
name: {{ $fullName }}-http-www-redirect
spec:
redirectRegex:
permanent: true
regex: "^(http)://(www\\.)?(.*)"
replacement: "https://$$3"
replacement: "https://$3"
{{- end }}
11 changes: 4 additions & 7 deletions charts/common/test-values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ service:
type: ClusterIP
containerPort: 5000
tls:
enabled: false
enabled: true
issuerName: "test"

deployment:
Expand Down Expand Up @@ -186,12 +186,9 @@ ingress:
{}
# kubernetes.io/ingress.class: nginx
# kubernetes.io/tls-acme: "true"
host: example.com

tls:
- secretName: chart-example-tls
hosts:
- chart-example.local
hosts:
- example.com
- www.example.com

resources:
limits:
Expand Down
9 changes: 3 additions & 6 deletions charts/common/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -197,12 +197,9 @@ ingress: {}
# {}
# # kubernetes.io/ingress.class: nginx
# # kubernetes.io/tls-acme: "true"
# host: example.com
#
# tls: []
# # - secretName: chart-example-tls
# # hosts:
# # - chart-example.local
# hosts:
# - example.com
# - www.example.com

# If enabled will create Traefik Middleware and apply to Ingress
# to redirect http to https and www to non-www
Expand Down

0 comments on commit 2c72ccf

Please sign in to comment.