Skip to content

Commit

Permalink
Merge pull request #106 from bedag/feature/ingress_defaultBackend
Browse files Browse the repository at this point in the history
[common]: add ingress defaultBackend
  • Loading branch information
TobyTheHutt authored Jul 27, 2023
2 parents cbff31b + 1ea87b4 commit fc17db5
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 4 deletions.
2 changes: 1 addition & 1 deletion charts/common/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apiVersion: v2
name: common
description: "Bedag's common Helm chart to use for creating other Helm charts"
version: 10.2.0
version: 10.3.0
# A chart can be either an 'application' or a 'library' chart.
#
# Application charts are a collection of templates that can be packaged into versioned archives
Expand Down
3 changes: 2 additions & 1 deletion charts/common/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# common

![Version: 10.2.0](https://img.shields.io/badge/Version-10.2.0-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square)
![Version: 10.3.0](https://img.shields.io/badge/Version-10.3.0-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square)

Bedag's common Helm chart to use for creating other Helm charts

Expand Down Expand Up @@ -33,6 +33,7 @@ Major Changes to functions are documented with the version affected. **Before up
| ingress.annotations | object | `{"nginx.ingress.kubernetes.io/ssl-redirect":"true"}` | annotations is a dictionary for defining ingress controller specific annotations |
| ingress.deploy | bool | `false` | deploy has to be set to true for rendering to be applied |
| ingress.ingressClassName | string | `""` | ingressClassName, defines the class of the ingress controller. |
| ingress.rules | list | `[{"host":"myapp.cluster.local","http":{"paths":[{"backend":{"serviceNameSuffix":"component-1","servicePort":"http"},"path":"/","pathType":"ImplementationSpecific"}]}}]` | rules is a list of host rules used to configure the Ingress |
| ingress.rules[0] | object | `{"host":"myapp.cluster.local","http":{"paths":[{"backend":{"serviceNameSuffix":"component-1","servicePort":"http"},"path":"/","pathType":"ImplementationSpecific"}]}}` | host is the URL which ingress is listening |
| ingress.rules[0].http | object | `{"paths":[{"backend":{"serviceNameSuffix":"component-1","servicePort":"http"},"path":"/","pathType":"ImplementationSpecific"}]}` | http is a list of http selectors pointing to backends |
| ingress.rules[0].http.paths | list | `[{"backend":{"serviceNameSuffix":"component-1","servicePort":"http"},"path":"/","pathType":"ImplementationSpecific"}]` | paths is a list of paths that map requests to backends |
Expand Down
15 changes: 15 additions & 0 deletions charts/common/templates/_ingress-ingress.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,20 @@ metadata:
{{- end }}
spec:
ingressClassName: {{ $ingress.ingressClassName }}
{{- if $ingress.defaultBackend }}
{{- if not $ingress.rules }}
defaultBackend:
service:
name: {{ template "library.name" $root }}-{{ $ingress.defaultBackend.serviceNameSuffix }}
port:
{{- if kindIs "float64" $ingress.defaultBackend.servicePort }}
number: {{ $ingress.defaultBackend.servicePort }}
{{- else }}
name: {{ $ingress.defaultBackend.servicePort | quote }}
{{- end }}
{{- end }}
{{- end }}
{{- if not $ingress.defaultBackend }}
rules:
{{- range $ingress.rules }}
- host: {{ .host }}
Expand Down Expand Up @@ -49,5 +63,6 @@ spec:
{{- end }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
{{- end -}}
32 changes: 31 additions & 1 deletion charts/common/values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,24 @@
"ingressClassName": {
"type": "string"
},
"defaultBackend":{
"type":"object",
"required": [
"serviceNameSuffix",
"servicePort"
],
"properties": {
"serviceNameSuffix": {
"type": "string"
},
"servicePort": {
"type": [
"number",
"string"
]
}
}
},
"rules": {
"type": "array",
"items": {
Expand Down Expand Up @@ -558,7 +576,19 @@
}
}
}
}
},
"oneOf": [
{
"required": [
"defaultBackend"
]
},
{
"required": [
"rules"
]
}
]
},
"servicemonitor": {
"type": "object",
Expand Down
12 changes: 11 additions & 1 deletion charts/common/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,16 @@ ingress:
deploy: false
# -- ingressClassName, defines the class of the ingress controller.
ingressClassName: ""
# rules is a list of host rules used to configure the Ingress
# START ONLY FOR SINGLE-SERVICE INGRESSES AND NOT RULESETS
# -- defaultBackend may be used if only a single Service Backend with no Rulesets is needed.
# defaultBackend:
# -- serviceNameSuffix describes the suffix of the serviceName
# serviceNameSuffix: component-1
# -- servicePort describes the port where the service is listening at (can be either a string or a number)
# servicePort: http
# END ONLY FOR SINGLE-SERVICE INGRESSES AND NOT RULESETS
# START ONLY FOR MULTI-SERVICE INGRESSES AND/OR SPECIFIC RULES
# -- rules is a list of host rules used to configure the Ingress
rules:
# -- host is the URL which ingress is listening
- host: myapp.cluster.local
Expand All @@ -54,6 +63,7 @@ ingress:
path: "/"
# -- pathType Each path in an Ingress is required to have a corresponding path type. Comment out for using default ("ImplementationSpecific")
pathType: "ImplementationSpecific"
# END ONLY FOR MULTI-SERVICE INGRESSES AND/OR SPECIFIC RULES

# -- annotations is a dictionary for defining ingress controller specific annotations
annotations:
Expand Down

0 comments on commit fc17db5

Please sign in to comment.