Skip to content

Commit

Permalink
Make server protocol configurable (#794)
Browse files Browse the repository at this point in the history
Co-authored-by: Yevhen Ivantsov <yivantsov@atlassian.com>
  • Loading branch information
bianchi2 and Yevhen Ivantsov authored Apr 30, 2024
1 parent a4e4b9c commit 2a41de2
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/main/charts/bamboo-agent/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ Kubernetes: `>=1.21.x-0`
| agent.securityToken.secretKey | string | `"security-token"` | |
| agent.securityToken.secretName | string | `nil` | The name of the K8s Secret that contains the security token. When specified the token will be automatically utilised on agent boot. An Example of creating a K8s secret for the secret below: 'kubectl create secret generic <secret-name> --from-literal=security-token=<security token>' https://kubernetes.io/docs/concepts/configuration/secret/#opaque-secrets |
| agent.server | string | `nil` | |
| agent.serverProtocol | string | `"http"` | The network protocol used for accessing the Bamboo server. Valid values are "http" for unencrypted connections or "https" for encrypted connections using TLS/SSL. |
| agent.shutdown.command | string | `nil` | Custom command for a [preStop hook](https://kubernetes.io/docs/concepts/containers/container-lifecycle-hooks/). Undefined by default which means no pre-stop hook is being executed when an agent container needs to be stopped and deleted |
| agent.shutdown.terminationGracePeriodSeconds | int | `30` | The termination grace period for pods during shutdown. This should be set to the internal grace period, plus a small buffer to allow the JVM to fully terminate. |
| agent.startupProbe.command | string | `"/probe-startup.sh"` | Command to use to check the startup status. This is provided by the agent image. |
Expand Down
2 changes: 1 addition & 1 deletion src/main/charts/bamboo-agent/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ The K8s DNS record for the Bamboo server service
*/}}
{{- define "agent.bambooServerServiceDns" -}}
{{- if .Values.agent.server }}
{{- printf "http://%s" .Values.agent.server }}
{{- printf "%s://%s" .Values.agent.serverProtocol .Values.agent.server }}
{{- end }}
{{- end }}

Expand Down
5 changes: 5 additions & 0 deletions src/main/charts/bamboo-agent/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,11 @@ agent:
#
server:

# -- The network protocol used for accessing the Bamboo server. Valid values are "http" for unencrypted connections
# or "https" for encrypted connections using TLS/SSL.
#
serverProtocol: http

# Standard K8s field that holds pod-level security attributes and common container settings.
# https://kubernetes.io/docs/tasks/configure-pod-container/security-context/
# Do not populate when deploying to OpenShift, unless anyuid policy is attached to a service account.
Expand Down
13 changes: 13 additions & 0 deletions src/test/java/test/BambooAgentTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,19 @@ void baseUrlSet(Product product) throws Exception {
env.assertHasValue("BAMBOO_SERVER", "http://bamboo.bamboo.svc.cluster.local");
}

@ParameterizedTest
@EnumSource(value = Product.class, names = "bamboo_agent")
void serverProtocol(Product product) throws Exception {
final var resources = helm.captureKubeResourcesFromHelmChart(product, Map.of(
"agent.server", "example.com",
"agent.serverProtocol", "https"
));

final var deployment = resources.getDeployment(product.getHelmReleaseName());
final var env = deployment.getContainer().getEnv();
env.assertHasValue("BAMBOO_SERVER", "https://example.com");
}

@ParameterizedTest
@EnumSource(value = Product.class, names = "bamboo_agent")
void bamboo_agent_security_token_secret_name(Product product) throws Exception {
Expand Down

0 comments on commit 2a41de2

Please sign in to comment.