mirror of
https://github.com/kubesphere/kubekey.git
synced 2025-12-25 17:12:50 +00:00
* feat: enhance precheck tasks for image registry and network validation - Added a task to ensure successful authentication to the image registry. - Updated existing tasks to provide clearer failure messages for required configurations. - Improved validation for network interfaces and CIDR configurations, ensuring dual-stack support. - Enhanced error handling in the resource handler for playbook creation. Signed-off-by: joyceliu <joyceliu@yunify.com> * feat: enhance configuration and query handling - Added `-trimpath` flag to Go build configuration for improved binary paths. - Updated REST configuration to set QPS and Burst limits for better performance. - Refactored query handling to use string types for field and value, improving type consistency. - Enhanced error handling in resource configuration updates and improved parsing of request bodies. Signed-off-by: joyceliu <joyceliu@yunify.com> * feat: check inventory when it's changed Signed-off-by: joyceliu <joyceliu@yunify.com> * feat: enhance playbook execution and query handling - Added a new optional query parameter `promise` to the playbook and inventory endpoints, allowing for asynchronous execution control. - Introduced a new result state `ResultPending` to indicate ongoing operations. - Refactored the executor function to handle the `promise` parameter, enabling conditional execution of playbooks. - Improved error handling and logging during playbook execution. Signed-off-by: joyceliu <joyceliu@yunify.com> --------- Signed-off-by: joyceliu <joyceliu@yunify.com>
57 lines
1.6 KiB
Go
57 lines
1.6 KiB
Go
package app
|
|
|
|
import (
|
|
"path/filepath"
|
|
|
|
"github.com/spf13/cobra"
|
|
"k8s.io/client-go/rest"
|
|
ctrlclient "sigs.k8s.io/controller-runtime/pkg/client"
|
|
|
|
"github.com/kubesphere/kubekey/v4/cmd/kk/app/options"
|
|
_const "github.com/kubesphere/kubekey/v4/pkg/const"
|
|
"github.com/kubesphere/kubekey/v4/pkg/manager"
|
|
"github.com/kubesphere/kubekey/v4/pkg/proxy"
|
|
)
|
|
|
|
// newWebCommand creates a new cobra command for starting the KubeKey web server
|
|
// It initializes the web server with the provided configuration options and starts
|
|
// the HTTP server with web UI interface
|
|
func newWebCommand() *cobra.Command {
|
|
o := options.NewKubeKeyWebOptions()
|
|
|
|
cmd := &cobra.Command{
|
|
Use: "web",
|
|
Short: "start a http server with web UI.",
|
|
RunE: func(cmd *cobra.Command, args []string) error {
|
|
// Initialize REST config for Kubernetes client
|
|
restconfig := &rest.Config{QPS: 100, Burst: 200}
|
|
if err := proxy.RestConfig(filepath.Join(o.Workdir, _const.RuntimeDir), restconfig); err != nil {
|
|
return err
|
|
}
|
|
|
|
// Create Kubernetes client with the REST config
|
|
client, err := ctrlclient.New(restconfig, ctrlclient.Options{
|
|
Scheme: _const.Scheme,
|
|
})
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
// Initialize and run the web manager with provided options
|
|
return manager.NewWebManager(manager.WebManagerOptions{
|
|
Workdir: o.Workdir,
|
|
Port: o.Port,
|
|
SchemaPath: o.SchemaPath,
|
|
UIPath: o.UIPath,
|
|
Client: client,
|
|
Config: restconfig,
|
|
}).Run(cmd.Context())
|
|
},
|
|
}
|
|
for _, f := range o.Flags().FlagSets {
|
|
cmd.Flags().AddFlagSet(f)
|
|
}
|
|
|
|
return cmd
|
|
}
|