Skip to content

Commit b72b113

Browse files
authored
feat: adds a mindthegap container and deployment (#637)
**What problem does this PR solve?**: This mindthegap container is going to serve the helm charts for any helm addons we have. **Which issue(s) this PR fixes**: https://jira.nutanix.com/browse/NCN-100596 https://jira.nutanix.com/browse/NCN-100597 **How Has This Been Tested?**: <!-- Please describe the tests that you ran to verify your changes. Provide output from the tests and any manual steps needed to replicate the tests. --> **Special notes for your reviewer**: <!-- Use this to provide any additional information to the reviewers. This may include: - Best way to review the PR. - Where the author wants the most review attention on. - etc. -->
1 parent d633b6b commit b72b113

File tree

25 files changed

+409
-71
lines changed

25 files changed

+409
-71
lines changed

.github/workflows/checks.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,8 @@ jobs:
222222
devbox run -- \
223223
kind load docker-image \
224224
--name chart-testing \
225-
"ko.local/cluster-api-runtime-extensions-nutanix:$(devbox run -- gojq -r .version dist/metadata.json)"
225+
"ko.local/cluster-api-runtime-extensions-nutanix:$(devbox run -- gojq -r .version dist/metadata.json)" \
226+
"ghcr.io/nutanix-cloud-native/caren-helm-reg:$(devbox run -- gojq -r .version dist/metadata.json)"
226227
227228
- if: steps.list-changed.outputs.changed == 'true'
228229
name: Setup Cluster API and cert-manager
@@ -238,7 +239,7 @@ jobs:
238239
devbox run -- \
239240
ct install \
240241
--config charts/ct-config.yaml \
241-
--helm-extra-set-args "--set-string image.repository=ko.local/cluster-api-runtime-extensions-nutanix --set-string image.tag=$(devbox run -- gojq -r .version dist/metadata.json)"
242+
--helm-extra-set-args "--set-string image.repository=ko.local/cluster-api-runtime-extensions-nutanix --set-string image.tag=$(devbox run -- gojq -r .version dist/metadata.json) --set-string helmRepositoryImage.tag=$(devbox run -- gojq -r .version dist/metadata.json)"
242243
env:
243244
KUBECONFIG: ct-kind-kubeconfig
244245

.goreleaser.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ before:
4242
$(helm template {{ .ProjectName }} ./charts/{{ .ProjectName }} \
4343
--namespace caren-system \
4444
--set-string image.tag=v{{ trimprefix .Version "v" }} \
45+
--set-string helmRepositoryImage.tag=v{{ trimprefix .Version "v" }} \
4546
{{ if .IsSnapshot }}--set-string image.repository=ko.local/{{ .ProjectName }}{{ end }} \
4647
)
4748
EOF'
@@ -50,6 +51,8 @@ before:
5051
sh -ec 'gojq --yaml-input --yaml-output \
5152
".releaseSeries |= (. + [{contract: \"v1beta1\", major: {{ .Major }}, minor: {{ .Minor }}}] | unique)" \
5253
metadata.yaml >release-metadata.yaml'
54+
- make template-helm-repository
55+
5356

5457
builds:
5558
- id: cluster-api-runtime-extensions-nutanix
@@ -92,6 +95,15 @@ archives:
9295
builds:
9396
- cluster-api-runtime-extensions-nutanix
9497

98+
dockers:
99+
- id: helm-registry-container
100+
use: buildx
101+
dockerfile: ./hack/addons/mindthegap-helm-registry/Dockerfile
102+
extra_files:
103+
- hack/addons/mindthegap-helm-registry/repos.yaml
104+
image_templates:
105+
- 'ghcr.io/nutanix-cloud-native/caren-helm-reg:{{ .Version }}'
106+
95107
kos:
96108
- id: cluster-api-runtime-extensions-nutanix
97109
build: cluster-api-runtime-extensions-nutanix

.pre-commit-config.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,11 @@ repos:
3434
language: system
3535
files: "^(hack/addons/|charts/cluster-api-runtime-extensions-nutanix/templates/.+/manifests/|make/addons.mk$)"
3636
pass_filenames: false
37-
- id: addons-configmap
38-
name: addons-configmap
39-
entry: make generate-helm-configmap
37+
- id: addons-repo-yaml
38+
name: addons-repo-yaml
39+
entry: make template-helm-repository
4040
language: system
41-
files: "^(hack/addons/|charts/cluster-api-runtime-extensions-nutanix/templates/.+|make/addons.mk$)"
41+
files: "hack/addons/mindthegap-helm-registry/repos.yaml"
4242
pass_filenames: false
4343
- id: check-devbox-lock
4444
name: check-devbox-lock

api/v1alpha1/zz_generated.deepcopy.go

Lines changed: 4 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

charts/cluster-api-runtime-extensions-nutanix/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ A Helm chart for cluster-api-runtime-extensions-nutanix
3232
| deployment.replicas | int | `1` | |
3333
| env | object | `{}` | |
3434
| helmAddonsConfigMap | string | `"default-helm-addons-config"` | |
35+
| helmRepositoryImage.pullPolicy | string | `"IfNotPresent"` | |
36+
| helmRepositoryImage.repository | string | `"ghcr.io/nutanix-cloud-native/caren-helm-reg"` | |
37+
| helmRepositoryImage.tag | string | `""` | |
3538
| hooks.ccm.nutanix.helmAddonStrategy.defaultValueTemplateConfigMap.create | bool | `true` | |
3639
| hooks.ccm.nutanix.helmAddonStrategy.defaultValueTemplateConfigMap.name | string | `"default-nutanix-ccm-helm-values-template"` | |
3740
| hooks.clusterAutoscaler.crsStrategy.defaultInstallationConfigMap.name | string | `"cluster-autoscaler"` | |
@@ -77,6 +80,7 @@ A Helm chart for cluster-api-runtime-extensions-nutanix
7780
| resources.requests.cpu | string | `"100m"` | |
7881
| resources.requests.memory | string | `"128Mi"` | |
7982
| securityContext.runAsUser | int | `65532` | |
83+
| selfHostedRegistry | bool | `true` | |
8084
| service.annotations | object | `{}` | |
8185
| service.port | int | `443` | |
8286
| service.type | string | `"ClusterIP"` | |

charts/cluster-api-runtime-extensions-nutanix/templates/helm-config.yaml

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,39 +10,39 @@ data:
1010
cilium: |
1111
ChartName: cilium
1212
ChartVersion: 1.15.5
13-
RepositoryURL: https://helm.cilium.io/
13+
RepositoryURL: {{ if .Values.selfHostedRegistry }}oci://helm-repository.{{ .Release.Namespace }}.svc/charts{{ else }}https://helm.cilium.io/{{ end }}
1414
cluster-autoscaler: |
1515
ChartName: cluster-autoscaler
1616
ChartVersion: 9.37.0
17-
RepositoryURL: https://kubernetes.github.io/autoscaler
17+
RepositoryURL: {{ if .Values.selfHostedRegistry }}oci://helm-repository.{{ .Release.Namespace }}.svc/charts{{ else }}https://kubernetes.github.io/autoscaler{{ end }}
1818
local-path-provisioner-csi: |
1919
ChartName: local-path-provisioner
20-
ChartVersion: v0.0.29
21-
RepositoryURL: https://charts.containeroo.ch
20+
ChartVersion: 0.0.29
21+
RepositoryURL: {{ if .Values.selfHostedRegistry }}oci://helm-repository.{{ .Release.Namespace }}.svc/charts{{ else }}https://charts.containeroo.ch{{ end }}
2222
metallb: |
2323
ChartName: metallb
24-
ChartVersion: v0.14.5
25-
RepositoryURL: https://metallb.github.io/metallb
24+
ChartVersion: 0.14.5
25+
RepositoryURL: {{ if .Values.selfHostedRegistry }}oci://helm-repository.{{ .Release.Namespace }}.svc/charts{{ else }}https://metallb.github.io/metallb{{ end }}
2626
nfd: |
2727
ChartName: node-feature-discovery
2828
ChartVersion: 0.15.2
29-
RepositoryURL: https://kubernetes-sigs.github.io/node-feature-discovery/charts
29+
RepositoryURL: {{ if .Values.selfHostedRegistry }}oci://helm-repository.{{ .Release.Namespace }}.svc/charts{{ else }}https://kubernetes-sigs.github.io/node-feature-discovery/charts{{ end }}
3030
nutanix-ccm: |
3131
ChartName: nutanix-cloud-provider
3232
ChartVersion: 0.3.3
33-
RepositoryURL: https://nutanix.github.io/helm/
33+
RepositoryURL: {{ if .Values.selfHostedRegistry }}oci://helm-repository.{{ .Release.Namespace }}.svc/charts{{ else }}https://nutanix.github.io/helm/{{ end }}
3434
nutanix-snapshot-csi: |
3535
ChartName: nutanix-csi-snapshot
36-
ChartVersion: v6.3.2
37-
RepositoryURL: https://nutanix.github.io/helm/
36+
ChartVersion: 6.3.2
37+
RepositoryURL: {{ if .Values.selfHostedRegistry }}oci://helm-repository.{{ .Release.Namespace }}.svc/charts{{ else }}https://nutanix.github.io/helm/{{ end }}
3838
nutanix-storage-csi: |
3939
ChartName: nutanix-csi-storage
40-
ChartVersion: v3.0.0-beta.1912
41-
RepositoryURL: https://nutanix.github.io/helm-releases/
40+
ChartVersion: 3.0.0-beta.1912
41+
RepositoryURL: {{ if .Values.selfHostedRegistry }}oci://helm-repository.{{ .Release.Namespace }}.svc/charts{{ else }}https://nutanix.github.io/helm-releases/{{ end }}
4242
tigera-operator: |
4343
ChartName: tigera-operator
4444
ChartVersion: v3.28.0
45-
RepositoryURL: https://docs.tigera.io/calico/charts
45+
RepositoryURL: {{ if .Values.selfHostedRegistry }}oci://helm-repository.{{ .Release.Namespace }}.svc/charts{{ else }}https://docs.tigera.io/calico/charts{{ end }}
4646
kind: ConfigMap
4747
metadata:
4848
creationTimestamp: null
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
# Copyright 2024 Nutanix. All rights reserved.
2+
# SPDX-License-Identifier: Apache-2.0
3+
# This file contains the manifests to run a helmRepository deployment which contains helm charts for our addons.
4+
# The pod is built via goreleaser with configuration from hack/addons.
5+
#
6+
{{ if .Values.selfHostedRegistry }}
7+
apiVersion: cert-manager.io/v1
8+
kind: Issuer
9+
metadata:
10+
name: helm-repository-selfsigned
11+
namespace: {{ .Release.Namespace }}
12+
spec:
13+
selfSigned: {}
14+
---
15+
apiVersion: cert-manager.io/v1
16+
kind: Certificate
17+
metadata:
18+
name: helm-repository-tls
19+
namespace: {{ .Release.Namespace }}
20+
spec:
21+
dnsNames:
22+
- helm-repository.{{ .Release.Namespace }}.svc
23+
- helm-repository.{{ .Release.Namespace }}.svc.cluster.local
24+
issuerRef:
25+
name: helm-repository-selfsigned
26+
kind: Issuer
27+
secretName: helm-repository-tls
28+
---
29+
apiVersion: apps/v1
30+
kind: Deployment
31+
metadata:
32+
name: helm-repository
33+
namespace: {{ .Release.Namespace }}
34+
labels:
35+
app: helm-repository
36+
spec:
37+
replicas: 1
38+
strategy:
39+
type: Recreate
40+
selector:
41+
matchLabels:
42+
app: helm-repository # deployment will track pods it generates because of this
43+
template:
44+
metadata:
45+
labels:
46+
app: helm-repository # pods have this label, and Service and Deployment depend on it
47+
spec:
48+
containers:
49+
- name: helm-repository
50+
ports:
51+
- name: serve
52+
protocol: TCP
53+
containerPort: 5000
54+
image: "{{ .Values.helmRepositoryImage.repository }}:{{ .Values.helmRepositoryImage.tag | default $.Chart.AppVersion }}"
55+
imagePullPolicy: "{{ .Values.image.pullPolicy }}"
56+
volumeMounts:
57+
- name: certs-vol
58+
mountPath: "/certs"
59+
readOnly: true
60+
env:
61+
volumes:
62+
- name: certs-vol
63+
secret:
64+
secretName: helm-repository-tls
65+
---
66+
apiVersion: v1
67+
kind: Service
68+
metadata:
69+
name: helm-repository
70+
namespace: {{ .Release.Namespace }}
71+
spec:
72+
selector:
73+
app: helm-repository
74+
ports:
75+
- port: 443
76+
targetPort: 5000
77+
type: ClusterIP
78+
{{ end }}

charts/cluster-api-runtime-extensions-nutanix/values.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,9 @@ hooks:
8484

8585
helmAddonsConfigMap: default-helm-addons-config
8686

87+
selfHostedRegistry: true
88+
89+
8790
deployDefaultClusterClasses: true
8891

8992
deployment:
@@ -94,6 +97,11 @@ image:
9497
tag: ""
9598
pullPolicy: IfNotPresent
9699

100+
helmRepositoryImage:
101+
repository: ghcr.io/nutanix-cloud-native/caren-helm-reg
102+
tag: ""
103+
pullPolicy: IfNotPresent
104+
97105
# -- Optional secrets used for pulling the container image
98106
imagePullSecrets: []
99107
# - name: Secret with Registry credentials

0 commit comments

Comments
 (0)