Skip to content

Commit ec12918

Browse files
authored
✨ add --klusterlet-values-file flag for arbitrary overrides during join/upgrade (#506)
* feat: add --klusterlet-file flag for arbitrary overrides during join/upgrade Signed-off-by: Tyler Gillson <[email protected]> * chore: address CodeRabbit nits Signed-off-by: Tyler Gillson <[email protected]> * test: upgrade controller-runtime & configure logger for e2e tests Signed-off-by: Tyler Gillson <[email protected]> * test: configurable e2e suite execution via GINGKO_LABEL_FILTER; fix typo in bootstrap token test filename Signed-off-by: Tyler Gillson <[email protected]> * fix: restrict klusterlet file fields during upgrade Signed-off-by: Tyler Gillson <[email protected]> * test: add --klusterlet-file e2e tests for join & upgrade Signed-off-by: Tyler Gillson <[email protected]> * ci: bump to go 1.24 Signed-off-by: Tyler Gillson <[email protected]> * chore: fix non-constant format string in call to fmt.Fprintf Signed-off-by: Tyler Gillson <[email protected]> * chore: address CodeRabbit nits Signed-off-by: Tyler Gillson <[email protected]> * refactor: replace CR with klusterlet Helm chart values Signed-off-by: Tyler Gillson <[email protected]> * chore: update flag descriptions Signed-off-by: Tyler Gillson <[email protected]> * test: add hack to get E2E passing. something was broken upstream. Signed-off-by: Tyler Gillson <[email protected]> * test: revert E2E hack Signed-off-by: Tyler Gillson <[email protected]> * ci: bump setup-go to v5 Signed-off-by: Tyler Gillson <[email protected]> * chore: address CodeRabbit nits Signed-off-by: Tyler Gillson <[email protected]> * chore: improve docstring for MergeKlusterletValues Signed-off-by: Tyler Gillson <[email protected]> * fix: dedicated test values files for join/upgrade Signed-off-by: Tyler Gillson <[email protected]> * test: bump deletion timeout; full suite passing locally, but CI seems to need more time now Signed-off-by: Tyler Gillson <[email protected]> * test: bump deletion timeout; full suite passing locally, but CI seems to need more time now Signed-off-by: Tyler Gillson <[email protected]> * test: bump deletion timeout; full suite passing locally, but CI seems to need more time now Signed-off-by: Tyler Gillson <[email protected]> --------- Signed-off-by: Tyler Gillson <[email protected]>
1 parent 6702b24 commit ec12918

File tree

109 files changed

+12284
-41
lines changed

Some content is hidden

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

109 files changed

+12284
-41
lines changed

.github/workflows/ocm.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
- run: echo ${{ github.event.client_payload.sha }}
1616
- uses: actions/checkout@v3
1717
- name: Set up Go
18-
uses: actions/setup-go@v3
18+
uses: actions/setup-go@v5
1919
with:
2020
go-version: ${{ env.GO_VERSION }}
2121
- name: E2E Tests

.github/workflows/release.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
- name: Checkout code
2020
uses: actions/checkout@v3
2121
- name: Set up Go
22-
uses: actions/setup-go@v3
22+
uses: actions/setup-go@v5
2323
with:
2424
go-version: ${{ env.GO_VERSION }}
2525
- name: Build project

.github/workflows/tests.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
steps:
1818
- uses: actions/checkout@v3
1919
- name: Set up Go
20-
uses: actions/setup-go@v3
20+
uses: actions/setup-go@v5
2121
with:
2222
go-version: ${{ env.GO_VERSION }}
2323
- name: verify
@@ -29,7 +29,7 @@ jobs:
2929
GOPATH: /tmp/go
3030
steps:
3131
- name: Set up Go
32-
uses: actions/setup-go@v3
32+
uses: actions/setup-go@v5
3333
with:
3434
go-version: ${{ env.GO_VERSION }}
3535
- name: Create GOPATH src directory
@@ -49,7 +49,7 @@ jobs:
4949
steps:
5050
- uses: actions/checkout@v3
5151
- name: Set up Go
52-
uses: actions/setup-go@v3
52+
uses: actions/setup-go@v5
5353
with:
5454
go-version: ${{ env.GO_VERSION }}
5555
- name: Integration Tests
@@ -60,7 +60,7 @@ jobs:
6060
steps:
6161
- uses: actions/checkout@v3
6262
- name: Set up Go
63-
uses: actions/setup-go@v3
63+
uses: actions/setup-go@v5
6464
with:
6565
go-version: ${{ env.GO_VERSION }}
6666
- name: E2E Tests

go.mod

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ require (
6868
github.com/go-errors/errors v1.4.2 // indirect
6969
github.com/go-gorp/gorp/v3 v3.1.0 // indirect
7070
github.com/go-logr/logr v1.4.2 // indirect
71+
github.com/go-logr/zapr v1.3.0 // indirect
7172
github.com/go-openapi/jsonpointer v0.21.0 // indirect
7273
github.com/go-openapi/jsonreference v0.20.2 // indirect
7374
github.com/go-openapi/swag v0.23.0 // indirect
@@ -129,6 +130,8 @@ require (
129130
go.opentelemetry.io/otel v1.33.0 // indirect
130131
go.opentelemetry.io/otel/trace v1.33.0 // indirect
131132
go.uber.org/automaxprocs v1.6.0 // indirect
133+
go.uber.org/multierr v1.11.0 // indirect
134+
go.uber.org/zap v1.27.0 // indirect
132135
go.yaml.in/yaml/v2 v2.4.2 // indirect
133136
go.yaml.in/yaml/v3 v3.0.3 // indirect
134137
golang.org/x/crypto v0.41.0 // indirect

pkg/cmd/join/cmd.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,5 +87,6 @@ func NewCmd(clusteradmFlags *genericclioptionsclusteradm.ClusteradmFlags, stream
8787
cmd.Flags().StringVar(&o.hubClusterArn, "hub-cluster-arn", "", "The arn of the hub cluster(i.e. EKS cluster) to which managed-cluster will join")
8888
cmd.Flags().StringVar(&o.managedClusterArn, "managed-cluster-arn", "", "The arn of the managed cluster(i.e. EKS cluster) which will be joining the hub")
8989
cmd.Flags().StringArrayVar(&o.klusterletAnnotations, "klusterlet-annotation", []string{}, fmt.Sprintf("Annotations to set on the ManagedCluster, in key=value format. Note: each key will be automatically prefixed with '%s/', if not set.", operatorv1.ClusterAnnotationsKeyPrefix))
90+
cmd.Flags().StringVar(&o.klusterletValuesFile, "klusterlet-values-file", "", "The path to a YAML file containing klusterlet Helm chart values. The values from the file override both the default klusterlet chart values and the values from other flags.")
9091
return cmd
9192
}

pkg/cmd/join/exec.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,11 @@ import (
3636
clusterv1 "open-cluster-management.io/api/cluster/v1"
3737
ocmfeature "open-cluster-management.io/api/feature"
3838
operatorv1 "open-cluster-management.io/api/operator/v1"
39+
3940
"open-cluster-management.io/clusteradm/pkg/cmd/join/preflight"
4041
genericclioptionsclusteradm "open-cluster-management.io/clusteradm/pkg/genericclioptions"
4142
"open-cluster-management.io/clusteradm/pkg/helpers"
43+
"open-cluster-management.io/clusteradm/pkg/helpers/klusterlet"
4244
preflightinterface "open-cluster-management.io/clusteradm/pkg/helpers/preflight"
4345
"open-cluster-management.io/clusteradm/pkg/helpers/printer"
4446
"open-cluster-management.io/clusteradm/pkg/helpers/reader"
@@ -247,8 +249,15 @@ func (o *Options) complete(cmd *cobra.Command, args []string) (err error) {
247249
if err := o.capiOptions.Complete(cmd, args); err != nil {
248250
return err
249251
}
250-
return nil
251252

253+
// If a klusterlet chart values file was provided, read and merge it
254+
if o.klusterletValuesFile != "" {
255+
if err := klusterlet.MergeKlusterletValues(o.klusterletValuesFile, o.klusterletChartConfig); err != nil {
256+
return fmt.Errorf("failed to merge klusterlet values file: %v", err)
257+
}
258+
}
259+
260+
return nil
252261
}
253262

254263
func (o *Options) validate() error {

pkg/cmd/join/options.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,10 @@ type Options struct {
100100

101101
// Annotations for registration controller to set on the ManagedCluster
102102
klusterletAnnotations []string
103+
104+
// klusterletValuesFile is the path to a YAML file containing klusterlet Helm chart values.
105+
// The values from the file override the default klusterlet chart values.
106+
klusterletValuesFile string
103107
}
104108

105109
func newOptions(clusteradmFlags *genericclioptionsclusteradm.ClusteradmFlags, streams genericiooptions.IOStreams) *Options {

pkg/cmd/upgrade/klusterlet/cmd.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,5 +51,6 @@ func NewCmd(clusteradmFlags *genericclioptionsclusteradm.ClusteradmFlags, stream
5151
"Path to a file containing version bundle overrides. Optional. If provided, overrides component versions within the selected version bundle.")
5252
cmd.Flags().BoolVar(&o.wait, "wait", false,
5353
"If set, the command will initialize the OCM control plan in foreground.")
54+
cmd.Flags().StringVar(&o.klusterletValuesFile, "klusterlet-values-file", "", "The path to a YAML file containing klusterlet Helm chart values. The values from the file override both the default klusterlet chart values and the values from other flags.")
5455
return cmd
5556
}

pkg/cmd/upgrade/klusterlet/exec.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ import (
1010
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
1111
"k8s.io/klog/v2"
1212
operatorclient "open-cluster-management.io/api/client/operator/clientset/versioned"
13+
1314
"open-cluster-management.io/clusteradm/pkg/helpers"
15+
"open-cluster-management.io/clusteradm/pkg/helpers/klusterlet"
1416
"open-cluster-management.io/clusteradm/pkg/helpers/reader"
1517
"open-cluster-management.io/clusteradm/pkg/helpers/wait"
1618
"open-cluster-management.io/clusteradm/pkg/version"
@@ -72,6 +74,13 @@ func (o *Options) complete(_ *cobra.Command, _ []string) (err error) {
7274
o.klusterletChartConfig.Klusterlet.WorkConfiguration = *k.Spec.WorkConfiguration
7375
}
7476

77+
// If a klusterlet values file was provided, read and merge it
78+
if o.klusterletValuesFile != "" {
79+
if err := klusterlet.MergeKlusterletValues(o.klusterletValuesFile, o.klusterletChartConfig); err != nil {
80+
return fmt.Errorf("failed to merge klusterlet values file: %v", err)
81+
}
82+
}
83+
7584
return nil
7685
}
7786

pkg/cmd/upgrade/klusterlet/options.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ type Options struct {
2323
//If set, the command will hold until the OCM control plane initialized
2424
wait bool
2525

26+
// klusterletValuesFile is the path to a YAML file containing klusterlet Helm chart values.
27+
// The values from the file override the default klusterlet chart values.
28+
klusterletValuesFile string
29+
2630
Streams genericiooptions.IOStreams
2731
}
2832

0 commit comments

Comments
 (0)