Skip to content

Commit b5ede5a

Browse files
committed
Fix bundle version
Signed-off-by: Jian Qiu <[email protected]>
1 parent b762279 commit b5ede5a

File tree

28 files changed

+281
-310
lines changed

28 files changed

+281
-310
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ require (
3131
open-cluster-management.io/api v0.14.1-0.20240627145512-bd6f2229b53c
3232
open-cluster-management.io/cluster-proxy v0.4.0
3333
open-cluster-management.io/managed-serviceaccount v0.6.0
34-
open-cluster-management.io/ocm v0.14.1-0.20240829031425-567a9a4e188c
34+
open-cluster-management.io/ocm v0.14.1-0.20240830005001-41c9196e5418
3535
open-cluster-management.io/sdk-go v0.14.1-0.20240628095929-9ffb1b19e566
3636
sigs.k8s.io/apiserver-network-proxy v0.29.0
3737
sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.29.0

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -577,8 +577,8 @@ open-cluster-management.io/cluster-proxy v0.4.0 h1:rm0UDaDWe3/P3xLzwqdHtqNksKwSz
577577
open-cluster-management.io/cluster-proxy v0.4.0/go.mod h1:gTvfDHAhGezhdg4BD3ECBn6jbg2Y5PbHhV2ceW5nrB0=
578578
open-cluster-management.io/managed-serviceaccount v0.6.0 h1:qIi5T9WQJBuoGqnYGIktXbtqfQoiN2H9XU2P/6lAQiw=
579579
open-cluster-management.io/managed-serviceaccount v0.6.0/go.mod h1:G4LUTbZiyrB8c0+rqi/xnDmGlsg7Rdr4T7MPLCWhyQI=
580-
open-cluster-management.io/ocm v0.14.1-0.20240829031425-567a9a4e188c h1:j2exRpAeji0qZispaOnSHsq6VhX8XHbIGS8F4djNw4E=
581-
open-cluster-management.io/ocm v0.14.1-0.20240829031425-567a9a4e188c/go.mod h1:KWsyZ9g9AyPcgwi8x+8g+LFJQ9oHNIRfsP5YI/npKFA=
580+
open-cluster-management.io/ocm v0.14.1-0.20240830005001-41c9196e5418 h1:lcM/+6sjZvkP1/ffojg2+A4cAgPR4h73xXrSqOudbsY=
581+
open-cluster-management.io/ocm v0.14.1-0.20240830005001-41c9196e5418/go.mod h1:KWsyZ9g9AyPcgwi8x+8g+LFJQ9oHNIRfsP5YI/npKFA=
582582
open-cluster-management.io/sdk-go v0.14.1-0.20240628095929-9ffb1b19e566 h1:8dgPiM3byX/rtOrFJIsea2haV4hSFTND65Tlj1EdK18=
583583
open-cluster-management.io/sdk-go v0.14.1-0.20240628095929-9ffb1b19e566/go.mod h1:xFmN3Db5nN68oLGnstmIRv4us8HJCdXFnBNMXVp0jWY=
584584
oras.land/oras-go v1.2.5 h1:XpYuAwAb0DfQsunIyMfeET92emK8km3W4yEzZvUbsTo=

pkg/cmd/init/exec.go

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import (
2626
"open-cluster-management.io/clusteradm/pkg/helpers/reader"
2727
"open-cluster-management.io/clusteradm/pkg/helpers/resourcerequirement"
2828
helperwait "open-cluster-management.io/clusteradm/pkg/helpers/wait"
29-
clustermanagerchart "open-cluster-management.io/ocm/deploy/cluster-manager/chart"
29+
"open-cluster-management.io/clusteradm/pkg/version"
3030
"open-cluster-management.io/ocm/pkg/operator/helpers/chart"
3131
)
3232

@@ -57,14 +57,20 @@ func (o *Options) complete(cmd *cobra.Command, args []string) (err error) {
5757
}
5858
})
5959

