Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support for multiple services #38

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,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: 1.2.0
version: 1.2.1

# 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
12 changes: 5 additions & 7 deletions templates/ingress.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,19 +50,17 @@ spec:
backend:
{{- if semverCompare ">=1.19-0" $.Capabilities.KubeVersion.GitVersion }}
service:
{{- range $key, $value := $svcPort }}
name: {{ $fullName }}
name: {{ if $.Values.ingress.multipleServices }}{{ $fullName }}{{ .path | trimPrefix "/" | replace "/" "-" | lower | trimSuffix "-" | trimPrefix "-" }}{{ else }}{{ $fullName }}{{ end }}
port:
{{- if $servicePortName }}
name: {{ $servicePortName }}
{{- else }}
number: {{ .port }}
number: {{ (index $svcPort 0).port }}
{{- end }}
{{- else }}
serviceName: {{ $fullName }}
servicePort: {{ .port }}
{{- end }}
serviceName: {{ if $.Values.ingress.multipleServices }}{{ $fullName }}{{ .path | trimPrefix "/" | replace "/" "-" | lower | trimSuffix "-" | trimPrefix "-" }}{{ else }}{{ $fullName }}{{ end }}
servicePort: {{ (index $svcPort 0).port }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
41 changes: 38 additions & 3 deletions templates/service.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,38 @@
{{ $servicePorts := .Values.service.ports }}
{{- if .Values.ingress.multipleServices }}
{{- $servicePorts := .Values.service.ports }}
{{- $servicePortName := .Values.service.portName -}}
{{- range .Values.ingress.hosts }}
{{- range .paths }}
apiVersion: v1
kind: Service
metadata:
name: {{ include "microservice.fullname" $ }}{{ .path | trimPrefix "/" | replace "/" "-" | lower | trimSuffix "-" | trimPrefix "-" }}
labels:
{{- include "microservice.labels" $ | nindent 4 }}
spec:
type: {{ $.Values.service.type }}
ports:
{{- range $key, $value := $servicePorts }}
- port: {{ .port }}
{{- if $servicePortName }}
targetPort: {{ $servicePortName }}
{{- else }}
targetPort: {{ .name }}
{{- end }}
protocol: TCP
{{- if $servicePortName }}
name: {{ $servicePortName }}
{{- else }}
name: {{ .name }}
{{- end }}
{{- end }}
selector:
{{- include "microservice.selectorLabels" $ | nindent 4 }}
---
{{- end }}
{{- end }}
{{- else }}
{{- $servicePorts := .Values.service.ports }}
{{- $servicePortName := .Values.service.portName -}}
apiVersion: v1
kind: Service
Expand All @@ -9,7 +43,7 @@ metadata:
spec:
type: {{ .Values.service.type }}
ports:
{{- range $key, $value := $servicePorts }}
{{- range $key, $value := $servicePorts }}
- port: {{ .port }}
{{- if $servicePortName }}
targetPort: {{ $servicePortName }}
Expand All @@ -22,6 +56,7 @@ spec:
{{- else }}
name: {{ .name }}
{{- end }}
{{- end }}
{{- end }}
selector:
{{- include "microservice.selectorLabels" . | nindent 4 }}
{{- end }}
1 change: 1 addition & 0 deletions values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ service:

ingress:
enabled: false
multipleServices: false
className: ""
annotations: {}
# kubernetes.io/ingress.class: nginx
Expand Down
Loading