diff --git a/charts/library/common-test/Chart.yaml b/charts/library/common-test/Chart.yaml index b3aba11e104..ed12a9e8852 100644 --- a/charts/library/common-test/Chart.yaml +++ b/charts/library/common-test/Chart.yaml @@ -7,7 +7,7 @@ apiVersion: v2 appVersion: unknown dependencies: - name: common - version: ~25.5.0 + version: ~25.6.0 repository: file://../common/ condition: "" alias: "" diff --git a/charts/library/common-test/tests/imagePullSecret/name_test.yaml b/charts/library/common-test/tests/imagePullSecret/name_test.yaml index 67853ef457d..8ad4b615903 100644 --- a/charts/library/common-test/tests/imagePullSecret/name_test.yaml +++ b/charts/library/common-test/tests/imagePullSecret/name_test.yaml @@ -22,7 +22,12 @@ tests: username: user2 password: pass2 email: mail2 + my-pull-secret3: + enabled: true + existingSecret: some-existing-secret asserts: + - hasDocuments: + count: 2 - documentIndex: &secretDoc 0 isKind: of: Secret diff --git a/charts/library/common-test/tests/pod/image_pull_secret_test.yaml b/charts/library/common-test/tests/pod/image_pull_secret_test.yaml index 2df955d171a..d96b78bcde6 100644 --- a/charts/library/common-test/tests/pod/image_pull_secret_test.yaml +++ b/charts/library/common-test/tests/pod/image_pull_secret_test.yaml @@ -34,6 +34,9 @@ tests: username: user password: pass email: mail + pull-secret3: + enabled: true + existingSecret: some-existing-secret asserts: - documentIndex: &cronJobDoc 2 isKind: @@ -48,6 +51,7 @@ tests: value: - name: test-release-name-common-test-pull-secret1 - name: test-release-name-common-test-pull-secret2 + - name: some-existing-secret - documentIndex: &otherDeploymentDoc 3 isKind: of: Deployment diff --git a/charts/library/common/Chart.yaml b/charts/library/common/Chart.yaml index 96a22832c10..91cb30cfcc5 100644 --- a/charts/library/common/Chart.yaml +++ b/charts/library/common/Chart.yaml @@ -48,4 +48,4 @@ sources: - https://hub.docker.com/_/ - https://hub.docker.com/r/mikefarah/yq type: library -version: 25.5.0 +version: 25.6.0 diff --git a/charts/library/common/templates/lib/pod/_imagePullSecret.tpl b/charts/library/common/templates/lib/pod/_imagePullSecret.tpl index de0f23ecb04..87b4c0fe371 100644 --- a/charts/library/common/templates/lib/pod/_imagePullSecret.tpl +++ b/charts/library/common/templates/lib/pod/_imagePullSecret.tpl @@ -13,6 +13,10 @@ objectData: The object data to be used to render the Pod. {{- range $name, $imgPull := $rootCtx.Values.imagePullSecret -}} {{- $pullName := (printf "%s-%s" (include "tc.v1.common.lib.chart.names.fullname" $rootCtx) $name) -}} + {{- if $imgPull.existingSecret -}} + {{- $pullName = $imgPull.existingSecret -}} + {{- end -}} + {{- if $imgPull.enabled -}} {{/* If targetSelectAll is true */}} {{- if $imgPull.targetSelectAll -}} diff --git a/charts/library/common/templates/spawner/_imagePullSecret.tpl b/charts/library/common/templates/spawner/_imagePullSecret.tpl index 6c606f2d2c6..5dfb309a51b 100644 --- a/charts/library/common/templates/spawner/_imagePullSecret.tpl +++ b/charts/library/common/templates/spawner/_imagePullSecret.tpl @@ -13,6 +13,9 @@ "name" $name "caller" "Image Pull Secret" "key" "imagePullSecret")) -}} + {{- if $imgPullSecret.existingSecret -}} + {{- continue -}} + {{- end -}} {{- if eq $enabled "true" -}} {{/* Create a copy of the configmap */}} diff --git a/website/src/content/docs/common/imagePullSecret.md b/website/src/content/docs/common/imagePullSecret.md index e475adfd3c9..14e47ac1d06 100644 --- a/website/src/content/docs/common/imagePullSecret.md +++ b/website/src/content/docs/common/imagePullSecret.md @@ -41,8 +41,8 @@ Define image pull secrets | ---------- | ----------------- | | Key | `imagePullSecret` | | Type | `map` | -| Required | ❌ | -| Helm `tpl` | ❌ | +| Required | ❌ | +| Helm `tpl` | ❌ | | Default | `{}` | Example @@ -61,8 +61,8 @@ Define image pull secret | ---------- | ----------------------- | | Key | `imagePullSecret.$name` | | Type | `map` | -| Required | ✅ | -| Helm `tpl` | ❌ | +| Required | ✅ | +| Helm `tpl` | ❌ | | Default | `{}` | Example @@ -82,8 +82,8 @@ Enables or Disables the image pull secret | ---------- | ------------------------------- | | Key | `imagePullSecret.$name.enabled` | | Type | `bool` | -| Required | ✅ | -| Helm `tpl` | ✅ | +| Required | ✅ | +| Helm `tpl` | ✅ | | Default | `false` | Example @@ -96,6 +96,39 @@ imagePullSecret: --- +#### `existingSecret` + +Define the existing secret name + +:::note + +If this is defined, only the following keys are used: + +- `enabled` +- `targetSelectAll` +- `targetSelector` + +::: + +| | | +| ---------- | -------------------------------------- | +| Key | `imagePullSecret.$name.existingSecret` | +| Type | `string` | +| Required | ❌ | +| Helm `tpl` | ❌ | +| Default | - | + +Example + +```yaml +imagePullSecret: + pull-secret-name: + enabled: true + existingSecret: some-existing-secret +``` + +--- + #### `namespace` Define the namespace for this object @@ -104,8 +137,8 @@ Define the namespace for this object | ---------- | --------------------------------- | | Key | `imagePullSecret.$name.namespace` | | Type | `string` | -| Required | ❌ | -| Helm `tpl` | ✅ (On value only) | +| Required | ❌ | +| Helm `tpl` | ✅ (On value only) | | Default | `""` | Example @@ -126,8 +159,8 @@ Additional labels for image pull secret | ---------- | ------------------------------ | | Key | `imagePullSecret.$name.labels` | | Type | `map` | -| Required | ❌ | -| Helm `tpl` | ✅ (On value only) | +| Required | ❌ | +| Helm `tpl` | ✅ (On value only) | | Default | `{}` | Example @@ -149,8 +182,8 @@ Additional annotations for image pull secret | ---------- | ----------------------------------- | | Key | `imagePullSecret.$name.annotations` | | Type | `map` | -| Required | ❌ | -| Helm `tpl` | ✅ (On value only) | +| Required | ❌ | +| Helm `tpl` | ✅ (On value only) | | Default | `{}` | Example @@ -172,8 +205,8 @@ Whether to assign the secret to all pods or not | ---------- | --------------------------------------- | | Key | `imagePullSecret.$name.targetSelectAll` | | Type | `bool` | -| Required | ❌ | -| Helm `tpl` | ❌ | +| Required | ❌ | +| Helm `tpl` | ❌ | | Default | unset | Example @@ -194,8 +227,8 @@ Define the pod(s) to assign the secret | ---------- | -------------------------------------- | | Key | `imagePullSecret.$name.targetSelector` | | Type | `list` of `string` | -| Required | ❌ | -| Helm `tpl` | ❌ | +| Required | ❌ | +| Helm `tpl` | ❌ | | Default | `[]` | Example @@ -218,8 +251,8 @@ Define the data of the image pull secret | ---------- | ---------------------------- | | Key | `imagePullSecret.$name.data` | | Type | `map` | -| Required | ✅ | -| Helm `tpl` | ❌ | +| Required | ✅ | +| Helm `tpl` | ❌ | | Default | `{}` | Example @@ -240,8 +273,8 @@ Define the registry of the image pull secret | ---------- | ------------------------------------- | | Key | `imagePullSecret.$name.data.registry` | | Type | `string` | -| Required | ✅ | -| Helm `tpl` | ✅ | +| Required | ✅ | +| Helm `tpl` | ✅ | | Default | `""` | Example @@ -263,8 +296,8 @@ Define the username of the image pull secret | ---------- | ------------------------------------- | | Key | `imagePullSecret.$name.data.username` | | Type | `string` | -| Required | ✅ | -| Helm `tpl` | ✅ | +| Required | ✅ | +| Helm `tpl` | ✅ | | Default | `""` | Example @@ -286,8 +319,8 @@ Define the password of the image pull secret | ---------- | ------------------------------------- | | Key | `imagePullSecret.$name.data.password` | | Type | `string` | -| Required | ✅ | -| Helm `tpl` | ✅ | +| Required | ✅ | +| Helm `tpl` | ✅ | | Default | `""` | Example @@ -309,8 +342,8 @@ Define the email of the image pull secret | ---------- | ---------------------------------- | | Key | `imagePullSecret.$name.data.email` | | Type | `string` | -| Required | ✅ | -| Helm `tpl` | ✅ | +| Required | ✅ | +| Helm `tpl` | ✅ | | Default | `""` | Example