Skip to content

Commit 64f5607

Browse files
authored
✨ Support --klusterlet-values-file for clusteradm join & klusterlet upgrade (#39)
* feat: add chart values to klusterlet config Signed-off-by: Tyler Gillson <[email protected]> * feat: wrapper struct for deepcopy Signed-off-by: Tyler Gillson <[email protected]> * feat: pass --klusterlet-values-file when appropriate Signed-off-by: Tyler Gillson <[email protected]> * feat: pass klusterlet values during upgrade Signed-off-by: Tyler Gillson <[email protected]> * chore: make reviewable Signed-off-by: Tyler Gillson <[email protected]> * chore: bump helm.sh/helm/v3 for GHSA-557j-xg8c-q2mm Signed-off-by: Tyler Gillson <[email protected]> * chore: bump clusteradm to v1.0.1 Signed-off-by: Tyler Gillson <[email protected]> * fix: make values entirely optional; allow updates to klustlert annotations and values Signed-off-by: Tyler Gillson <[email protected]> * chore: bump helm.sh/helm/v3 for GHSA-9h84-qmv7-982p, GHSA-f9f8-9pmf-xv68 Signed-off-by: Tyler Gillson <[email protected]> --------- Signed-off-by: Tyler Gillson <[email protected]>
1 parent 4701f77 commit 64f5607

File tree

454 files changed

+68788
-2845
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

454 files changed

+68788
-2845
lines changed

fleetconfig-controller/api/v1alpha1/fleetconfig_types.go

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,14 @@ package v1alpha1
1818

1919
import (
2020
"fmt"
21+
"maps"
22+
"reflect"
2123
"sort"
2224
"time"
2325

26+
"open-cluster-management.io/ocm/pkg/operator/helpers/chart"
27+
28+
corev1 "k8s.io/api/core/v1"
2429
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2530
)
2631

@@ -540,6 +545,66 @@ type Klusterlet struct {
540545
// +kubebuilder:default:={}
541546
// +optional
542547
Source OCMSource `json:"source,omitzero"`
548+
549+
// Values for the klusterlet Helm chart.
550+
// +optional
551+
Values *KlusterletChartConfig `json:"values,omitempty"`
552+
}
553+
554+
// KlusterletChartConfig is a wrapper around the external chart.KlusterletChartConfig
555+
// to provide the required DeepCopy methods for code generation.
556+
type KlusterletChartConfig struct {
557+
chart.KlusterletChartConfig `json:",inline"`
558+
}
559+
560+
// DeepCopy returns a deep copy of the KlusterletChartConfig.
561+
func (k *KlusterletChartConfig) DeepCopy() *KlusterletChartConfig {
562+
if k == nil {
563+
return nil
564+
}
565+
out := new(KlusterletChartConfig)
566+
k.DeepCopyInto(out)
567+
return out
568+
}
569+
570+
// DeepCopyInto copies all properties of this object into another object of the
571+
// same type that is provided as a pointer.
572+
func (k *KlusterletChartConfig) DeepCopyInto(out *KlusterletChartConfig) {
573+
*out = *k
574+
575+
out.KlusterletChartConfig = k.KlusterletChartConfig
576+
577+
if k.NodeSelector != nil {
578+
k, out := &k.NodeSelector, &out.NodeSelector
579+
*out = make(map[string]string, len(*k))
580+
maps.Copy(*out, *k)
581+
}
582+
if k.Tolerations != nil {
583+
k, out := &k.Tolerations, &out.Tolerations
584+
*out = make([]corev1.Toleration, len(*k))
585+
for i := range *k {
586+
(*k)[i].DeepCopyInto(&(*out)[i])
587+
}
588+
}
589+
590+
k.Affinity.DeepCopyInto(&out.Affinity)
591+
k.Resources.DeepCopyInto(&out.Resources)
592+
k.PodSecurityContext.DeepCopyInto(&out.PodSecurityContext)
593+
k.SecurityContext.DeepCopyInto(&out.SecurityContext)
594+
595+
out.Images = k.Images
596+
out.Klusterlet = k.Klusterlet
597+
598+
if k.MultiHubBootstrapHubKubeConfigs != nil {
599+
k, out := &k.MultiHubBootstrapHubKubeConfigs, &out.MultiHubBootstrapHubKubeConfigs
600+
*out = make([]chart.BootStrapKubeConfig, len(*k))
601+
copy(*out, *k)
602+
}
603+
}
604+
605+
// IsEmpty checks if the KlusterletChartConfig is empty/default/zero-valued
606+
func (k *KlusterletChartConfig) IsEmpty() bool {
607+
return reflect.DeepEqual(*k, KlusterletChartConfig{})
543608
}
544609

545610
// ResourceSpec defines resource limits and requests for all managed clusters.

fleetconfig-controller/api/v1alpha1/validation.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ import (
2323
// - spec.addOnConfig
2424
// - spec.registrationAuth.*
2525
// - spec.hub.clusterManager.source.*
26+
// - spec.spokes[*].klusterlet.annotations
2627
// - spec.spokes[*].klusterlet.source.*
28+
// - spec.spokes[*].klusterlet.values
2729
// - spec.spokes[*].addOns
2830
func allowFleetConfigUpdate(newObject *FleetConfig, oldObject *FleetConfig) error {
2931

@@ -57,8 +59,12 @@ func allowFleetConfigUpdate(newObject *FleetConfig, oldObject *FleetConfig) erro
5759
if oldSpoke, exists := oldSpokes[newSpoke.Name]; exists {
5860
oldSpokeCopy := oldSpoke
5961
newSpokeCopy := newSpoke
62+
newSpokeCopy.Klusterlet.Annotations = nil
63+
oldSpokeCopy.Klusterlet.Annotations = nil
6064
oldSpokeCopy.Klusterlet.Source = (OCMSource{})
6165
newSpokeCopy.Klusterlet.Source = (OCMSource{})
66+
oldSpokeCopy.Klusterlet.Values = nil
67+
newSpokeCopy.Klusterlet.Values = nil
6268
newSpokeCopy.AddOns = []AddOn{}
6369
oldSpokeCopy.AddOns = []AddOn{}
6470

fleetconfig-controller/api/v1alpha1/zz_generated.deepcopy.go

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

fleetconfig-controller/build/Dockerfile.base

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ ARG ARCH
3838
RUN apk update && apk add --no-cache bash curl
3939

4040
# Install clusteradm
41-
ARG CLUSTERADM_VERSION=1.0.0
41+
ARG CLUSTERADM_VERSION=1.0.1
4242
RUN curl -L https://raw.githubusercontent.com/open-cluster-management-io/clusteradm/main/install.sh | bash -s -- ${CLUSTERADM_VERSION}
4343

4444
## Stage 3: Compress binaries with upx to reduce image size

fleetconfig-controller/build/Dockerfile.eks

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ ARG ARCH
3838
RUN apk update && apk add --no-cache bash curl
3939

4040
# Install clusteradm
41-
ARG CLUSTERADM_VERSION=1.0.0
41+
ARG CLUSTERADM_VERSION=1.0.1
4242
RUN curl -L https://raw.githubusercontent.com/open-cluster-management-io/clusteradm/main/install.sh | bash -s -- ${CLUSTERADM_VERSION}
4343

4444
# Install aws-iam-authenticator

fleetconfig-controller/build/Dockerfile.gke

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ ARG ARCH
3737
RUN apk update && apk add --no-cache bash curl
3838

3939
# Install clusteradm
40-
ARG CLUSTERADM_VERSION=1.0.0
40+
ARG CLUSTERADM_VERSION=1.0.1
4141
RUN curl -L https://raw.githubusercontent.com/open-cluster-management-io/clusteradm/main/install.sh | bash -s -- ${CLUSTERADM_VERSION}
4242

4343
## Stage 3: Compress binaries with upx to reduce image size

0 commit comments

Comments
 (0)