feat(common): add existing secret support for pullsecret (#31500)

**Description**
<!--
Please include a summary of the change and which issue is fixed. Please
also include relevant motivation and context. List any dependencies that
are required for this change.
-->
⚒️ Fixes  #31324

**⚙️ Type of change**

- [x] ⚙️ Feature/App addition
- [ ] 🪛 Bugfix
- [ ] ⚠️ Breaking change (fix or feature that would cause existing
functionality to not work as expected)
- [ ] 🔃 Refactor of current code

**🧪 How Has This Been Tested?**
<!--
Please describe the tests that you ran to verify your changes. Provide
instructions so we can reproduce. Please also list any relevant details
for your test configuration
-->

**📃 Notes:**
<!-- Please enter any other relevant information here -->

**✔️ Checklist:**

- [ ] ⚖️ My code follows the style guidelines of this project
- [ ] 👀 I have performed a self-review of my own code
- [ ] #️⃣ I have commented my code, particularly in hard-to-understand
areas
- [ ] 📄 I have made corresponding changes to the documentation
- [ ] ⚠️ My changes generate no new warnings
- [ ] 🧪 I have added tests to this description that prove my fix is
effective or that my feature works
- [ ] ⬆️ I increased versions for any altered app according to semantic
versioning
- [ ] I made sure the title starts with `feat(chart-name):`,
`fix(chart-name):` or `chore(chart-name):`

** App addition**

If this PR is an app addition please make sure you have done the
following.

- [ ] 🖼️ I have added an icon in the Chart's root directory called
`icon.png`

---

_Please don't blindly check all the boxes. Read them and only check
those that apply.
Those checkboxes are there for the reviewer to see what is this all
about and
the status of this PR with a quick glance._

---------

Co-authored-by: Stavros Kois <s.kois@outlook.com>
This commit is contained in:
Kjeld Schouten
2025-02-01 22:52:32 +01:00
committed by GitHub
co-authored by Stavros Kois
parent 8a7f540e51
commit a759873bf5
7 changed files with 77 additions and 28 deletions
+1 -1
View File
@@ -7,7 +7,7 @@ apiVersion: v2
appVersion: unknown appVersion: unknown
dependencies: dependencies:
- name: common - name: common
version: ~25.5.0 version: ~25.6.0
repository: file://../common/ repository: file://../common/
condition: "" condition: ""
alias: "" alias: ""
@@ -22,7 +22,12 @@ tests:
username: user2 username: user2
password: pass2 password: pass2
email: mail2 email: mail2
my-pull-secret3:
enabled: true
existingSecret: some-existing-secret
asserts: asserts:
- hasDocuments:
count: 2
- documentIndex: &secretDoc 0 - documentIndex: &secretDoc 0
isKind: isKind:
of: Secret of: Secret
@@ -34,6 +34,9 @@ tests:
username: user username: user
password: pass password: pass
email: mail email: mail
pull-secret3:
enabled: true
existingSecret: some-existing-secret
asserts: asserts:
- documentIndex: &cronJobDoc 2 - documentIndex: &cronJobDoc 2
isKind: isKind:
@@ -48,6 +51,7 @@ tests:
value: value:
- name: test-release-name-common-test-pull-secret1 - name: test-release-name-common-test-pull-secret1
- name: test-release-name-common-test-pull-secret2 - name: test-release-name-common-test-pull-secret2
- name: some-existing-secret
- documentIndex: &otherDeploymentDoc 3 - documentIndex: &otherDeploymentDoc 3
isKind: isKind:
of: Deployment of: Deployment
+1 -1
View File
@@ -48,4 +48,4 @@ sources:
- https://hub.docker.com/_/ - https://hub.docker.com/_/
- https://hub.docker.com/r/mikefarah/yq - https://hub.docker.com/r/mikefarah/yq
type: library type: library
version: 25.5.0 version: 25.6.0
@@ -13,6 +13,10 @@ objectData: The object data to be used to render the Pod.
{{- range $name, $imgPull := $rootCtx.Values.imagePullSecret -}} {{- range $name, $imgPull := $rootCtx.Values.imagePullSecret -}}
{{- $pullName := (printf "%s-%s" (include "tc.v1.common.lib.chart.names.fullname" $rootCtx) $name) -}} {{- $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 $imgPull.enabled -}}
{{/* If targetSelectAll is true */}} {{/* If targetSelectAll is true */}}
{{- if $imgPull.targetSelectAll -}} {{- if $imgPull.targetSelectAll -}}
@@ -13,6 +13,9 @@
"name" $name "caller" "Image Pull Secret" "name" $name "caller" "Image Pull Secret"
"key" "imagePullSecret")) -}} "key" "imagePullSecret")) -}}
{{- if $imgPullSecret.existingSecret -}}
{{- continue -}}
{{- end -}}
{{- if eq $enabled "true" -}} {{- if eq $enabled "true" -}}
{{/* Create a copy of the configmap */}} {{/* Create a copy of the configmap */}}
@@ -41,8 +41,8 @@ Define image pull secrets
| ---------- | ----------------- | | ---------- | ----------------- |
| Key | `imagePullSecret` | | Key | `imagePullSecret` |
| Type | `map` | | Type | `map` |
| Required | ❌ | | Required | ❌ |
| Helm `tpl` | ❌ | | Helm `tpl` | ❌ |
| Default | `{}` | | Default | `{}` |
Example Example
@@ -61,8 +61,8 @@ Define image pull secret
| ---------- | ----------------------- | | ---------- | ----------------------- |
| Key | `imagePullSecret.$name` | | Key | `imagePullSecret.$name` |
| Type | `map` | | Type | `map` |
| Required | ✅ | | Required | ✅ |
| Helm `tpl` | ❌ | | Helm `tpl` | ❌ |
| Default | `{}` | | Default | `{}` |
Example Example
@@ -82,8 +82,8 @@ Enables or Disables the image pull secret
| ---------- | ------------------------------- | | ---------- | ------------------------------- |
| Key | `imagePullSecret.$name.enabled` | | Key | `imagePullSecret.$name.enabled` |
| Type | `bool` | | Type | `bool` |
| Required | ✅ | | Required | ✅ |
| Helm `tpl` | ✅ | | Helm `tpl` | ✅ |
| Default | `false` | | Default | `false` |
Example 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` #### `namespace`
Define the namespace for this object Define the namespace for this object
@@ -104,8 +137,8 @@ Define the namespace for this object
| ---------- | --------------------------------- | | ---------- | --------------------------------- |
| Key | `imagePullSecret.$name.namespace` | | Key | `imagePullSecret.$name.namespace` |
| Type | `string` | | Type | `string` |
| Required | ❌ | | Required | ❌ |
| Helm `tpl` | ✅ (On value only) | | Helm `tpl` | ✅ (On value only) |
| Default | `""` | | Default | `""` |
Example Example
@@ -126,8 +159,8 @@ Additional labels for image pull secret
| ---------- | ------------------------------ | | ---------- | ------------------------------ |
| Key | `imagePullSecret.$name.labels` | | Key | `imagePullSecret.$name.labels` |
| Type | `map` | | Type | `map` |
| Required | ❌ | | Required | ❌ |
| Helm `tpl` | ✅ (On value only) | | Helm `tpl` | ✅ (On value only) |
| Default | `{}` | | Default | `{}` |
Example Example
@@ -149,8 +182,8 @@ Additional annotations for image pull secret
| ---------- | ----------------------------------- | | ---------- | ----------------------------------- |
| Key | `imagePullSecret.$name.annotations` | | Key | `imagePullSecret.$name.annotations` |
| Type | `map` | | Type | `map` |
| Required | ❌ | | Required | ❌ |
| Helm `tpl` | ✅ (On value only) | | Helm `tpl` | ✅ (On value only) |
| Default | `{}` | | Default | `{}` |
Example Example
@@ -172,8 +205,8 @@ Whether to assign the secret to all pods or not
| ---------- | --------------------------------------- | | ---------- | --------------------------------------- |
| Key | `imagePullSecret.$name.targetSelectAll` | | Key | `imagePullSecret.$name.targetSelectAll` |
| Type | `bool` | | Type | `bool` |
| Required | ❌ | | Required | ❌ |
| Helm `tpl` | ❌ | | Helm `tpl` | ❌ |
| Default | unset | | Default | unset |
Example Example
@@ -194,8 +227,8 @@ Define the pod(s) to assign the secret
| ---------- | -------------------------------------- | | ---------- | -------------------------------------- |
| Key | `imagePullSecret.$name.targetSelector` | | Key | `imagePullSecret.$name.targetSelector` |
| Type | `list` of `string` | | Type | `list` of `string` |
| Required | ❌ | | Required | ❌ |
| Helm `tpl` | ❌ | | Helm `tpl` | ❌ |
| Default | `[]` | | Default | `[]` |
Example Example
@@ -218,8 +251,8 @@ Define the data of the image pull secret
| ---------- | ---------------------------- | | ---------- | ---------------------------- |
| Key | `imagePullSecret.$name.data` | | Key | `imagePullSecret.$name.data` |
| Type | `map` | | Type | `map` |
| Required | ✅ | | Required | ✅ |
| Helm `tpl` | ❌ | | Helm `tpl` | ❌ |
| Default | `{}` | | Default | `{}` |
Example Example
@@ -240,8 +273,8 @@ Define the registry of the image pull secret
| ---------- | ------------------------------------- | | ---------- | ------------------------------------- |
| Key | `imagePullSecret.$name.data.registry` | | Key | `imagePullSecret.$name.data.registry` |
| Type | `string` | | Type | `string` |
| Required | ✅ | | Required | ✅ |
| Helm `tpl` | ✅ | | Helm `tpl` | ✅ |
| Default | `""` | | Default | `""` |
Example Example
@@ -263,8 +296,8 @@ Define the username of the image pull secret
| ---------- | ------------------------------------- | | ---------- | ------------------------------------- |
| Key | `imagePullSecret.$name.data.username` | | Key | `imagePullSecret.$name.data.username` |
| Type | `string` | | Type | `string` |
| Required | ✅ | | Required | ✅ |
| Helm `tpl` | ✅ | | Helm `tpl` | ✅ |
| Default | `""` | | Default | `""` |
Example Example
@@ -286,8 +319,8 @@ Define the password of the image pull secret
| ---------- | ------------------------------------- | | ---------- | ------------------------------------- |
| Key | `imagePullSecret.$name.data.password` | | Key | `imagePullSecret.$name.data.password` |
| Type | `string` | | Type | `string` |
| Required | ✅ | | Required | ✅ |
| Helm `tpl` | ✅ | | Helm `tpl` | ✅ |
| Default | `""` | | Default | `""` |
Example Example
@@ -309,8 +342,8 @@ Define the email of the image pull secret
| ---------- | ---------------------------------- | | ---------- | ---------------------------------- |
| Key | `imagePullSecret.$name.data.email` | | Key | `imagePullSecret.$name.data.email` |
| Type | `string` | | Type | `string` |
| Required | ✅ | | Required | ✅ |
| Helm `tpl` | ✅ | | Helm `tpl` | ✅ |
| Default | `""` | | Default | `""` |
Example Example