60+
bundleVersion, err := version.GetVersionBundle(o.bundleVersion)
61+
if err != nil {
62+
return err
63+
}
64+
6065
if !o.singleton {
61-
o.clusterManagerChartConfig.Images = clustermanagerchart.ImagesConfig{
66+
o.clusterManagerChartConfig.Images = chart.ImagesConfig{
6267
Registry: o.registry,
63-
ImageCredentials: clustermanagerchart.ImageCredentials{
68+
ImageCredentials: chart.ImageCredentials{
6469
CreateImageCredentials: true,
6570
},
71+
Tag: bundleVersion.OCM,
6672
}
67-
o.clusterManagerChartConfig.ClusterManager = clustermanagerchart.ClusterManagerConfig{
73+
o.clusterManagerChartConfig.ClusterManager = chart.ClusterManagerConfig{
6874
RegistrationConfiguration: operatorv1.RegistrationHubConfiguration{
6975
FeatureGates: genericclioptionsclusteradm.ConvertToFeatureGateAPI(
7076
genericclioptionsclusteradm.HubMutableFeatureGate, ocmfeature.DefaultHubRegistrationFeatureGates),
@@ -81,11 +87,11 @@ func (o *Options) complete(cmd *cobra.Command, args []string) (err error) {
8187
o.clusterManagerChartConfig.CreateBootstrapToken = o.useBootstrapToken
8288

8389
if o.imagePullCredFile != "" {
84-
_, err := os.ReadFile(o.imagePullCredFile)
90+
content, err := os.ReadFile(o.imagePullCredFile)
8591
if err != nil {
8692
return fmt.Errorf("failed read the image pull credential file %v: %v", o.imagePullCredFile, err)
8793
}
88-
// TODO read username/password and set to helm chart.
94+
o.clusterManagerChartConfig.Images.ImageCredentials.DockerConfigJson = string(content)
8995
}
9096

9197
resourceRequirement, err := resourcerequirement.NewResourceRequirement(
@@ -98,8 +104,6 @@ func (o *Options) complete(cmd *cobra.Command, args []string) (err error) {
98104
o.Helm.WithNamespace(o.SingletonName)
99105
}
100106

101-
o.clusterManagerChartConfig.Images.Tag = o.bundleVersion
102-
103107
return nil
104108
}
105109

pkg/cmd/init/options.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,14 @@ import (
55
"k8s.io/cli-runtime/pkg/genericclioptions"
66
genericclioptionsclusteradm "open-cluster-management.io/clusteradm/pkg/genericclioptions"
77
"open-cluster-management.io/clusteradm/pkg/helpers/helm"
8-
clustermanagerchart "open-cluster-management.io/ocm/deploy/cluster-manager/chart"
98
"open-cluster-management.io/ocm/pkg/operator/helpers/chart"
109
)
1110

1211
// Options is holding all the command-line options
1312
type Options struct {
1413
// ClusteradmFlags: The generic options from the clusteradm cli-runtime.
1514
ClusteradmFlags *genericclioptionsclusteradm.ClusteradmFlags
16-
clusterManagerChartConfig *clustermanagerchart.ChartConfig
15+
clusterManagerChartConfig *chart.ClusterManagerChartConfig
1716
// The file to output the resources will be sent to the file.
1817
outputFile string
1918
// If true the bootstrap token will be used instead of the service account token

pkg/cmd/join/exec.go

Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import (
55
"bytes"
66
"context"
77
"crypto/x509"
8-
"encoding/base64"
98
"encoding/pem"
109
"fmt"
1110
"os"
@@ -42,7 +41,7 @@ import (
4241
"open-cluster-management.io/clusteradm/pkg/helpers/reader"
4342
"open-cluster-management.io/clusteradm/pkg/helpers/resourcerequirement"
4443
"open-cluster-management.io/clusteradm/pkg/helpers/wait"
45-
klusterletchart "open-cluster-management.io/ocm/deploy/klusterlet/chart"
44+
"open-cluster-management.io/clusteradm/pkg/version"
4645
"open-cluster-management.io/ocm/pkg/operator/helpers/chart"
4746
sdkhelpers "open-cluster-management.io/sdk-go/pkg/helpers"
4847
)
@@ -89,24 +88,30 @@ func (o *Options) complete(cmd *cobra.Command, args []string) (err error) {
8988

9089
agentNamespace := AgentNamespacePrefix + "agent"
9190

92-
o.klusterletChartConfig.Klusterlet = klusterletchart.KlusterletConfig{
91+
o.klusterletChartConfig.Klusterlet = chart.KlusterletConfig{
9392
ClusterName: o.clusterName,
9493
}
9594

96-
o.klusterletChartConfig.Images = klusterletchart.ImagesConfig{
95+
bundleVersion, err := version.GetVersionBundle(o.bundleVersion)
96+
if err != nil {
97+
return err
98+
}
99+
100+
o.klusterletChartConfig.Images = chart.ImagesConfig{
97101
Registry: o.registry,
98-
ImageCredentials: klusterletchart.ImageCredentials{
102+
Tag: bundleVersion.OCM,
103+
ImageCredentials: chart.ImageCredentials{
99104
CreateImageCredentials: true,
100105
},
101106
}
102107
o.klusterletChartConfig.EnableSyncLabels = o.enableSyncLabels
103108

104109
if o.imagePullCredFile != "" {
105-
_, err := os.ReadFile(o.imagePullCredFile)
110+
content, err := os.ReadFile(o.imagePullCredFile)
106111
if err != nil {
107112
return fmt.Errorf("failed read the image pull credential file %v: %v", o.imagePullCredFile, err)
108113
}
109-
// TODO add user/password
114+
o.klusterletChartConfig.Images.ImageCredentials.DockerConfigJson = string(content)
110115
}
111116

112117
// deploy klusterlet
@@ -136,9 +141,7 @@ func (o *Options) complete(cmd *cobra.Command, args []string) (err error) {
136141
if err != nil {
137142
return err
138143
}
139-
if resourceRequirement.ResourceRequirements != nil {
140-
o.klusterletChartConfig.Resources = *resourceRequirement.ResourceRequirements
141-
}
144+
o.klusterletChartConfig.Klusterlet.ResourceRequirement = *resourceRequirement
142145

143146
o.klusterletChartConfig.Klusterlet.RegistrationConfiguration = operatorv1.RegistrationConfiguration{
144147
FeatureGates: genericclioptionsclusteradm.ConvertToFeatureGateAPI(
@@ -159,8 +162,6 @@ func (o *Options) complete(cmd *cobra.Command, args []string) (err error) {
159162
o.klusterletChartConfig.Klusterlet.Mode = operatorv1.InstallMode(o.mode)
160163
}
161164

162-
o.klusterletChartConfig.Images.Tag = o.bundleVersion
163-
164165
// if --ca-file is set, read ca data
165166
if o.caFile != "" {
166167
cabytes, err := os.ReadFile(o.caFile)
@@ -285,7 +286,7 @@ func (o *Options) validate() error {
285286
return err
286287
}
287288
}
288-
o.klusterletChartConfig.ExternalManagedKubeConfig = base64.StdEncoding.EncodeToString(managedConfig)
289+
o.klusterletChartConfig.ExternalManagedKubeConfig = string(managedConfig)
289290
}
290291

291292
if err := o.capiOptions.Validate(); err != nil {
@@ -353,20 +354,20 @@ func (o *Options) applyKlusterlet(r *reader.ResourceReader, operatorClient opera
353354
return err
354355
}
355356

357+
o.klusterletChartConfig.CreateNamespace = o.createNameSpace
358+
356359
// If Deployment/klusterlet is not deployed, deploy it
357-
if !available {
358-
o.klusterletChartConfig.CreateNamespace = o.createNameSpace
360+
if available {
361+
o.klusterletChartConfig.NoOperator = true
362+
}
359363

360-
raw, err := chart.RenderKlusterletChart(
361-
o.klusterletChartConfig,
362-
"open-cluster-management")
363-
if err != nil {
364-
return err
365-
}
364+
raw, err := chart.RenderKlusterletChart(o.klusterletChartConfig, OperatorNamesapce)
365+
if err != nil {
366+
return err
367+
}
366368

367-
if err := r.ApplyRaw(raw); err != nil {
368-
return err
369-
}
369+
if err := r.ApplyRaw(raw); err != nil {
370+
return err
370371
}
371372

372373
if !o.ClusteradmFlags.DryRun {

pkg/cmd/join/options.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import (
66
clientcmdapiv1 "k8s.io/client-go/tools/clientcmd/api/v1"
77
"open-cluster-management.io/clusteradm/pkg/clusterprovider/capi"
88
genericclioptionsclusteradm "open-cluster-management.io/clusteradm/pkg/genericclioptions"
9-
klusterletchart "open-cluster-management.io/ocm/deploy/klusterlet/chart"
109
"open-cluster-management.io/ocm/pkg/operator/helpers/chart"
1110
)
1211

@@ -77,7 +76,7 @@ type Options struct {
7776
// If create ns or use existing ns
7877
createNameSpace bool
7978

80-
klusterletChartConfig *klusterletchart.ChartConfig
79+
klusterletChartConfig *chart.KlusterletChartConfig
8180

8281
capiOptions *capi.CAPIOptions
8382

pkg/cmd/join/scenario/join/namespace.yaml

Lines changed: 0 additions & 7 deletions
This file was deleted.

pkg/cmd/join/scenario/resources.go

Lines changed: 0 additions & 19 deletions
This file was deleted.

pkg/cmd/upgrade/clustermanager/exec.go

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
1010
operatorclient "open-cluster-management.io/api/client/operator/clientset/versioned"
1111
"open-cluster-management.io/clusteradm/pkg/helpers/reader"
12-
clustermanagerchart "open-cluster-management.io/ocm/deploy/cluster-manager/chart"
12+
"open-cluster-management.io/clusteradm/pkg/version"
1313
"open-cluster-management.io/ocm/pkg/operator/helpers/chart"
1414

1515
"github.com/spf13/cobra"
@@ -39,12 +39,21 @@ func (o *Options) complete(cmd *cobra.Command, args []string) (err error) {
3939
return err
4040
}
4141

42-
o.clusterManagerChartConfig.Images = clustermanagerchart.ImagesConfig{
42+
bundleVersion, err := version.GetVersionBundle(o.bundleVersion)
43+
if err != nil {
44+
return err
45+
}
46+
47+
o.clusterManagerChartConfig.Images = chart.ImagesConfig{
4348
Registry: o.registry,
44-
Tag: o.bundleVersion,
49+
Tag: bundleVersion.OCM,
4550
}
4651

47-
o.clusterManagerChartConfig.ClusterManager = clustermanagerchart.ClusterManagerConfig{}
52+
if cm.Spec.ResourceRequirement != nil {
53+
o.clusterManagerChartConfig.ClusterManager = chart.ClusterManagerConfig{
54+
ResourceRequirement: *cm.Spec.ResourceRequirement,
55+
}
56+
}
4857

4958
// reconstruct values from the cluster manager CR.
5059
if cm.Spec.RegistrationConfiguration != nil {

pkg/cmd/upgrade/clustermanager/options.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ package clustermanager
44
import (
55
"k8s.io/cli-runtime/pkg/genericclioptions"
66
genericclioptionsclusteradm "open-cluster-management.io/clusteradm/pkg/genericclioptions"
7-
clustermanagerchart "open-cluster-management.io/ocm/deploy/cluster-manager/chart"
87
"open-cluster-management.io/ocm/pkg/operator/helpers/chart"
98
)
109

@@ -13,7 +12,7 @@ type Options struct {
1312
//ClusteradmFlags: The generic options from the clusteradm cli-runtime.
1413
ClusteradmFlags *genericclioptionsclusteradm.ClusteradmFlags
1514

16-
clusterManagerChartConfig *clustermanagerchart.ChartConfig
15+
clusterManagerChartConfig *chart.ClusterManagerChartConfig
1716
//The file to output the resources will be sent to the file.
1817
registry string
1918
//version of predefined compatible image versions

0 commit comments

Comments
 (0)