-
Notifications
You must be signed in to change notification settings - Fork 97
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
feat: add command-line tool admiralctl and implement the migrate subcommand #202
base: main
Are you sure you want to change the base?
Conversation
6c9984d
to
c6d1551
Compare
@mrlihanbo PTAL, incidentally, maybe I should revamp the build-related scripts to build |
c6d1551
to
d30a06f
Compare
d30a06f
to
4236ecd
Compare
47fad5c
to
f3a0dea
Compare
pkg/admiralctl/admiralctl.go
Outdated
ioStreams := genericclioptions.IOStreams{In: os.Stdin, Out: os.Stdout, ErrOut: os.Stderr} | ||
groups := templates.CommandGroups{ | ||
{ | ||
Message: "Advanced Commands:", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Resource Management Commands? /cc @limhawjia @gary-lgy
pkg/admiralctl/admiralctl.go
Outdated
{ | ||
Message: "Advanced Commands:", | ||
Commands: []*cobra.Command{ | ||
migrate.NewCmdMigrate(f, parentCommand), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Federalize
may be better? /cc @gary-lgy @limhawjia
pkg/admiralctl/migrate/migrate.go
Outdated
// populated by the kubernetes. | ||
// The kubernetes will set this fields in case of graceful deletion. This field is read-only and can't propagate to | ||
// member clusters. | ||
unstructured.RemoveNestedField(workload.Object, "metadata", "deletionTimestamp") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is strange to federalize the resources in deleting status. Should we forbid the operation in preflight?/cc @gary-lgy @limhawjia
pkg/admiralctl/migrate/migrate.go
Outdated
return fmt.Errorf("failed to create resource %q(%s/%s) in control plane: %w", gvr, o.Namespace, o.name, err) | ||
} | ||
|
||
if o.AutoCreatePolicy { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we should support specifying exist propagation policy when federalize member cluster resources? /cc @gary-lgy @limhawjia
pkg/admiralctl/migrate/migrate.go
Outdated
|
||
unstructured.RemoveNestedField(workload.Object, "status") | ||
|
||
if workload.GetKind() == common.ServiceKind { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pod maybe be deleted if it specifies not exist node name by k8s, should we remove spec.NodeName when Kind is Pod? cc @mrlihanbo
…ommand Signed-off-by: Liang Deng <[email protected]> Signed-off-by: Liang Deng <[email protected]> Signed-off-by: Liang Deng <[email protected]> Signed-off-by: Liang Deng <[email protected]> Signed-off-by: Liang Deng <[email protected]>
d7c1327
to
0baed93
Compare
Summary
KubeAdmiral is a multi-cluster management system for Kubernetes, developed from Kubernetes Federation v2. However, it currently lacks a command-line tool to simplify user operations. Therefore, this proposal aims to set up the code framework for the KubeAdmiral command-line tool:
admiralctl
, and to implement the subcommand to import resources from existing clusters into the federation.Motivation
By developing
admiralctl
, we can greatly simplify user operations and enhance the overall usability of KubeAdmiral.Goals
We need to achieve the following goals:
Non-Goals/Future Work
admiralctl join
,admiralctl unjoin
, and so on.Proposal
Command line tool framework selection
For the command line tool framework selection, after research, the cobra framework was finally selected for the following reasons:
cobra
provides a clear structure for managing commands, subcommands, flags, and arguments, making building complex CLI tools intuitive and simple.cobra
automatically generates-h
or--help
flags for your application, displaying help information about commands.pflag
library provides more powerful flag parsing thanflag
in the Go standard library.cobra
can automatically generate documentation for your CLI in Markdown, man, or other formats, which is useful for keeping documentation and code synchronized.kubectl
,kubeadm
, and many other well-known projects usecobra
, which validates its stability and reliability in production environments.Admiralctl migrate subcommand implementation
AutoCreatePolicy
is true, create aPropagationPolicy
orClusterPropagationPolicy
and bind the policy to the corresponding workload on the control plane (by labeling).Command design