Skip to content

Commit

Permalink
fixup! refactor: Move helm value to helmRepository.enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
jimmidyson committed Nov 6, 2024
1 parent e738700 commit 710471c
Show file tree
Hide file tree
Showing 10 changed files with 93 additions and 41 deletions.
2 changes: 1 addition & 1 deletion charts/cluster-api-runtime-extensions-nutanix/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ A Helm chart for cluster-api-runtime-extensions-nutanix
| deployment.replicas | int | `1` | |
| env | object | `{}` | |
| helmAddonsConfigMap | string | `"default-helm-addons-config"` | |
| helmRepository.enabled | bool | `true` | |
| helmRepository.images.bundleInitializer.pullPolicy | string | `"IfNotPresent"` | |
| helmRepository.images.bundleInitializer.repository | string | `"ghcr.io/nutanix-cloud-native/caren-helm-reg"` | |
| helmRepository.images.bundleInitializer.tag | string | `""` | |
Expand Down Expand Up @@ -102,7 +103,6 @@ A Helm chart for cluster-api-runtime-extensions-nutanix
| resources.requests.cpu | string | `"100m"` | |
| resources.requests.memory | string | `"128Mi"` | |
| securityContext.runAsUser | int | `65532` | |
| selfHostedRegistry | bool | `true` | |
| service.annotations | object | `{}` | |
| service.port | int | `443` | |
| service.type | string | `"ClusterIP"` | |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,48 +10,48 @@ data:
aws-ccm: |
ChartName: aws-cloud-controller-manager
ChartVersion: 0.0.8
RepositoryURL: "{{ if .Values.selfHostedRegistry }}oci://helm-repository.{{ .Release.Namespace }}.svc/charts{{ else }}https://kubernetes.github.io/cloud-provider-aws{{ end }}"
RepositoryURL: '{{ if .Values.helmRepository.enabled }}oci://helm-repository.{{ .Release.Namespace }}.svc/charts{{ else }}https://kubernetes.github.io/cloud-provider-aws{{ end }}'
aws-ebs-csi: |
ChartName: aws-ebs-csi-driver
ChartVersion: 2.35.1
RepositoryURL: "{{ if .Values.selfHostedRegistry }}oci://helm-repository.{{ .Release.Namespace }}.svc/charts{{ else }}https://kubernetes-sigs.github.io/aws-ebs-csi-driver{{ end }}"
RepositoryURL: '{{ if .Values.helmRepository.enabled }}oci://helm-repository.{{ .Release.Namespace }}.svc/charts{{ else }}https://kubernetes-sigs.github.io/aws-ebs-csi-driver{{ end }}'
cilium: |
ChartName: cilium
ChartVersion: 1.16.2
RepositoryURL: "{{ if .Values.selfHostedRegistry }}oci://helm-repository.{{ .Release.Namespace }}.svc/charts{{ else }}https://helm.cilium.io/{{ end }}"
RepositoryURL: '{{ if .Values.helmRepository.enabled }}oci://helm-repository.{{ .Release.Namespace }}.svc/charts{{ else }}https://helm.cilium.io/{{ end }}'
cluster-autoscaler: |
ChartName: cluster-autoscaler
ChartVersion: 9.40.0
RepositoryURL: "{{ if .Values.selfHostedRegistry }}oci://helm-repository.{{ .Release.Namespace }}.svc/charts{{ else }}https://kubernetes.github.io/autoscaler{{ end }}"
RepositoryURL: '{{ if .Values.helmRepository.enabled }}oci://helm-repository.{{ .Release.Namespace }}.svc/charts{{ else }}https://kubernetes.github.io/autoscaler{{ end }}'
local-path-provisioner-csi: |
ChartName: local-path-provisioner
ChartVersion: 0.0.29
RepositoryURL: "{{ if .Values.selfHostedRegistry }}oci://helm-repository.{{ .Release.Namespace }}.svc/charts{{ else }}https://charts.containeroo.ch{{ end }}"
RepositoryURL: '{{ if .Values.helmRepository.enabled }}oci://helm-repository.{{ .Release.Namespace }}.svc/charts{{ else }}https://charts.containeroo.ch{{ end }}'
metallb: |
ChartName: metallb
ChartVersion: 0.14.8
RepositoryURL: "{{ if .Values.selfHostedRegistry }}oci://helm-repository.{{ .Release.Namespace }}.svc/charts{{ else }}https://metallb.github.io/metallb{{ end }}"
RepositoryURL: '{{ if .Values.helmRepository.enabled }}oci://helm-repository.{{ .Release.Namespace }}.svc/charts{{ else }}https://metallb.github.io/metallb{{ end }}'
nfd: |
ChartName: node-feature-discovery
ChartVersion: 0.16.4
RepositoryURL: "{{ if .Values.selfHostedRegistry }}oci://helm-repository.{{ .Release.Namespace }}.svc/charts{{ else }}https://kubernetes-sigs.github.io/node-feature-discovery/charts{{ end }}"
RepositoryURL: '{{ if .Values.helmRepository.enabled }}oci://helm-repository.{{ .Release.Namespace }}.svc/charts{{ else }}https://kubernetes-sigs.github.io/node-feature-discovery/charts{{ end }}'
nutanix-ccm: |
ChartName: nutanix-cloud-provider
ChartVersion: 0.4.1
RepositoryURL: "{{ if .Values.selfHostedRegistry }}oci://helm-repository.{{ .Release.Namespace }}.svc/charts{{ else }}https://nutanix.github.io/helm/{{ end }}"
RepositoryURL: '{{ if .Values.helmRepository.enabled }}oci://helm-repository.{{ .Release.Namespace }}.svc/charts{{ else }}https://nutanix.github.io/helm/{{ end }}'
nutanix-storage-csi: |
ChartName: nutanix-csi-storage
ChartVersion: 3.1.0
RepositoryURL: "{{ if .Values.selfHostedRegistry }}oci://helm-repository.{{ .Release.Namespace }}.svc/charts{{ else }}https://nutanix.github.io/helm-releases/{{ end }}"
RepositoryURL: '{{ if .Values.helmRepository.enabled }}oci://helm-repository.{{ .Release.Namespace }}.svc/charts{{ else }}https://nutanix.github.io/helm-releases/{{ end }}'
snapshot-controller: |
ChartName: snapshot-controller
ChartVersion: 3.0.6
RepositoryURL: "{{ if .Values.selfHostedRegistry }}oci://helm-repository.{{ .Release.Namespace }}.svc/charts{{ else }}https://piraeus.io/helm-charts/{{ end }}"
RepositoryURL: '{{ if .Values.helmRepository.enabled }}oci://helm-repository.{{ .Release.Namespace }}.svc/charts{{ else }}https://piraeus.io/helm-charts/{{ end }}'
tigera-operator: |
ChartName: tigera-operator
ChartVersion: v3.28.2
RepositoryURL: "{{ if .Values.selfHostedRegistry }}oci://helm-repository.{{ .Release.Namespace }}.svc/charts{{ else }}https://docs.tigera.io/calico/charts{{ end }}"
RepositoryURL: '{{ if .Values.helmRepository.enabled }}oci://helm-repository.{{ .Release.Namespace }}.svc/charts{{ else }}https://docs.tigera.io/calico/charts{{ end }}'
kind: ConfigMap
metadata:
creationTimestamp: null
name: {{ .Values.helmAddonsConfigMap }}
name: '{{ .Values.helmAddonsConfigMap }}'
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# This file contains the manifests to run a helmRepository deployment which contains helm charts for our addons.
# The pod is built via goreleaser with configuration from hack/addons.
#
{{ if .Values.selfHostedRegistry }}
{{ if .Values.helmRepository.enabled }}
apiVersion: cert-manager.io/v1
kind: Issuer
metadata:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@
},
"helmRepository": {
"properties": {
"enabled": {
"type": "boolean"
},
"images": {
"properties": {
"bundleInitializer": {
Expand Down Expand Up @@ -599,9 +602,6 @@
},
"type": "object"
},
"selfHostedRegistry": {
"type": "boolean"
},
"service": {
"properties": {
"annotations": {
Expand Down
3 changes: 1 addition & 2 deletions charts/cluster-api-runtime-extensions-nutanix/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,6 @@ hooks:

helmAddonsConfigMap: default-helm-addons-config

selfHostedRegistry: true

deployDefaultClusterClasses: true

# The ClusterClass and the Templates it references must be in the same namespace
Expand All @@ -133,6 +131,7 @@ image:
pullPolicy: IfNotPresent

helmRepository:
enabled: true
images:
bundleInitializer:
repository: ghcr.io/nutanix-cloud-native/caren-helm-reg
Expand Down
2 changes: 0 additions & 2 deletions hack/addons/add-warning-helm-configmap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,3 @@ $(cat "${GIT_REPO_ROOT}/hack/license-header.yaml.txt")
#=================================================================
$(cat "${ASSETS_DIR}/helm-config.yaml")
EOF

sed -i s/placeholder/"{{ .Values.helmAddonsConfigMap }}"/g "${GIT_REPO_ROOT}/charts/cluster-api-runtime-extensions-nutanix/templates/helm-config.yaml"
57 changes: 56 additions & 1 deletion hack/addons/helm-chart-bundler/repos.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,59 @@
# DO NOT EDIT THIS FILE
# IT HAS BEEN GENERATED BY /hack/addons/generate-mindthegap-repofile.sh
#=================================================================
{}
repositories:
aws-cloud-controller-manager:
repoURL: https://kubernetes.github.io/cloud-provider-aws
charts:
aws-cloud-controller-manager:
- 0.0.8
aws-ebs-csi-driver:
repoURL: https://kubernetes-sigs.github.io/aws-ebs-csi-driver
charts:
aws-ebs-csi-driver:
- 2.35.1
cilium:
repoURL: https://helm.cilium.io/
charts:
cilium:
- 1.16.2
cluster-autoscaler:
repoURL: https://kubernetes.github.io/autoscaler
charts:
cluster-autoscaler:
- 9.40.0
local-path-provisioner:
repoURL: https://charts.containeroo.ch
charts:
local-path-provisioner:
- 0.0.29
metallb:
repoURL: https://metallb.github.io/metallb
charts:
metallb:
- 0.14.8
node-feature-discovery:
repoURL: https://kubernetes-sigs.github.io/node-feature-discovery/charts
charts:
node-feature-discovery:
- 0.16.4
nutanix-cloud-provider:
repoURL: https://nutanix.github.io/helm/
charts:
nutanix-cloud-provider:
- 0.4.1
nutanix-csi-storage:
repoURL: https://nutanix.github.io/helm-releases/
charts:
nutanix-csi-storage:
- 3.1.0
snapshot-controller:
repoURL: https://piraeus.io/helm-charts/
charts:
snapshot-controller:
- 3.0.6
tigera-operator:
repoURL: https://docs.tigera.io/calico/charts
charts:
tigera-operator:
- v3.28.2
2 changes: 1 addition & 1 deletion hack/tools/helm-cm/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ func createConfigMapFromDir(kustomizeDir string) (*corev1.ConfigMap, error) {

finalCM := corev1.ConfigMap{
ObjectMeta: metav1.ObjectMeta{
Name: "placeholder",
Name: "{{ .Values.helmAddonsConfigMap }}",
},
TypeMeta: metav1.TypeMeta{
APIVersion: corev1.SchemeGroupVersion.String(),
Expand Down
34 changes: 17 additions & 17 deletions hack/tools/mindthegap-helm-reg/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,14 @@ package main

import (
"bytes"
"context"
"flag"
"fmt"
"log"
"os"
"path"

"gopkg.in/yaml.v2"
corev1 "k8s.io/api/core/v1"
yamlDecode "k8s.io/apimachinery/pkg/util/yaml"
ctrl "sigs.k8s.io/controller-runtime"
)

type HelmChartFromConfigMap struct {
Expand All @@ -31,8 +29,6 @@ type HelmChartsConfig struct {
Repositories map[string]Repository `yaml:"repositories,omitempty"`
}

var log = ctrl.LoggerFrom(context.Background())

func main() {
args := os.Args
var (
Expand All @@ -46,27 +42,32 @@ func main() {
"input configmap file to create the mindthegap repo file from")
err := flagSet.Parse(args[1:])
if err != nil {
log.Error(err, "failed to parse args")
log.Fatalln("failed to parse args:", err)
}
if outputFile == "" {
log.Fatalln("output file is required")
}
if inputConfigMapFile == "" {
log.Fatalln("input configmap file is required")
}
fullPath := inputConfigMapFile
if !path.IsAbs(fullPath) {
wd, err := os.Getwd()
if err != nil {
log.Error(err, "failed to get wd")
return
log.Fatalln("failed to get wd:", err)
}
fullPath = path.Join(wd, inputConfigMapFile)
}
f, err := os.Open(fullPath)
if err != nil {
log.Error(err, "failed to open file")
return
log.Fatalln("failed to open file:", err)
}
defer f.Close()
cm := &corev1.ConfigMap{}
err = yamlDecode.NewYAMLOrJSONDecoder(f, 1024).Decode(cm)
if err != nil {
log.Error(err, fmt.Sprintf("failed to unmarshal file %s", fullPath))
f.Close()
log.Fatalf("failed to unmarshal file %s: %v\n", fullPath, err)
}
out := HelmChartsConfig{
map[string]Repository{},
Expand All @@ -75,8 +76,7 @@ func main() {
var settings HelmChartFromConfigMap
err = yaml.Unmarshal([]byte(info), &settings)
if err != nil {
log.Error(err, "failed unmarshl settings")
return
log.Fatalln("failed to unmarshal settings:", err)
}
out.Repositories[settings.Name] = Repository{
RepoURL: settings.Repository,
Expand All @@ -89,23 +89,23 @@ func main() {
}
b, err := yaml.Marshal(out)
if err != nil {
log.Error(err, fmt.Sprintf("failed to marshal obj %v", out))
log.Fatalf("failed to marshal obj %+v: %v", out, err)
}
fullOutputfilePath := outputFile
if !path.IsAbs(outputFile) {
wd, err := os.Getwd()
if err != nil {
log.Error(err, "failed")
log.Fatalln("failed:", err)
}
fullOutputfilePath = path.Join(wd, outputFile)
}
f, err = os.OpenFile(fullOutputfilePath, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0o666)
if err != nil {
log.Error(err, "failed to create file")
log.Fatalln("failed to create file:", err)
}
defer f.Close()
_, err = bytes.NewBuffer(b).WriteTo(f)
if err != nil {
log.Error(err, "failed to write to file")
log.Fatalln("failed to write to file:", err)
}
}
2 changes: 1 addition & 1 deletion make/addons.mk
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ generate-mindthegap-repofile: generate-helm-configmap ; $(info $(M) generating h

.PHONY: template-helm-repository
template-helm-repository: generate-mindthegap-repofile ## this is used by gorealeaser to set the helm value to this.
sed -i 's#\(RepositoryURL: *\)\(.*\)#\1"{{ if .Values.selfHostedRegistry }}oci://helm-repository.{{ .Release.Namespace }}.svc/charts{{ else }}\2{{ end }}"#' "./charts/cluster-api-runtime-extensions-nutanix/templates/helm-config.yaml"
yq -i '.data |= (to_entries | map(.value |= (. | fromjson | .RepositoryURL |= "{{ if .Values.helmRepository.enabled }}oci://helm-repository.{{ .Release.Namespace }}.svc/charts{{ else }}" + . + "{{ end }}" | to_yaml)) | from_entries)' ./charts/cluster-api-runtime-extensions-nutanix/templates/helm-config.yaml

.PHONY: list-images
list-images:
Expand Down

0 comments on commit 710471c

Please sign in to comment.