From c214925ca1ec32bf51b57f4c692ef3f0c9c3c694 Mon Sep 17 00:00:00 2001 From: Jim Barber Date: Mon, 20 Mar 2023 17:57:49 +0800 Subject: [PATCH] More configurability of fullname template variable Provide more ways to tailor the `fullname` template variable that is used for naming resources. It's a way to independently set it from the `name` template variable that is used in the `app` label and selector, which is useful when you want to have multiple Buildkite agents with different configuration deployed into the same Kubernetes namespace, but without having awkward resource names. See https://github.com/buildkite/charts/issues/99 for more details. --- stable/agent/Chart.yaml | 2 +- stable/agent/README.md | 2 ++ stable/agent/templates/_helpers.tpl | 8 ++++++++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/stable/agent/Chart.yaml b/stable/agent/Chart.yaml index dc3888f8..78ba6b32 100644 --- a/stable/agent/Chart.yaml +++ b/stable/agent/Chart.yaml @@ -1,7 +1,7 @@ apiVersion: v1 description: Buildkite Agent Chart name: agent -version: 0.6.1 +version: 0.6.2 appVersion: 3.25.0 icon: https://buildkite.com/_next/static/assets/assets/images/brand-assets/buildkite-logo-portrait-on-light-61fc0230.png keywords: diff --git a/stable/agent/README.md b/stable/agent/README.md index 9e554d8f..5b5afb65 100644 --- a/stable/agent/README.md +++ b/stable/agent/README.md @@ -107,6 +107,8 @@ Parameter | Description | Default `dind.resources` | Pod resource requests & limits for dind sidecar (if enabled) | `{}` `dind.volumeMounts` | Extra volumeMounts configuration | `nil` `terminationGracePeriodSeconds` | Duration in seconds the pod needs to terminate gracefully | `30` +`nameOverride` | Provide a name to override the default `$name` template variable | `nil` +`fullnameOverride` | Provide a name to substitute for the full names of resources | `nil` Specify each parameter using the `--set key=value[,key=value]` argument to `helm install`. diff --git a/stable/agent/templates/_helpers.tpl b/stable/agent/templates/_helpers.tpl index 559791e9..724c5b25 100644 --- a/stable/agent/templates/_helpers.tpl +++ b/stable/agent/templates/_helpers.tpl @@ -11,9 +11,17 @@ Create a default fully qualified app name. We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). */}} {{- define "fullname" -}} +{{- if .Values.fullnameOverride -}} +{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}} +{{- else -}} {{- $name := default .Chart.Name .Values.nameOverride -}} +{{- if contains $name .Release.Name -}} +{{- .Release.Name | trunc 63 | trimSuffix "-" -}} +{{- else -}} {{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}} {{- end -}} +{{- end -}} +{{- end -}} {{/* Set the Deployment API version based on the version of Kubernetes the chart is being deployed into.