Skip to content

Commit

Permalink
Merge pull request #54 from empathyco/feat/split-ingress
Browse files Browse the repository at this point in the history
chore: allow to split ingress
  • Loading branch information
jmsantorum authored May 14, 2024
2 parents f2b734c + a0ee274 commit 2b19887
Show file tree
Hide file tree
Showing 5 changed files with 71 additions and 3 deletions.
2 changes: 1 addition & 1 deletion charts/motive-service/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ description: A Helm chart for Kubernetes

type: application

version: 2.0.6
version: 2.0.7

appVersion: "1.0.0"
3 changes: 2 additions & 1 deletion charts/motive-service/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# motive-service

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

A Helm chart for Kubernetes

Expand Down Expand Up @@ -29,6 +29,7 @@ A Helm chart for Kubernetes
| ingress.public.hosts[0].paths[0].pathType | string | `"ImplementationSpecific"` | |
| ingress.public.hosts[0].paths[0].port | int | `8080` | |
| ingress.public.hosts[0].paths[0].portName | string | `"http"` | |
| ingress.public.split | bool | `false` | |
| ingress.public.tls | list | `[]` | |
| metrics.enabled | bool | See values.yaml | Enable and configure a Prometheus serviceMonitor for the chart under this key. |
| metrics.podMonitor.annotations | object | `{}` | |
Expand Down
66 changes: 66 additions & 0 deletions charts/motive-service/templates/ingress-public-split.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
{{- with .Values.ingress.public -}}
{{- if and .enabled .split -}}
{{- if and .className (not (semverCompare ">=1.18-0" $.Capabilities.KubeVersion.GitVersion)) }}
{{- if not (hasKey .annotations "kubernetes.io/ingress.class") }}
{{- $_ := set .annotations "kubernetes.io/ingress.class" .className}}
{{- end }}
{{- end }}
{{- $ingressConfig := . -}}
{{- $counter := 0 | int -}}
{{- range $host := .hosts }}
{{- if semverCompare ">=1.19-0" $.Capabilities.KubeVersion.GitVersion -}}
apiVersion: networking.k8s.io/v1
{{- else if semverCompare ">=1.14-0" $.Capabilities.KubeVersion.GitVersion -}}
apiVersion: networking.k8s.io/v1beta1
{{- else -}}
apiVersion: extensions/v1beta1
{{- end }}
kind: Ingress
metadata:
name: {{ include "motive-service.fullname" $ }}-public-{{ $counter }}
labels:
{{- include "motive-service.serviceLabels" $ | nindent 4 }}
{{- $annotations := merge ($host.annotations | default (dict)) $ingressConfig.annotations -}}
{{- with $annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
{{- if and $host.className (semverCompare ">=1.18-0" $.Capabilities.KubeVersion.GitVersion) }}
ingressClassName: {{ $ingressConfig.className }}
{{- end }}
{{- if $ingressConfig.tls }}
tls:
{{- range $ingressConfig.tls }}
- hosts:
{{- range .hosts }}
- {{ . | quote }}
{{- end }}
secretName: {{ .secretName }}
{{- end }}
{{- end }}
rules:
- host: {{ $host.host | quote }}
http:
paths:
{{- range $host.paths }}
- path: {{ .path }}
{{- if and .pathType (semverCompare ">=1.18-0" $.Capabilities.KubeVersion.GitVersion) }}
pathType: {{ .pathType }}
{{- end }}
backend:
{{- if semverCompare ">=1.19-0" $.Capabilities.KubeVersion.GitVersion }}
service:
name: {{ include "motive-service.fullname" $ }}
port:
name: {{ .portName | default "http" }}
{{- else }}
serviceName: {{ include "motive-service.fullname" $ }}
servicePort: {{ .port | default 8080 }}
{{- end }}
{{- end }}
---
{{- $counter = add1 $counter -}}
{{- end }}
{{- end }}
{{- end }}
2 changes: 1 addition & 1 deletion charts/motive-service/templates/ingress-public.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{{- with .Values.ingress.public -}}
{{- if .enabled -}}
{{- if and .enabled (not .split) -}}
{{- if and .className (not (semverCompare ">=1.18-0" $.Capabilities.KubeVersion.GitVersion)) }}
{{- if not (hasKey .annotations "kubernetes.io/ingress.class") }}
{{- $_ := set .annotations "kubernetes.io/ingress.class" .className}}
Expand Down
1 change: 1 addition & 0 deletions charts/motive-service/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,7 @@ ingress:

public:
enabled: false
split: false
className: nginx-public
annotations: {}
# nginx.ingress.kubernetes.io/enable-opentelemetry: "true"
Expand Down

0 comments on commit 2b19887

Please sign in to comment.