Skip to content

Commit

Permalink
fix: Fix hardcoded image for test connection pod and allow to skip th…
Browse files Browse the repository at this point in the history
…e creation of this pod [RHDHBUGS-155] [RHIDP-5558] (redhat-developer#54)

* Make the test-connection pod image parameters configurable

Otherwise, this can reportedly be an issue in air-gapped environments.

* Allow to skip the creation of the test-connection pod when creating a Release

* Add some test values for CI

* Bump the Chart version

* Add docs to README template
  • Loading branch information
rm3l committed Feb 3, 2025
1 parent 85cc04e commit 405a0b2
Show file tree
Hide file tree
Showing 7 changed files with 131 additions and 4 deletions.
2 changes: 1 addition & 1 deletion charts/backstage/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,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.19.2
version: 2.19.3
47 changes: 46 additions & 1 deletion charts/backstage/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# RHDH Backstage Helm Chart for OpenShift (Community Version)

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

A Helm chart for deploying Red Hat Developer Hub.
Expand Down Expand Up @@ -118,6 +118,46 @@ helm upgrade -i <release_name> oci://ghcr.io/redhat-developer/rhdh-chart/backsta

> **Tip**: List all releases using `helm list`

### Testing a Release

Once an Helm Release has been deployed, you can test it using the [`helm test`](https://helm.sh/docs/helm/helm_test/) command:

```sh
helm test <release_name>
```

This will run a simple Pod in the cluster to check that the application deployed is up and running.

You can control whether to disable this test pod or you can also customize the image it leverages.
See the `test.enabled` and `test.image` parameters in the [`values.yaml`](./values.yaml) file.

> **Tip**: Disabling the test pod will not prevent the `helm test` command from passing later on. It will simply report that no test suite is available.

Below are a few examples:

<details>

<summary>Disabling the test pod</summary>

```sh
helm install <release_name> <repo_or_oci_registry> \
--set test.enabled=false
```

</details>

<details>

<summary>Customizing the test pod image</summary>

```sh
helm install <release_name> <repo_or_oci_registry> \
--set test.image.repository=curl/curl-base \
--set test.image.tag=8.11.1
```

</details>

### Uninstalling the Chart

To uninstall/delete the `my-backstage-release` deployment:
Expand Down Expand Up @@ -166,6 +206,11 @@ Kubernetes: `>= 1.25.0-0`
| route.tls.key | Key file contents | string | `""` |
| route.tls.termination | Specify TLS termination. | string | `"edge"` |
| route.wildcardPolicy | Wildcard policy if any for the route. Currently only 'Subdomain' or 'None' is allowed. | string | `"None"` |
| test | Test pod parameters | object | `{"enabled":true,"image":{"registry":"quay.io","repository":"curl/curl","tag":"latest"}}` |
| test.enabled | Whether to enable the test-connection pod used for testing the Release using `helm test`. | bool | `true` |
| test.image.registry | Test connection pod image registry | string | `"quay.io"` |
| test.image.repository | Test connection pod image repository. Note that the image needs to have both the `sh` and `curl` binaries in it. | string | `"curl/curl"` |
| test.image.tag | Test connection pod image tag. Note that the image needs to have both the `sh` and `curl` binaries in it. | string | `"latest"` |
| upstream | Upstream Backstage [chart configuration](https://github.com/backstage/charts/blob/main/charts/backstage/values.yaml) | object | Use Openshift compatible settings |
| upstream.backstage.initContainers[0].image | Image used by the initContainer to install dynamic plugins into the `dynamic-plugins-root` volume mount. It could be replaced by a custom image based on this one. | string | `quay.io/janus-idp/backstage-showcase:latest` |

Expand Down
40 changes: 40 additions & 0 deletions charts/backstage/README.md.gotmpl
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,46 @@ helm upgrade -i <release_name> oci://ghcr.io/redhat-developer/rhdh-chart/backsta

> **Tip**: List all releases using `helm list`

### Testing a Release

Once an Helm Release has been deployed, you can test it using the [`helm test`](https://helm.sh/docs/helm/helm_test/) command:

```sh
helm test <release_name>
```

This will run a simple Pod in the cluster to check that the application deployed is up and running.

You can control whether to disable this test pod or you can also customize the image it leverages.
See the `test.enabled` and `test.image` parameters in the [`values.yaml`](./values.yaml) file.

> **Tip**: Disabling the test pod will not prevent the `helm test` command from passing later on. It will simply report that no test suite is available.

Below are a few examples:

<details>

<summary>Disabling the test pod</summary>

```sh
helm install <release_name> <repo_or_oci_registry> \
--set test.enabled=false
```

</details>

<details>

<summary>Customizing the test pod image</summary>

```sh
helm install <release_name> <repo_or_oci_registry> \
--set test.image.repository=curl/curl-base \
--set test.image.tag=8.11.1
```

</details>

### Uninstalling the Chart

To uninstall/delete the `my-backstage-release` deployment:
Expand Down
14 changes: 14 additions & 0 deletions charts/backstage/ci/with-custom-image-for-test-pod-values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Workaround for kind cluster in CI which has no Routes and no PVCs
route:
enabled: false
upstream:
postgresql:
primary:
persistence:
enabled: false

test:
image:
registry: quay.io
repository: curl/curl-base
tag: 8.11.1
11 changes: 11 additions & 0 deletions charts/backstage/ci/with-test-pod-disabled-values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Workaround for kind cluster in CI which has no Routes and no PVCs
route:
enabled: false
upstream:
postgresql:
primary:
persistence:
enabled: false

test:
enabled: false
6 changes: 4 additions & 2 deletions charts/backstage/templates/tests/test-connection.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{{- if .Values.test.enabled }}
apiVersion: v1
kind: Pod
metadata:
Expand All @@ -8,7 +9,7 @@ metadata:
{{- include "common.tplvalues.render" ( dict "value" .Values.upstream.commonLabels "context" $ ) | nindent 4 }}
{{- end }}
annotations:
helm.sh/hook: test
helm.sh/hook: test
spec:
containers:
- name: curl
Expand All @@ -30,10 +31,11 @@ spec:
command:
- ls
- /usr/bin/curl
image: quay.io/curl/curl:latest
image: "{{ .Values.test.image.registry }}/{{ .Values.test.image.repository }}:{{ .Values.test.image.tag }}"
imagePullPolicy: IfNotPresent
command: ["/bin/sh", "-c"]
args:
- |
curl --connect-timeout 5 --max-time 20 --retry 20 --retry-delay 10 --retry-max-time 60 --retry-all-errors {{ include "common.names.fullname" . }}:{{ .Values.upstream.service.ports.backend }}
restartPolicy: Never
{{- end }}
15 changes: 15 additions & 0 deletions charts/backstage/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -296,3 +296,18 @@ dynamicPlugins:
requests:
storage: 5Gi
storageClassName: null

# -- Test pod parameters
test:
# -- Whether to enable the test-connection pod used for testing the Release using `helm test`.
enabled: true

image:
# -- Test connection pod image registry
registry: quay.io

# -- Test connection pod image repository. Note that the image needs to have both the `sh` and `curl` binaries in it.
repository: curl/curl

# -- Test connection pod image tag. Note that the image needs to have both the `sh` and `curl` binaries in it.
tag: latest

0 comments on commit 405a0b2

Please sign in to comment.