Skip to content

Commit

Permalink
install regiatration agent using multicluster controlplane
Browse files Browse the repository at this point in the history
Signed-off-by: yuchenyao <yaoyuchen0626@163.com>
  • Loading branch information
ycyaoxdu committed May 18, 2023
1 parent 1eac672 commit e2e6c62
Show file tree
Hide file tree
Showing 13 changed files with 496 additions and 151 deletions.
45 changes: 33 additions & 12 deletions pkg/cmd/join/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"fmt"

"github.com/spf13/cobra"
"github.com/spf13/pflag"
"k8s.io/cli-runtime/pkg/genericclioptions"
genericclioptionsclusteradm "open-cluster-management.io/clusteradm/pkg/genericclioptions"
"open-cluster-management.io/clusteradm/pkg/helpers"
Expand Down Expand Up @@ -48,19 +49,39 @@ func NewCmd(clusteradmFlags *genericclioptionsclusteradm.ClusteradmFlags, stream
}

genericclioptionsclusteradm.SpokeMutableFeatureGate.AddFlag(cmd.Flags())
cmd.Flags().StringVar(&o.token, "hub-token", "", "The token to access the hub")
cmd.Flags().StringVar(&o.hubAPIServer, "hub-apiserver", "", "The api server url to the hub")
cmd.Flags().StringVar(&o.caFile, "ca-file", "", "the file path to hub ca, optional")
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.bundleVersion, "bundle-version", "default",
"The version of predefined compatible image versions (e.g. v0.6.0). Defaults to the latest released version. You can also set \"latest\" to install the latest development version.")
cmd.Flags().BoolVar(&o.forceHubInClusterEndpointLookup, "force-internal-endpoint-lookup", false,

//joinSet contains the base flags for join command
joinSet := pflag.NewFlagSet("join", pflag.ExitOnError)
joinSet.StringVar(&o.token, "hub-token", "", "The token to access the hub")
joinSet.StringVar(&o.hubAPIServer, "hub-apiserver", "", "The api server url to the hub")
joinSet.StringVar(&o.caFile, "ca-file", "", "the file path to hub ca, optional")
joinSet.StringVar(&o.clusterName, "cluster-name", "", "The name of the joining cluster")
joinSet.BoolVar(&o.forceHubInClusterEndpointLookup, "force-internal-endpoint-lookup", false,
"If true, the installed klusterlet agent will be starting the cluster registration process by "+
"looking for the internal endpoint from the public cluster-info in the hub cluster instead of from --hub-apiserver.")
cmd.Flags().BoolVar(&o.wait, "wait", false, "If true, running the cluster registration in foreground.")
cmd.Flags().StringVarP(&o.mode, "mode", "m", "default", "mode to deploy klusterlet, can be default or hosted")
cmd.Flags().StringVar(&o.managedKubeconfigFile, "managed-cluster-kubeconfig", "", "To specify the directory to external managed cluster kubeconfig in hosted mode")
joinSet.BoolVar(&o.wait, "wait", false, "If true, running the cluster registration in foreground.")
joinSet.StringVar(&o.outputFile, "output-file", "", "The generated resources will be copied in the specified file")
joinSet.StringVarP(&o.mode, "mode", "m", "default", "mode to install OCM agent, can be default, hosted or controlplane-agent")

//klusterletSet contains the flags for deploy klusterlet
klusterletSet := pflag.NewFlagSet("default-klusterlet", pflag.ExitOnError)
klusterletSet.StringVar(&o.registry, "image-registry", "quay.io/open-cluster-management", "The name of the image registry serving OCM images.")
klusterletSet.StringVar(&o.bundleVersion, "bundle-version", "default",
"The version of predefined compatible image versions (e.g. v0.6.0). Defaults to the latest released version. You can also set \"latest\" to install the latest development version.")
klusterletSet.StringVar(&o.managedKubeconfigFile, "managed-cluster-kubeconfig", "", "To specify the directory to external managed cluster kubeconfig in hosted mode")
klusterletSet.SetAnnotation("image-registry", "mode-orinted", []string{"default", "hosted"})
klusterletSet.SetAnnotation("bundle-version", "mode-orinted", []string{"default", "hosted"})
klusterletSet.SetAnnotation("managed-cluster-kubeconfig", "mode-orinted", []string{"hosted"})

//controlplaneAgentSet contains the flags for deploy controlplane agent
controlplaneAgentSet := pflag.NewFlagSet("controlplane-agent", pflag.ExitOnError)
controlplaneAgentSet.StringVar(&o.controlplaneAgentImage, "controlplane-agent-image", "quay.io/open-cluster-management/multicluster-controlplane:latest", "The name of the controlplane agent image")
controlplaneAgentSet.SetAnnotation("controlplane-agent-image", "mode-orinted", []string{"controlplane-agent"})

// flagSet for join command
cmd.Flags().AddFlagSet(joinSet)
cmd.Flags().AddFlagSet(klusterletSet)
cmd.Flags().AddFlagSet(controlplaneAgentSet)

return cmd
}
Loading

0 comments on commit e2e6c62

Please sign in to comment.