Skip to content

Commit

Permalink
feat(common): add existing secret support for pullsecret (#31500)
Browse files Browse the repository at this point in the history
**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 <[email protected]>
  • Loading branch information
PrivatePuffin and stavros-k authored Feb 1, 2025
1 parent 8a7f540 commit a759873
Show file tree
Hide file tree
Showing 7 changed files with 77 additions and 28 deletions.
2 changes: 1 addition & 1 deletion charts/library/common-test/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ apiVersion: v2
appVersion: unknown
dependencies:
- name: common
version: ~25.5.0
version: ~25.6.0
repository: file://../common/
condition: ""
alias: ""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ tests:
username: user
password: pass
email: mail
pull-secret3:
enabled: true
existingSecret: some-existing-secret
asserts:
- documentIndex: &cronJobDoc 2
isKind:
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion charts/library/common/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 4 additions & 0 deletions charts/library/common/templates/lib/pod/_imagePullSecret.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -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 -}}
Expand Down
3 changes: 3 additions & 0 deletions charts/library/common/templates/spawner/_imagePullSecret.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -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 */}}
Expand Down
85 changes: 59 additions & 26 deletions website/src/content/docs/common/imagePullSecret.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ Define image pull secrets
| ---------- | ----------------- |
| Key | `imagePullSecret` |
| Type | `map` |
| Required ||
| Helm `tpl` ||
| Required | |
| Helm `tpl` | |
| Default | `{}` |

Example
Expand All @@ -61,8 +61,8 @@ Define image pull secret
| ---------- | ----------------------- |
| Key | `imagePullSecret.$name` |
| Type | `map` |
| Required | ✅ |
| Helm `tpl` | ❌ |
| Required | ✅ |
| Helm `tpl` | ❌ |
| Default | `{}` |

Example
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down

0 comments on commit a759873

Please sign in to comment.