Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Connect cluster cmd #3239

Merged
merged 16 commits into from
Sep 4, 2023
Merged

Connect cluster cmd #3239

merged 16 commits into from
Sep 4, 2023

Conversation

ranatrk
Copy link
Contributor

@ranatrk ranatrk commented Aug 22, 2023

Closes #3086

What changed?
Add connect cluster cmd to gitops

Why was this change made?
to use connector pkg to connect a remote cluster to a cluster

How was this change implemented?

How did you validate the change?

  • Explain how a reviewer can verify the change themselves
    Once building the gitops cmd with the updates:
./gitops connect cluster --namespace default --service-account test-service-account --cluster-role test-service-account-cluster-role --cluster-role-binding test-service-account-cluster-role-binding  --connect-context <CONTEXT> kind-wge-dev

Release notes

Documentation Changes

Other follow ups

@ranatrk ranatrk requested a review from a team August 22, 2023 11:50
@ranatrk ranatrk added the enhancement New feature or request label Aug 22, 2023
@ranatrk ranatrk force-pushed the connect-cluster-cmd branch 3 times, most recently from 2f64295 to b57cde9 Compare August 23, 2023 15:31
@ranatrk ranatrk requested a review from bigkevmcd August 23, 2023 16:12
@ranatrk ranatrk force-pushed the connect-cluster-cmd branch from b57cde9 to 3c5b17d Compare August 24, 2023 09:14
Copy link
Contributor

@bigkevmcd bigkevmcd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to figure out the kubeconfig situation.

We can land it, but we should address before it goes public.

cmd/gitops/app/connect/clusters/cmd.go Outdated Show resolved Hide resolved
}

logger := stdr.New(nil)
ctx := log.IntoContext(context.Background(), logger)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could probably call cmd.Context() rather than creating a new Background context?

cmd/gitops/app/connect/cmd.go Show resolved Hide resolved
cmd/gitops/app/connect/cmd.go Outdated Show resolved Hide resolved
cmd/gitops/app/connect/clusters/cmd.go Outdated Show resolved Hide resolved
@ranatrk ranatrk force-pushed the connect-cluster-cmd branch 4 times, most recently from 1f14567 to 82c8f99 Compare August 31, 2023 10:08
cmd.Flags().StringVar(&connectOptionsCmdFlags.ServiceAccountName, "service-account", "weave-gitops-enterprise", "Service account name to be created/used")
cmd.Flags().StringVar(&connectOptionsCmdFlags.ClusterRoleName, "cluster-role", "weave-gitops-enterprise", "Cluster role name to be created/used")
cmd.Flags().StringVar(&connectOptionsCmdFlags.ClusterRoleBindingName, "cluster-role-binding", "weave-gitops-enterprise", "Cluster role binding name to be created/used")
cmd.Flags().StringVar(&connectOptionsCmdFlags.Namespace, "namespace", "default", "namespace of remote cluster")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could change this to a StringVarP https://pkg.go.dev/github.com/spf13/pflag#StringToStringVarP and add a "short name" of n which would allow it to be used as -n for the namespace which has the same semantic as kubectl.

@bigkevmcd
Copy link
Contributor

I also think we need to remove the two different ways of loading the config, but I've covered that elsewhere 😄

@ranatrk ranatrk force-pushed the connect-cluster-cmd branch 4 times, most recently from c7d7797 to ba3ae07 Compare August 31, 2023 14:34
Copy link
Contributor

@bigkevmcd bigkevmcd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some minor textual tidyups, looks good, thank you!

cmd.Flags().StringVar(&connectOptionsCmdFlags.ServiceAccountName, "service-account", "weave-gitops-enterprise", "Service account name to be created/used")
cmd.Flags().StringVar(&connectOptionsCmdFlags.ClusterRoleName, "cluster-role", "weave-gitops-enterprise", "Cluster role name to be created/used")
cmd.Flags().StringVar(&connectOptionsCmdFlags.ClusterRoleBindingName, "cluster-role-binding", "weave-gitops-enterprise", "Cluster role binding name to be created/used")
cmd.Flags().StringVarP(&connectOptionsCmdFlags.Namespace, "namespace", "n", "default", "namespace of remote cluster")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's make this Namespace of remote cluster in keeping with the other descriptions?

pkg/cluster/connector/config.go Outdated Show resolved Hide resolved
pkg/cluster/connector/config.go Outdated Show resolved Hide resolved
@ranatrk ranatrk force-pushed the connect-cluster-cmd branch from 499d05e to b927471 Compare September 4, 2023 10:19
@ranatrk ranatrk merged commit 703b438 into main Sep 4, 2023
@ranatrk ranatrk deleted the connect-cluster-cmd branch September 4, 2023 10:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add gitops connect cluster command
2 participants