support run work agent outside of managed cluster#104
support run work agent outside of managed cluster#104openshift-merge-robot merged 2 commits intoopen-cluster-management-io:mainfrom
Conversation
| flags := cmd.Flags() | ||
| // This command only supports reading from config | ||
| flags.StringVar(&o.HubKubeconfigFile, "hub-kubeconfig", o.HubKubeconfigFile, "Location of kubeconfig file to connect to hub cluster.") | ||
| flags.StringVar(&o.SpokeKubeconfigFile, "spoke-kubeconfig", o.SpokeKubeconfigFile, "Location of kubeconfig file to connect to spoke cluster.") |
There was a problem hiding this comment.
can't we use the built-in --kubeconfig flag here?
There was a problem hiding this comment.
I think it is better not, the built-in --kubeconfig in our case represents the cluster where the work-agent pod run.
There was a problem hiding this comment.
this should be explicit callout that if this is not set, but --kubeconfig is set. kubeconfig will be used to connect to spoke.
e29befa to
9a6686d
Compare
| Burst int | ||
| HubKubeconfigFile string | ||
| SpokeKubeconfigFile string | ||
| SpokeKubeconfig *rest.Config |
There was a problem hiding this comment.
This was originally used for integration test, but now I think it can be deleted
| spokeDynamicClient, err := dynamic.NewForConfig(spokeRestConfig) | ||
| // load spoke client config and create spoke clients, | ||
| // the work agent may running not in the spoke/managed cluster. | ||
| if o.SpokeKubeconfig == nil { |
There was a problem hiding this comment.
I do not see how it can be not nil
| flags := cmd.Flags() | ||
| // This command only supports reading from config | ||
| flags.StringVar(&o.HubKubeconfigFile, "hub-kubeconfig", o.HubKubeconfigFile, "Location of kubeconfig file to connect to hub cluster.") | ||
| flags.StringVar(&o.SpokeKubeconfigFile, "spoke-kubeconfig", o.SpokeKubeconfigFile, "Location of kubeconfig file to connect to spoke cluster.") |
There was a problem hiding this comment.
this should be explicit callout that if this is not set, but --kubeconfig is set. kubeconfig will be used to connect to spoke.
| if o.SpokeKubeconfigFile != "" { | ||
| o.SpokeKubeconfig, err = clientcmd.BuildConfigFromFlags("" /* leave masterurl as empty */, o.SpokeKubeconfigFile) | ||
| if err != nil { | ||
| return fmt.Errorf("unable to load spoke kubeconfig from file %q: %w", o.SpokeKubeconfigFile, err) |
There was a problem hiding this comment.
I would make it a func
func (o *WorkloadAgentOptions) spokeKubeConfig(controllerContext) *rest.Config, error {
if o.SpokeKubeconfigFile != "" {
return clientcmd.BuildConfigFromFlags("" /* leave masterurl as empty */, o.SpokeKubeconfigFile)
}
return controllerContext.KubeConfig
}add a flag spoke-kubeconfig to specify the kubeconfig of the apoke/managed cluster Signed-off-by: zhujian <jiazhu@redhat.com>
9a6686d to
526c686
Compare
|
/retest |
Signed-off-by: zhujian <jiazhu@redhat.com>
526c686 to
68c815c
Compare
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: qiujian16, zhujian7 The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Signed-off-by: zhujian jiazhu@redhat.com
related issue: open-cluster-management-io/registration-operator#158
todo: