Skip to content

Commit

Permalink
feat: allow extra ports to be added to the backend service (#237)
Browse files Browse the repository at this point in the history
This is useful when prometheus metrics are exposed on a different port.
This resolves #236.

Signed-off-by: RedlineTriad <39059512+RedlineTriad@users.noreply.github.com>
  • Loading branch information
RedlineTriad authored Dec 10, 2024
1 parent 5129443 commit df1d5e8
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 9 deletions.
2 changes: 1 addition & 1 deletion charts/backstage/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,4 @@ sources:
# 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: 2.2.0
version: 2.3.0
3 changes: 2 additions & 1 deletion charts/backstage/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Backstage Helm Chart

[![Artifact Hub](https://img.shields.io/endpoint?url=https://artifacthub.io/badge/repository/backstage)](https://artifacthub.io/packages/search?repo=backstage)
![Version: 2.2.0](https://img.shields.io/badge/Version-2.2.0-informational?style=flat-square)
![Version: 2.3.0](https://img.shields.io/badge/Version-2.3.0-informational?style=flat-square)
![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square)

A Helm chart for deploying a Backstage application
Expand Down Expand Up @@ -125,6 +125,7 @@ Kubernetes: `>= 1.19.0-0`
| backstage.extraEnvVars | Backstage container environment variables | list | `[]` |
| backstage.extraEnvVarsCM | Backstage container environment variables from existing ConfigMaps | list | `[]` |
| backstage.extraEnvVarsSecrets | Backstage container environment variables from existing Secrets | list | `[]` |
| backstage.extraPorts | Backstage container additional ports | list | `[]` |
| backstage.extraVolumeMounts | Backstage container additional volume mounts | list | `[]` |
| backstage.extraVolumes | Backstage container additional volumes | list | `[]` |
| backstage.hostAliases | Host Aliases for the pod <br /> Ref: https://kubernetes.io/docs/concepts/services-networking/add-entries-to-pod-etc-hosts-with-host-aliases/ | list | `[]` |
Expand Down
3 changes: 3 additions & 0 deletions charts/backstage/templates/backstage-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,9 @@ spec:
- name: backend
containerPort: {{ .Values.backstage.containerPorts.backend }}
protocol: TCP
{{- if .Values.backstage.extraPorts }}
{{- include "common.tplvalues.render" ( dict "value" .Values.backstage.extraPorts "context" $) | nindent 12 }}
{{- end }}
{{- if (or .Values.backstage.extraAppConfig .Values.backstage.appConfig (and .Values.backstage.extraVolumeMounts .Values.backstage.extraVolumes)) }}
volumeMounts:
{{- range .Values.backstage.extraAppConfig }}
Expand Down
36 changes: 36 additions & 0 deletions charts/backstage/values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -2389,6 +2389,42 @@
"title": "Backstage container environment variables from existing Secrets",
"type": "array"
},
"extraPorts": {
"default": [],
"items": {
"description": "ContainerPort represents a network port in a single container.",
"properties": {
"containerPort": {
"description": "Number of port to expose on the pod's IP address. This must be a valid port number, 0 < x < 65536.",
"format": "int32",
"type": "integer"
},
"hostIP": {
"description": "What host IP to bind the external port to.",
"type": "string"
},
"hostPort": {
"description": "Number of port to expose on the host. If specified, this must be a valid port number, 0 < x < 65536. If HostNetwork is specified, this must match ContainerPort. Most containers do not need this.",
"format": "int32",
"type": "integer"
},
"name": {
"description": "If specified, this must be an IANA_SVC_NAME and unique within the pod. Each named port in a pod must have a unique name. Name for the port that can be referred to by services.",
"type": "string"
},
"protocol": {
"description": "Protocol for port. Must be UDP, TCP, or SCTP. Defaults to \"TCP\".",
"type": "string"
}
},
"required": [
"containerPort"
],
"type": "object"
},
"title": "Extra ports to expose in the Backstage container",
"type": "array"
},
"extraVolumeMounts": {
"default": [],
"items": {
Expand Down
26 changes: 19 additions & 7 deletions charts/backstage/values.schema.tmpl.json
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,14 @@
]
]
},
"extraPorts": {
"title": "Extra ports to expose in the Backstage container",
"type": "array",
"items": {
"$ref": "https://raw.githubusercontent.com/yannh/kubernetes-json-schema/master/master/_definitions.json#/definitions/io.k8s.api.core.v1.ContainerPort"
},
"default": []
},
"extraVolumeMounts": {
"title": "Backstage container additional volume mounts",
"type": "array",
Expand Down Expand Up @@ -457,10 +465,10 @@
"$ref": "https://raw.githubusercontent.com/yannh/kubernetes-json-schema/master/master/_definitions.json#/definitions/io.k8s.api.core.v1.Probe",
"default": {
"httpGet": {
"path": "/.backstage/health/v1/readiness",
"port": 7007,
"scheme": "HTTP"
}
"path": "/.backstage/health/v1/readiness",
"port": 7007,
"scheme": "HTTP"
}
},
"examples": [
{
Expand Down Expand Up @@ -879,13 +887,17 @@
"description": "The port where the metrics are exposed. If using OpenTelemetry as [documented here](https://backstage.io/docs/tutorials/setup-opentelemetry/), then the port needs to be explicitely specificed. OpenTelemetry's default port is 9464.",
"title": "ServiceMonitor endpoint port",
"anyOf": [
{ "type": "string" },
{ "type": "integer" }
{
"type": "string"
},
{
"type": "integer"
}
]
}
}
}
}
}
}
}
}
3 changes: 3 additions & 0 deletions charts/backstage/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,9 @@ backstage:
# -- Backstage container environment variables from existing Secrets
extraEnvVarsSecrets: []

# -- Backstage container additional ports
extraPorts: []

# -- Backstage container additional volume mounts
extraVolumeMounts: []

Expand Down

0 comments on commit df1d5e8

Please sign in to comment.