Skip to content

Commit

Permalink
Ndev 21757 NDEV 21756 : feat - added imagePullSecret for cluster-regi…
Browse files Browse the repository at this point in the history
…strator and also included configuration to add cluster labels while registering clusters (#527)

* fix: added imagePullSecret in registrator and cluster labels while registering cluster

Signed-off-by: VedRatan <[email protected]>

* chore: added image pull secret for hooks

Signed-off-by: VedRatan <[email protected]>

* chore: bump chart version

Signed-off-by: VedRatan <[email protected]>

* chore: bump chart version

Signed-off-by: VedRatan <[email protected]>

* chore: revert nirmataURL

Signed-off-by: VedRatan <[email protected]>

---------

Signed-off-by: VedRatan <[email protected]>
  • Loading branch information
VedRatan authored Feb 27, 2025
1 parent e2e25d3 commit 89033a6
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 1 deletion.
2 changes: 1 addition & 1 deletion charts/cluster-registrator/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ type: application
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.1.17-rc4
version: 0.1.17-rc5

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
Expand Down
4 changes: 4 additions & 0 deletions charts/cluster-registrator/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,7 @@ Create the name of the service account to use
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}

{{- define "registrator.imagePullSecret" }}
{{- printf "{\"auths\":{\"%s\":{\"auth\":\"%s\"}}}" .registryName (printf "%s:%s" .userName .password | b64enc) | b64enc }}
{{- end }}
11 changes: 11 additions & 0 deletions charts/cluster-registrator/templates/imagepullsecret.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{{ if and .Values.imagePullSecret.registryName .Values.imagePullSecret.userName .Values.imagePullSecret.password }}
---
apiVersion: v1
kind: Secret
metadata:
name: cluster-registrator-imagepullsecret
namespace: {{ .Values.namespace }}
type: kubernetes.io/dockerconfigjson
data:
.dockerconfigjson: {{ template "registrator.imagePullSecret" .Values.imagePullSecret }}
{{ end }}
8 changes: 8 additions & 0 deletions charts/cluster-registrator/templates/job.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,10 @@ metadata:
spec:
template:
spec:
{{ if and .Values.imagePullSecret.registryName .Values.imagePullSecret.userName .Values.imagePullSecret.password }}
imagePullSecrets:
- name: cluster-registrator-imagepullsecret
{{ end }}
containers:
- name: cluster-registrator
image: {{ .Values.registrator.image.registry | default "ghcr.io" }}/{{ .Values.registrator.image.repository | default "nirmata" }}/cluster-registrator:{{ .Chart.AppVersion }}
Expand All @@ -423,6 +427,10 @@ spec:
- "--token-secret"
- "{{ .Values.apiTokenSecret }}"
{{- end }}
{{ range $key, $value := .Values.clusterLabels }}
- "--labels"
- "{{$key}}:{{$value}}"
{{ end }}
env:
- name: CLUSTER_NAME
value: "{{ .Values.cluster.name }}"
Expand Down
4 changes: 4 additions & 0 deletions charts/cluster-registrator/templates/pre-delete-hook.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ spec:
spec:
restartPolicy: Never
serviceAccountName: nirmata-cluster-registrator
{{ if and .Values.imagePullSecret.registryName .Values.imagePullSecret.userName .Values.imagePullSecret.password }}
imagePullSecrets:
- name: cluster-registrator-imagepullsecret
{{ end }}
containers:
- name: delete-items
image: {{ .Values.hooks.image.registry | default "ghcr.io" }}/{{ .Values.hooks.image.repository | default "nirmata" }}/kubectl:{{ .Values.hooks.image.tag }}
Expand Down
8 changes: 8 additions & 0 deletions charts/cluster-registrator/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,14 @@ proxy:
httpsProxy: ""
noProxy: ""

imagePullSecret:
registryName: ""
userName: ""
password: ""

clusterLabels:
# key: value

registrator:
image:
registry: ""
Expand Down

0 comments on commit 89033a6

Please sign in to comment.