From f78ed2458bcef12c61eb22088112c0ed90878de5 Mon Sep 17 00:00:00 2001 From: Ilan Pinto Date: Wed, 8 Dec 2021 16:43:10 +0200 Subject: [PATCH 1/3] This is a combination of 2 commits. This is the 1st commit message: support image rendring for join command added image rending to the join command Signed-off-by: Ilan Pinto --- .gitignore | 1 + .vscode/launch.json | 20 +++++++++++++++++++ pkg/cmd/join/cmd.go | 3 +++ pkg/cmd/join/exec.go | 11 ++++++++++ pkg/cmd/join/options.go | 14 +++++++++++++ .../join/scenario/join/klusterlets.cr.yaml | 4 ++-- pkg/cmd/join/scenario/join/operator.yaml | 2 +- 7 files changed, 52 insertions(+), 3 deletions(-) create mode 100644 .vscode/launch.json diff --git a/.gitignore b/.gitignore index 2642fc61b..b13ce48e9 100644 --- a/.gitignore +++ b/.gitignore @@ -23,3 +23,4 @@ test/out #vendor .DS_Store +launch.json \ No newline at end of file diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 000000000..5e0c77565 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,20 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "name": "GO", + "type": "go", + "request": "launch", + "mode": "auto", + "program": "${fileDirname}", + "args": ["join","--hub-token", "mickzn.kpeetnrpqt9soifw", "--hub-apiserver", "https://127.0.0.1:58916", "--cluster-name" ,"--image-repo", "docker.io","--dry-run" ] , + "env":{ + "KUBECONFIG":"/tmp/cm.yaml" + }, + + } + ] +} \ No newline at end of file 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 d4060a465..fcc21e157 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 f50ca60ca..fc16c4034 100644 --- a/pkg/cmd/join/options.go +++ b/pkg/cmd/join/options.go @@ -21,6 +21,11 @@ type Options struct { //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 @@ -29,6 +34,7 @@ type Values struct { ClusterName string //Hub: Hub information Hub Hub + ImageRegistry ImageRegistry } //Hub: The hub values for the template @@ -40,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..e0877f523 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 + workImagePullSpec: {{ .ImageRegistry.Registry }}/work 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" From f7568102025c311dd75db374d839a434c222e0f3 Mon Sep 17 00:00:00 2001 From: Ilan Pinto Date: Thu, 9 Dec 2021 14:50:16 +0200 Subject: [PATCH 2/3] removed git launch Signed-off-by: Ilan Pinto --- .gitignore | 1 - .vscode/launch.json | 20 -------------------- 2 files changed, 21 deletions(-) delete mode 100644 .vscode/launch.json diff --git a/.gitignore b/.gitignore index b13ce48e9..2642fc61b 100644 --- a/.gitignore +++ b/.gitignore @@ -23,4 +23,3 @@ test/out #vendor .DS_Store -launch.json \ No newline at end of file diff --git a/.vscode/launch.json b/.vscode/launch.json deleted file mode 100644 index 5e0c77565..000000000 --- a/.vscode/launch.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - // Use IntelliSense to learn about possible attributes. - // Hover to view descriptions of existing attributes. - // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 - "version": "0.2.0", - "configurations": [ - { - "name": "GO", - "type": "go", - "request": "launch", - "mode": "auto", - "program": "${fileDirname}", - "args": ["join","--hub-token", "mickzn.kpeetnrpqt9soifw", "--hub-apiserver", "https://127.0.0.1:58916", "--cluster-name" ,"--image-repo", "docker.io","--dry-run" ] , - "env":{ - "KUBECONFIG":"/tmp/cm.yaml" - }, - - } - ] -} \ No newline at end of file From 1fff33a74c83dd03a5bd95f6d1152ebad47b0f95 Mon Sep 17 00:00:00 2001 From: Ilan Pinto Date: Thu, 9 Dec 2021 20:41:41 +0200 Subject: [PATCH 3/3] added version param to klusterlet Signed-off-by: Ilan Pinto --- pkg/cmd/join/scenario/join/klusterlets.cr.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/cmd/join/scenario/join/klusterlets.cr.yaml b/pkg/cmd/join/scenario/join/klusterlets.cr.yaml index e0877f523..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: {{ .ImageRegistry.Registry }}/registration - workImagePullSpec: {{ .ImageRegistry.Registry }}/work + registrationImagePullSpec: {{ .ImageRegistry.Registry }}/registration:{{ .ImageRegistry.Version }} + workImagePullSpec: {{ .ImageRegistry.Registry }}/work:{{ .ImageRegistry.Version }} clusterName: {{ .ClusterName }} namespace: open-cluster-management-agent externalServerURLs: