Skip to content

Commit

Permalink
Specify a custom listening port for an application (#1792)
Browse files Browse the repository at this point in the history
User can now specify a custom listening port for an Epinio application.
The port is pushed inside the application container via the environment
variable: PORT.
The value defaults to 8080; it can be specified using a custom chart value
during the application's push:

epinio push -n 'app-name' --chart-value 'appListeningPort=8087'

Valid appListeningPort values range from 1001 to (2^16)-1

Fixes: epinio/epinio#1792
Signed-off-by: Giuseppe Baccini <giuseppe.baccini@suse.com>
  • Loading branch information
Giuseppe Baccini committed Mar 16, 2023
1 parent 059e2b0 commit accb369
Show file tree
Hide file tree
Showing 11 changed files with 30 additions and 8 deletions.
2 changes: 1 addition & 1 deletion chart/application-stateful/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ description: The helm chart for epinio applications to be deployed by
icon: https://raw.githubusercontent.com/epinio/helm-charts/main/assets/epinio.png
home: https://github.com/epinio/epinio
type: application
version: 0.1.21
version: 0.1.22-rc1
keywords:
- epinio
- paas
Expand Down
7 changes: 7 additions & 0 deletions chart/application-stateful/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,10 @@ character removed.
{{- define "epinio-truncate" -}}
{{ print "r-" (sha1sum .) }}
{{- end }}
{{/*
Application listening port
*/}}
{{- define "epinio-app-listening-port" -}}
{{ .Values.userConfig.appListeningPort | default 8080 }}
{{- end }}
2 changes: 1 addition & 1 deletion chart/application-stateful/templates/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ spec:
ports:
- port: 8080
protocol: TCP
targetPort: 8080
targetPort: {{ include "epinio-app-listening-port" . }}
selector:
{{- include "epinio-application.selectorLabels" . | nindent 4 }}
type: ClusterIP
Expand Down
4 changes: 2 additions & 2 deletions chart/application-stateful/templates/statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ spec:
containers:
- name: {{ include "epinio-truncate" .Values.epinio.appName }}
ports:
- containerPort: 8080
- containerPort: {{ include "epinio-app-listening-port" . }}
protocol: TCP
{{- with .Values.epinio.configurations }}
volumeMounts:
Expand All @@ -55,7 +55,7 @@ spec:
{{- end }}
env:
- name: PORT
value: "8080"
value: {{ include "epinio-app-listening-port" . | quote }}
{{- range .Values.epinio.env }}
- name: {{ .name | quote }}
value: {{ .value | quote }}
Expand Down
2 changes: 2 additions & 0 deletions chart/application-stateful/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,5 @@ nodeSelector: {}
tolerations: []

affinity: {}

userConfig: {}
2 changes: 1 addition & 1 deletion chart/application/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ description: The helm chart for epinio applications to be deployed by
icon: https://raw.githubusercontent.com/epinio/helm-charts/main/assets/epinio.png
home: https://github.com/epinio/epinio
type: application
version: 0.1.24
version: 0.1.25-rc1
keywords:
- epinio
- paas
Expand Down
7 changes: 7 additions & 0 deletions chart/application/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,10 @@ character removed.
{{- define "epinio-truncate" -}}
{{ print "r" (trunc 21 (include "epinio-name-sanitize" .)) "-" (sha1sum .) }}
{{- end }}
{{/*
Application listening port
*/}}
{{- define "epinio-app-listening-port" -}}
{{ .Values.userConfig.appListeningPort | default 8080 }}
{{- end }}
4 changes: 2 additions & 2 deletions chart/application/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ spec:
containers:
- name: {{ include "epinio-truncate" .Values.epinio.appName }}
ports:
- containerPort: 8080
- containerPort: {{ include "epinio-app-listening-port" . }}
protocol: TCP
{{- with .Values.epinio.configpaths }}
volumeMounts:
Expand All @@ -52,7 +52,7 @@ spec:
{{- end }}
env:
- name: PORT
value: "8080"
value: {{ include "epinio-app-listening-port" . | quote }}
{{- range .Values.epinio.env }}
- name: {{ .name | quote }}
value: {{ .value | quote }}
Expand Down
2 changes: 1 addition & 1 deletion chart/application/templates/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ spec:
ports:
- port: 8080
protocol: TCP
targetPort: 8080
targetPort: {{ include "epinio-app-listening-port" . }}
selector:
{{- include "epinio-application.selectorLabels" . | nindent 4 }}
type: ClusterIP
2 changes: 2 additions & 0 deletions chart/application/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,5 @@ nodeSelector: {}
tolerations: []

affinity: {}

userConfig: {}
4 changes: 4 additions & 0 deletions chart/epinio/templates/default-app-chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,7 @@ spec:
shortDescription: Epinio standard deployment
description: Epinio standard support chart for application deployment
helmChart: https://github.com/epinio/helm-charts/releases/download/epinio-application-0.1.24/epinio-application-0.1.24.tgz
settings:
appListeningPort:
type: 'integer'
minimum: '1001'

0 comments on commit accb369

Please sign in to comment.