diff --git a/pkg/cmd/join/cmd.go b/pkg/cmd/join/cmd.go index 56141e1df..0b3eecdbb 100644 --- a/pkg/cmd/join/cmd.go +++ b/pkg/cmd/join/cmd.go @@ -47,5 +47,8 @@ func NewCmd(clusteradmFlags *genericclioptionsclusteradm.ClusteradmFlags, stream cmd.Flags().StringVar(&o.hubAPIServer, "hub-apiserver", "", "The api server url to the hub") cmd.Flags().StringVar(&o.clusterName, "cluster-name", "", "The name of the joining cluster") cmd.Flags().StringVar(&o.outputFile, "output-file", "", "The generated resources will be copied in the specified file") + cmd.Flags().StringVar(&o.registry, "image-registry", "quay.io/open-cluster-management", "The name of the image registry serving OCM images.") + cmd.Flags().StringVar(&o.version, "version", "latest", + "The installing version of OCM components.") return cmd } diff --git a/pkg/cmd/join/exec.go b/pkg/cmd/join/exec.go index b5cfd38c1..991f1dcc3 100644 --- a/pkg/cmd/join/exec.go +++ b/pkg/cmd/join/exec.go @@ -37,9 +37,14 @@ func (o *Options) complete(cmd *cobra.Command, args []string) (err error) { Hub: Hub{ APIServer: o.hubAPIServer, }, + ImageRegistry: ImageRegistry{ + Registry: o.registry, + Version: o.version, + }, } klog.V(3).InfoS("values:", "clusterName", o.values.ClusterName, "hubAPIServer", o.values.Hub.APIServer) return nil + } func (o *Options) validate() error { @@ -52,6 +57,12 @@ func (o *Options) validate() error { if o.values.ClusterName == "" { return fmt.Errorf("name is missing") } + if len(o.registry) == 0 { + return fmt.Errorf("registry should not be empty") + } + if len(o.version) == 0 { + return fmt.Errorf("version should not be empty") + } return nil } diff --git a/pkg/cmd/join/options.go b/pkg/cmd/join/options.go index f9a7cdd99..fc16c4034 100644 --- a/pkg/cmd/join/options.go +++ b/pkg/cmd/join/options.go @@ -20,6 +20,12 @@ type Options struct { values Values //The file to output the resources will be sent to the file. outputFile string + + //Installing release version of OCM + version string + //Pulling image registry of OCM + registry string + } //Values: The values used in the template @@ -28,6 +34,7 @@ type Values struct { ClusterName string //Hub: Hub information Hub Hub + ImageRegistry ImageRegistry } //Hub: The hub values for the template @@ -39,6 +46,14 @@ type Hub struct { KubeConfig string } +type ImageRegistry struct { + // image registry name + Registry string + // image version + Version string +} + + func newOptions(clusteradmFlags *genericclioptionsclusteradm.ClusteradmFlags, streams genericclioptions.IOStreams) *Options { return &Options{ ClusteradmFlags: clusteradmFlags, diff --git a/pkg/cmd/join/scenario/join/klusterlets.cr.yaml b/pkg/cmd/join/scenario/join/klusterlets.cr.yaml index 0b6333e69..9904c1a36 100644 --- a/pkg/cmd/join/scenario/join/klusterlets.cr.yaml +++ b/pkg/cmd/join/scenario/join/klusterlets.cr.yaml @@ -4,8 +4,8 @@ kind: Klusterlet metadata: name: klusterlet spec: - registrationImagePullSpec: quay.io/open-cluster-management/registration - workImagePullSpec: quay.io/open-cluster-management/work + registrationImagePullSpec: {{ .ImageRegistry.Registry }}/registration:{{ .ImageRegistry.Version }} + workImagePullSpec: {{ .ImageRegistry.Registry }}/work:{{ .ImageRegistry.Version }} clusterName: {{ .ClusterName }} namespace: open-cluster-management-agent externalServerURLs: diff --git a/pkg/cmd/join/scenario/join/operator.yaml b/pkg/cmd/join/scenario/join/operator.yaml index e4a6d9515..5891e0bf7 100644 --- a/pkg/cmd/join/scenario/join/operator.yaml +++ b/pkg/cmd/join/scenario/join/operator.yaml @@ -42,7 +42,7 @@ spec: serviceAccountName: klusterlet containers: - name: klusterlet - image: quay.io/open-cluster-management/registration-operator:latest + image: {{ .ImageRegistry.Registry }}/registration-operator:{{ .ImageRegistry.Version }} args: - "/registration-operator" - "klusterlet"