Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions pkg/cmd/join/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
11 changes: 11 additions & 0 deletions pkg/cmd/join/exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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
}
Expand Down
15 changes: 15 additions & 0 deletions pkg/cmd/join/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -28,6 +34,7 @@ type Values struct {
ClusterName string
//Hub: Hub information
Hub Hub
ImageRegistry ImageRegistry
}

//Hub: The hub values for the template
Expand All @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions pkg/cmd/join/scenario/join/klusterlets.cr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion pkg/cmd/join/scenario/join/operator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down