Skip to content

Commit

Permalink
feat: configurable ingress backend (#124)
Browse files Browse the repository at this point in the history
  • Loading branch information
bzp2010 authored Jul 5, 2024
1 parent 03fd935 commit 65377e0
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 37 deletions.
2 changes: 1 addition & 1 deletion charts/api7/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.14.5
version: 0.15.0

# 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
17 changes: 8 additions & 9 deletions charts/api7/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# api7ee3

![Version: 0.14.5](https://img.shields.io/badge/Version-0.14.5-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 3.0.0](https://img.shields.io/badge/AppVersion-3.0.0-informational?style=flat-square)
![Version: 0.15.0](https://img.shields.io/badge/Version-0.15.0-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 3.0.0](https://img.shields.io/badge/AppVersion-3.0.0-informational?style=flat-square)

A Helm chart for Kubernetes

Expand Down Expand Up @@ -67,19 +67,18 @@ A Helm chart for Kubernetes
| developer_portal.image.pullPolicy | string | `"IfNotPresent"` | |
| developer_portal.image.repository | string | `"api7/api7-developer-portal"` | |
| developer_portal.image.tag | string | `"v0.0.5"` | |
| developer_portal.ingress.annotations | object | `{}` | |
| developer_portal.ingress.className | string | `""` | |
| developer_portal.ingress.enabled | bool | `false` | |
| developer_portal.ingress.hosts[0].host | string | `"developer-portal.local"` | |
| developer_portal.ingress.hosts[0].paths[0].path | string | `"/"` | |
| developer_portal.ingress.hosts[0].paths[0].pathType | string | `"ImplementationSpecific"` | |
| developer_portal.ingress.tls | list | `[]` | |
| developer_portal.port | int | `4321` | |
| developer_portal.replicaCount | int | `1` | |
| developer_portal_configuration.enable | bool | `true` | |
| developer_portal_configuration.server.listen.host | string | `"0.0.0.0"` | |
| developer_portal_configuration.server.listen.port | int | `4321` | |
| developer_portal_configuration.server.listen.tls.enabled | bool | `true` | |
| developer_portal_service.ingress.annotations | object | `{}` | |
| developer_portal_service.ingress.className | string | `""` | |
| developer_portal_service.ingress.enabled | bool | `false` | |
| developer_portal_service.ingress.hosts[0].host | string | `"developer-portal.local"` | |
| developer_portal_service.ingress.hosts[0].paths[0].path | string | `"/"` | |
| developer_portal_service.ingress.hosts[0].paths[0].pathType | string | `"ImplementationSpecific"` | |
| developer_portal_service.ingress.tls | list | `[]` | |
| developer_portal_service.port | int | `4321` | |
| developer_portal_service.type | string | `"ClusterIP"` | |
| dp_manager.extraEnvVars | list | `[]` | |
Expand Down
4 changes: 4 additions & 0 deletions charts/api7/templates/dashboard-ingress.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ spec:
{{- if and .pathType (semverCompare ">=1.18-0" $.Capabilities.KubeVersion.GitVersion) }}
pathType: {{ .pathType }}
{{- end }}
{{- if .backend }}
backend: {{ toYaml .backend | nindent 14 }}
{{- else }}
backend:
{{- if semverCompare ">=1.19-0" $.Capabilities.KubeVersion.GitVersion }}
service:
Expand All @@ -62,6 +65,7 @@ spec:
serviceName: {{ $fullName }}
servicePort: {{ $svcPort }}
{{- end }}
{{- end}}
{{- end }}
{{- end }}
{{- end }}
26 changes: 15 additions & 11 deletions charts/api7/templates/developer-portal-ingress.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{{- if .Values.developer_portal.ingress.enabled }}
{{- if .Values.developer_portal_service.ingress.enabled }}
{{- $fullName := printf "%s-developer-portal" (include "api7ee3.fullname" .) -}}
{{- $svcPort := .Values.developer_portal.port -}}
{{- if and .Values.developer_portal.ingress.className (not (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion)) }}
{{- if not (hasKey .Values.developer_portal.ingress.annotations "kubernetes.io/ingress.class") }}
{{- $_ := set .Values.developer_portal.ingress.annotations "kubernetes.io/ingress.class" .Values.developer_portal.ingress.className}}
{{- $svcPort := .Values.developer_portal_service.port -}}
{{- if and .Values.developer_portal_service.ingress.className (not (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion)) }}
{{- if not (hasKey .Values.developer_portal_service.ingress.annotations "kubernetes.io/ingress.class") }}
{{- $_ := set .Values.developer_portal_service.ingress.annotations "kubernetes.io/ingress.class" .Values.developer_portal_service.ingress.className}}
{{- end }}
{{- end }}
{{- if semverCompare ">=1.19-0" .Capabilities.KubeVersion.GitVersion -}}
Expand All @@ -18,17 +18,17 @@ metadata:
name: {{ $fullName }}
labels:
{{- include "api7ee3.labels" . | nindent 4 }}
{{- with .Values.developer_portal.ingress.annotations }}
{{- with .Values.developer_portal_service.ingress.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
{{- if and .Values.developer_portal.ingress.className (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion) }}
ingressClassName: {{ .Values.developer_portal.ingress.className }}
{{- if and .Values.developer_portal_service.ingress.className (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion) }}
ingressClassName: {{ .Values.developer_portal_service.ingress.className }}
{{- end }}
{{- if .Values.developer_portal.ingress.tls }}
{{- if .Values.developer_portal_service.ingress.tls }}
tls:
{{- range .Values.developer_portal.ingress.tls }}
{{- range .Values.developer_portal_service.ingress.tls }}
- hosts:
{{- range .hosts }}
- {{ . | quote }}
Expand All @@ -37,7 +37,7 @@ spec:
{{- end }}
{{- end }}
rules:
{{- range .Values.developer_portal.ingress.hosts }}
{{- range .Values.developer_portal_service.ingress.hosts }}
- host: {{ .host | quote }}
http:
paths:
Expand All @@ -46,6 +46,9 @@ spec:
{{- if and .pathType (semverCompare ">=1.18-0" $.Capabilities.KubeVersion.GitVersion) }}
pathType: {{ .pathType }}
{{- end }}
{{- if .backend }}
backend: {{ toYaml .backend | nindent 14 }}
{{- else }}
backend:
{{- if semverCompare ">=1.19-0" $.Capabilities.KubeVersion.GitVersion }}
service:
Expand All @@ -56,6 +59,7 @@ spec:
serviceName: {{ $fullName }}
servicePort: {{ $svcPort }}
{{- end }}
{{- end}}
{{- end }}
{{- end }}
{{- end }}
4 changes: 4 additions & 0 deletions charts/api7/templates/dp-manager-ingress.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ spec:
{{- if and .pathType (semverCompare ">=1.18-0" $.Capabilities.KubeVersion.GitVersion) }}
pathType: {{ .pathType }}
{{- end }}
{{- if .backend }}
backend: {{ toYaml .backend | nindent 14 }}
{{- else }}
backend:
{{- if semverCompare ">=1.19-0" $.Capabilities.KubeVersion.GitVersion }}
service:
Expand All @@ -56,6 +59,7 @@ spec:
serviceName: {{ $fullName }}
servicePort: {{ $svcPort }}
{{- end }}
{{- end}}
{{- end }}
{{- end }}
{{- end }}
46 changes: 30 additions & 16 deletions charts/api7/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,22 +30,6 @@ developer_portal:
# Overrides the image tag whose default is the chart appVersion.
tag: "v0.0.5"
extraEnvVars: []
port: 4321
ingress:
enabled: false
className: ""
annotations: {}
# kubernetes.io/ingress.class: nginx
# kubernetes.io/tls-acme: "true"
hosts:
- host: developer-portal.local
paths:
- path: /
pathType: ImplementationSpecific
tls: []
# - secretName: developer-portal-tls
# hosts:
# - developer-portal.local


imagePullSecret: ""
Expand Down Expand Up @@ -89,6 +73,11 @@ dashboard_service:
paths:
- path: /
pathType: ImplementationSpecific
# backend:
# service:
# name: api7ee3-dashboard
# port:
# number: 7943
tls: []
# - secretName: dashboard-tls
# hosts:
Expand All @@ -109,6 +98,11 @@ dp_manager_service:
paths:
- path: /
pathType: ImplementationSpecific
# backend:
# service:
# name: api7ee3-dp-manager
# port:
# number: 7943
tls: []
# - secretName: dp-manager-tls
# hosts:
Expand All @@ -117,6 +111,26 @@ dp_manager_service:
developer_portal_service:
type: ClusterIP
port: 4321
ingress:
enabled: false
className: ""
annotations: {}
# kubernetes.io/ingress.class: nginx
# kubernetes.io/tls-acme: "true"
hosts:
- host: developer-portal.local
paths:
- path: /
pathType: ImplementationSpecific
# backend:
# service:
# name: api7ee3-developer-portal
# port:
# number: 7943
tls: []
# - secretName: developer-portal-tls
# hosts:
# - developer-portal.local

resources: {}
# We usually recommend not to specify default resources and to leave this as a conscious
Expand Down

0 comments on commit 65377e0

Please sign in to comment.