-
Notifications
You must be signed in to change notification settings - Fork 17
Implement multi-cluster support for kubectl commands #45
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
base: main
Are you sure you want to change the base?
Implement multi-cluster support for kubectl commands #45
Conversation
- Added command to retrieve resources from all managed clusters with unified output.
- Introduced The Kubernetes package manager
Common actions for Helm:
- helm search: search for charts
- helm pull: download a chart to your local directory to view
- helm install: upload the chart to Kubernetes
- helm list: list releases of charts
Environment variables:
| Name | Description |
|------------------------------------|------------------------------------------------------------------------------------------------------------|
| $HELM_CACHE_HOME | set an alternative location for storing cached files. |
| $HELM_CONFIG_HOME | set an alternative location for storing Helm configuration. |
| $HELM_DATA_HOME | set an alternative location for storing Helm data. |
| $HELM_DEBUG | indicate whether or not Helm is running in Debug mode |
| $HELM_DRIVER | set the backend storage driver. Values are: configmap, secret, memory, sql. |
| $HELM_DRIVER_SQL_CONNECTION_STRING | set the connection string the SQL storage driver should use. |
| $HELM_MAX_HISTORY | set the maximum number of helm release history. |
| $HELM_NAMESPACE | set the namespace used for the helm operations. |
| $HELM_NO_PLUGINS | disable plugins. Set HELM_NO_PLUGINS=1 to disable plugins. |
| $HELM_PLUGINS | set the path to the plugins directory |
| $HELM_REGISTRY_CONFIG | set the path to the registry config file. |
| $HELM_REPOSITORY_CACHE | set the path to the repository cache directory |
| $HELM_REPOSITORY_CONFIG | set the path to the repositories file. |
| $KUBECONFIG | set an alternative Kubernetes configuration file (default "~/.kube/config") |
| $HELM_KUBEAPISERVER | set the Kubernetes API Server Endpoint for authentication |
| $HELM_KUBECAFILE | set the Kubernetes certificate authority file. |
| $HELM_KUBEASGROUPS | set the Groups to use for impersonation using a comma-separated list. |
| $HELM_KUBEASUSER | set the Username to impersonate for the operation. |
| $HELM_KUBECONTEXT | set the name of the kubeconfig context. |
| $HELM_KUBETOKEN | set the Bearer KubeToken used for authentication. |
| $HELM_KUBEINSECURE_SKIP_TLS_VERIFY | indicate if the Kubernetes API server's certificate validation should be skipped (insecure) |
| $HELM_KUBETLS_SERVER_NAME | set the server name used to validate the Kubernetes API server certificate |
| $HELM_BURST_LIMIT | set the default burst limit in the case the server contains many CRDs (default 100, -1 to disable) |
| $HELM_QPS | set the Queries Per Second in cases where a high number of calls exceed the option for higher burst values |
Helm stores cache, configuration, and data based on the following configuration order:
- If a HELM_*_HOME environment variable is set, it will be used
- Otherwise, on systems supporting the XDG base directory specification, the XDG variables will be used
- When no other location is set a default location will be used based on the operating system
By default, the default directories depend on the Operating System. The defaults are listed below:
| Operating System | Cache Path | Configuration Path | Data Path |
|------------------|---------------------------|--------------------------------|-------------------------|
| Linux | $HOME/.cache/helm | $HOME/.config/helm | $HOME/.local/share/helm |
| macOS | $HOME/Library/Caches/helm | $HOME/Library/Preferences/helm | $HOME/Library/helm |
| Windows | %TEMP%\helm | %APPDATA%\helm | %APPDATA%\helm |
Usage:
helm [command]
Available Commands:
completion generate autocompletion scripts for the specified shell
create create a new chart with the given name
dependency manage a chart's dependencies
env helm client environment information
get download extended information of a named release
help Help about any command
history fetch release history
install install a chart
lint examine a chart for possible issues
list list releases
package package a chart directory into a chart archive
plugin install, list, or uninstall Helm plugins
pull download a chart from a repository and (optionally) unpack it in local directory
push push a chart to remote
registry login to or logout from a registry
repo add, list, remove, update, and index chart repositories
rollback roll back a release to a previous revision
search search for a keyword in charts
show show information of a chart
status display the status of the named release
template locally render templates
test run tests for a release
uninstall uninstall a release
upgrade upgrade a release
verify verify that a chart at the given path has been signed and is valid
version print the client version information
Flags:
--burst-limit int client-side default throttling limit (default 100)
--debug enable verbose output
-h, --help help for helm
--kube-apiserver string the address and the port for the Kubernetes API server
--kube-as-group stringArray group to impersonate for the operation, this flag can be repeated to specify multiple groups.
--kube-as-user string username to impersonate for the operation
--kube-ca-file string the certificate authority file for the Kubernetes API server connection
--kube-context string name of the kubeconfig context to use
--kube-insecure-skip-tls-verify if true, the Kubernetes API server's certificate will not be checked for validity. This will make your HTTPS connections insecure
--kube-tls-server-name string server name to use for Kubernetes API server certificate validation. If it is not provided, the hostname used to contact the server is used
--kube-token string bearer token used for authentication
--kubeconfig string path to the kubeconfig file
-n, --namespace string namespace scope for this request
--qps float32 queries per second used when communicating with the Kubernetes API, not including bursting
--registry-config string path to the registry config file (default "/home/mavrick/.config/helm/registry/config.json")
--repository-cache string path to the directory containing cached repository indexes (default "/home/mavrick/.cache/helm/repository")
--repository-config string path to the file containing repository names and URLs (default "/home/mavrick/.config/helm/repositories.yaml")
Use "helm [command] --help" for more information about a command. command for managing Helm releases across multiple clusters, including install, upgrade, list, uninstall, rollback, status, and values operations.
- Created command to fetch logs from containers in pods across all managed clusters.
- Developed command to manage the rollout of resources across all managed clusters, including history, pause, restart, resume, status, and undo functionalities.
- Implemented command to create and run images in pods across all managed clusters.
- Established a root command with custom help functions and global flags for kubeconfig, remote context, and namespace handling.
- Enhanced error handling and user feedback for operations across multiple clusters.
|
@MAVRICK-1 please either pair this down to be a smaller PR or fix the conflicts. Thank you |
|
@clubanderson i am solving the conflicts but , we have to it in single pr , its a migration to use the function between kubestellar cli and kubectl plugin |
| | kubectl multi | kubestellar | Description | | ||
| |--------------|-------------|-------------| | ||
| | `kubectl multi get` | `kubestellar get` | Get resources from all clusters | | ||
| | `kubectl multi apply` | `kubestellar apply` | Apply configuration to all clusters | | ||
| | `kubectl multi delete` | `kubestellar delete` | Delete resources from all clusters | | ||
| | `kubectl multi describe` | `kubestellar describe` | Describe resources across clusters | | ||
| | `kubectl multi logs` | `kubestellar logs` | Get logs from pods across clusters | |
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.
Hii rishi just to make sure that both Kubectl multi and kubestellar will give the same output ? if no it is not clear here! or can you clear more here ?
| ╭─────────────────────────────────────────────────────────────────────────────────╮ | ||
| │ ██╗ ██╗██╗ ██╗██████╗ ███████╗███████╗████████╗███████╗██╗ ██╗ █████╗ ██████╗ │ | ||
| │ ██║ ██╔╝██║ ██║██╔══██╗██╔════╝██╔════╝╚══██╔══╝██╔════╝██║ ██║ ██╔══██╗██╔══██╗ │ | ||
| │ █████╔╝ ██║ ██║██████╔╝█████╗ ███████╗ ██║ █████╗ ██║ ██║ ███████║██████╔╝ │ | ||
| │ ██╔═██╗ ██║ ██║██╔══██╗██╔══╝ ╚════██║ ██║ ██╔══╝ ██║ ██║ ██╔══██║██╔══██╗ │ | ||
| │ ██║ ██╗╚██████╔╝██████╔╝███████╗███████║ ██║ ███████╗███████╗███████╗██║ ██║██║ ██║ │ | ||
| │ ╚═╝ ╚═╝ ╚═════╝ ╚═════╝ ╚══════╝╚══════╝ ╚═╝ ╚══════╝╚══════╝╚══════╝╚═╝ ╚═╝╚═╝ ╚═╝ │ | ||
| │ 🌟 Multi-Cluster Kubernetes Management System 🌟 │ | ||
| ╰─────────────────────────────────────────────────────────────────────────────────╮ |
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.
this is not very clear here!
| ╭─────────────────────────────────────────────────────────────────────────────────────────────╮ | ||
| │ │ | ||
| │ ██╗ ██╗██╗ ██╗██████╗ ███████╗███████╗████████╗███████╗██╗ ██╗ █████╗ ██████╗ │ | ||
| │ ██║ ██╔╝██║ ██║██╔══██╗██╔════╝██╔════╝╚══██╔══╝██╔════╝██║ ██║ ██╔══██╗██╔══██╗ │ | ||
| │ █████╔╝ ██║ ██║██████╔╝█████╗ ███████╗ ██║ █████╗ ██║ ██║ ███████║██████╔╝ │ | ||
| │ ██╔═██╗ ██║ ██║██╔══██╗██╔══╝ ╚════██║ ██║ ██╔══╝ ██║ ██║ ██╔══██║██╔══██╗ │ | ||
| │ ██║ ██╗╚██████╔╝██████╔╝███████╗███████║ ██║ ███████╗███████╗███████╗██║ ██║██║ ██║ │ | ||
| │ ╚═╝ ╚═╝ ╚═════╝ ╚═════╝ ╚══════╝╚══════╝ ╚═╝ ╚══════╝╚══════╝╚══════╝╚═╝ ╚═╝╚═╝ ╚═╝ │ | ||
| │ │ | ||
| │ 🌟 Multi-Cluster Kubernetes Management System 🌟 │ | ||
| ╰─────────────────────────────────────────────────────────────────────────────────────────────╯ |
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 broken ! please fix it !
| kubestellar helm install nginx nginx/nginx | ||
| # Upgrade a release across all clusters | ||
| kubestellar helm upgrade nginx nginx/nginx --set replicas=3 | ||
| # List releases across all clusters | ||
| kubestellar helm list | ||
| # Uninstall a release from all clusters | ||
| kubestellar helm uninstall nginx | ||
| # Rollback a release across all clusters | ||
| kubestellar h rollback nginx 1`, |
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.
what this will do is it just a wrapper of helm command ?
or it will install kubestellar?
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.
Going to upgrade it, it will be more than just a wrapper
| # Get logs from a specific container | ||
| kubestellar logs nginx-pod -c nginx | ||
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.
I'm not very clear with this ? the same thing kubectl-multi do now?
what special thing this logs command do ? I want just make sure the idea and will not present delicately here!
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.
FYI, https://github.com/kubestellar/kubectl-plugin/blob/main/pkg/cmd/logs.go
you can take a look into this file !
| cli.cyan.Println("│") | ||
| cli.cyan.Print("│ ") | ||
| cli.bold.Print("██╗ ██╗██╗ ██╗██████╗ ███████╗███████╗████████╗███████╗███████╗███████╗██╗ █████╗ ██████╗ ") | ||
| cli.cyan.Println("│") | ||
| cli.cyan.Print("│ ") | ||
| cli.bold.Print("██║ ██╔╝██║ ██║██╔══██╗██╔════╝██╔════╝╚══██╔══╝██╔════╝██╔════╝██╔════╝██║ ██╔══██╗██╔══██╗") | ||
| cli.cyan.Println("│") | ||
| cli.cyan.Print("│ ") | ||
| cli.bold.Print("█████╔╝ ██║ ██║██████╔╝█████╗ ███████╗ ██║ █████╗ ███████╗███████╗██║ ███████║██████╔╝") | ||
| cli.cyan.Println("│") | ||
| cli.cyan.Print("│ ") | ||
| cli.bold.Print("██╔═██╗ ██║ ██║██╔══██╗██╔══╝ ╚════██║ ██║ ██╔══╝ ╚════██║╚════██║██║ ██╔══██║██╔══██╗") | ||
| cli.cyan.Println("│") | ||
| cli.cyan.Print("│ ") | ||
| cli.bold.Print("██║ ██╗╚██████╔╝██████╔╝███████╗███████║ ██║ ███████╗███████║███████║███████╗██║ ██║██║ ██║") | ||
| cli.cyan.Println("│") | ||
| cli.cyan.Print("│ ") | ||
| cli.bold.Print("╚═╝ ╚═╝ ╚═════╝ ╚═════╝ ╚══════╝╚══════╝ ╚═╝ ╚══════╝╚══════╝╚══════╝╚══════╝╚═╝ ╚═╝╚═╝ ╚═╝") |
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.
broken msg here ! please fixed it !
| } | ||
| fmt.Println() | ||
|
|
||
| // TODO: Implement actual delete operation using core operations |
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.
my concern is that there is lots of TODO in this file so , is it enough mature to add in the main branch ?
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.
There are a lot of things to implement before it to make it streamline . So next pr will look into or else this pr will be of 10 k+ lines .
Its not production ready so it won't be problem
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.
There are a lot of things to implement before it to make it streamline . So next pr will look into or else this pr will be of 10 k+ lines . Its not production ready so it won't be problem
fine, but still it is a big PR will it work as expected?
did you test all command ?
else we have to it will be good if you go with small PRs!
or a with test cases that the prs pass !
| kubectl multi helm list --all-namespaces | ||
| # List only deployed releases | ||
| kubectl multi h list --deployed | ||
| # List failed releases | ||
| kubectl multi h ls --failed`, |
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.
I think you have used kubectl multi helm and kubectl multi h both ! you should stick with one only!
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's short hand like,
K get namespace and k get ns
|
Hii @MAVRICK-1 thanks you so much for this PR! really appreciate your work ! |
|
Some updates are left to do |
|
yes, @Rupam-It made good progress on fixing commands recently - we do not want to lose this. |
This pull request introduces significant improvements to the build system and documentation, and adds a new standalone CLI entry point for KubeStellar. The changes split the project into two binaries: a
kubectlplugin (kubectl-multi) and a standalone CLI (kubestellar). The Makefile is refactored to support building, installing, and developing both binaries independently or together. TheREADME.mdis extensively rewritten to reflect the new dual-CLI architecture, provide detailed usage instructions, and enhance clarity for users and contributors. Additionally, a new main entry point for the standalone CLI is added.Key changes:
Build System and Makefile Refactoring
Makefileto support building, installing, and developing both thekubectl-multiplugin and the newkubestellarstandalone CLI, with separate targets for each binary and combined targets for both. [1] [2] [3]Standalone CLI Addition
cmd/kubestellar/main.gofor the standalonekubestellarCLI, which initializes the CLI using the shared command package.Documentation Overhaul
README.mdto document both the plugin and standalone CLI, including installation, usage, architecture, commands, configuration, example outputs, development instructions, and support resources.These changes collectively modernize the project structure, improve developer and user experience, and lay the groundwork for future enhancements.
Fixes #44