kusion
kusion copied to clipboard
[GLCC Project] Kusion Resources Dashboard / Kusion 资源管理大盘
Background
Currently, Kusion has the capacity for Kubernetes resource and IaaS cloud resource operations and status management. However, the status of resources can only be viewed during operation execution, without an entry for viewing resource status when operations are not being performed. This project aims to build a Kusion resource management dashboard to enable users to view resource status at any time.
Objective
Build the Kusion resource dashboard.
Deliverables
Tasks include:
- Building the resource status viewing capability for users to view the status of all resources under the current application.
- Building the capability to detect resource status and cluster real-time drift, providing prompts for drifted resources.
- Building a user-friendly command-line interface to facilitate user usage of the above capabilities.
Difficulty
Low
Skill Requirements
- Familiarity with Go language
- Understanding of Kubernetes
- Understanding of Terraform (bonus)
背景
Kusion 当前已经具备 Kubernetes 资源与 IaaS 云资源的运维与状态管理能力,资源状态只在运维操作执行时才能看到,缺少在不执行运维操作时查看资源状态的入口。本课题需要基于当前已有能力构建 Kusion 资源管理大盘,方便用户随时查看资源的状态。
目标
构建 Kusion 资源管理大盘
产出要求
具体包含如下任务:
- 构建资源状态查看能力,用户可以查看当前应用下所有资源的状态
- 构建资源状态与集群真实状态漂移检测能力,对于已经漂移的资源做出提示
- 建设用户友好的命令行交互界面,方便用户使用上述能力
难度
低
能力要求
- 熟悉 Go 语言
- 了解 Kubernetes
- 了解 Terraform(加分项)
Roadmap pointed out that Kusion supported 资源配置漂移检查
in February 2023, but I didn't find related issues and PRs, could you please provide more information about this?
Roadmap pointed out that Kusion supported
资源配置漂移检查
in February 2023, but I didn't find related issues and PRs, could you please provide more information about this?
Thanks for your report. The Chinese version of the roadmap is deprecated, we will make a clean-up recently. Please check the English version.
Roadmap pointed out that Kusion supported
资源配置漂移检查
in February 2023, but I didn't find related issues and PRs, could you please provide more information about this?Thanks for your report. The Chinese version of the roadmap is deprecated, we will make a clean-up recently. Please check the English version.
The content structure of the Roadmap section of the English version and the Chinese version is very inconsistent, so I still don't know what is the current ability of Kusion or KusionStack to detect configuration drift?
Roadmap pointed out that Kusion supported
资源配置漂移检查
in February 2023, but I didn't find related issues and PRs, could you please provide more information about this?Thanks for your report. The Chinese version of the roadmap is deprecated, we will make a clean-up recently. Please check the English version.
The content structure of the Roadmap section of the English version and the Chinese version is very inconsistent, so I still don't know what is the current ability of Kusion or KusionStack to detect configuration drift?
Kusion currently lacks the ability to identify configuration drift, which is designated as task 2 in the GLCC project's objectives.
Thanks!
I will submit the proposal on gitlink today.
@SparkYuan Thank you very much for giving me this opportunity to participate in the development of the kusion. I will complete the initial development work as soon as possible.
Design
task1
Kusion runtime resource management commands are mainly preview
, apply
and destroy
. In preview
and apply
, calling the Preview
and changes.Summary(os.Stdout)
method will output an overview of the current resource changes on the command line. For example:
The apply command can monitor the status of all resources through the watch flag, and display the detailed information of the current resource Type, Kind, Name, and Detail in a user-friendly manner. For example:
On the other hand, the apply
command, when used with the watch
flag, allows for monitoring the status of all resources and displays the detailed information of the current resource, including its Type, Kind, Name, and Details, in a user-friendly manner.
Based on the above, this proposal combines the preview
command to show resource change information and the watch
flag to display real-time resource status, creating a new mechanism for viewing resource states. This approach provides a comprehensive view of both the planned changes and the current state of resources, enhancing visibility and enabling better monitoring and management of resources.
task2
To implement the resource drift detection capability, we reuse the relevant code from the apply
command that deals with resource model diff. Here is an example of how I incorporate it into thekusion get
command:
// Summary preview table
changes.Summary(os.Stdout)
// Prompt
for {
target, err := changes.PromptDetails()
if err != nil {
return err
}
if target == "" { // Cancel option
break
}
changes.OutputDiff(target)
}
task3
To fulfill the user's need to view resource status using Kusion, this solution takes inspiration from the kubectl get
command. It proposes adding a get
subcommand to Kusion for viewing relevant resource status. In order to support resource drift detection, a --show-drift
flag would be added.
With the new get
subcommand and the --show-drift
flag, users can retrieve the current status of resources managed by Kusion. This feature enables them to compare the desired state with the actual state of resources and detect any configuration drift. By incorporating this functionality, Kusion enhances its resource management capabilities and provides users with a comprehensive toolset for monitoring and maintaining their resources.
The following is the directory structure and help documentation of the get
subcommand.
├── get
│ ├── get.go
│ ├── get_test.go
│ ├── options.go
│ └── options_test.go
View the status of resource(s).
Prints the most important information about the status of resources. If you want to see how resources are drifting, you can use the --show-drift flag.
Examples:
# Display the status of all resource(s) in the current directory
kusion get
# Display resource(s) drifting condition in the current directory
kusion get --show-drift
Options:
-a, --all=false:
Automatically show all plan details, combined use with flag `--detail`
-d, --detail=false:
Automatically show plan details with interactive options
--ignore-fields=[]:
Ignore differences of target fields
--no-style=false:
no-style sets to RawOutput mode and disables all of styling
--operator='':
Specify the operator
-o, --output='':
Specify the output format
--show-drift=false:
Display resource(s) drift
Usage:
kusion get [flags] [options]
Use "kusion get options" for a list of global command-line options (applies to all commands).
Preview
-
kusion get
-
kusion get --show-drift
TODO
- [x] add
get
command - [ ]
get
command unit test - [ ] i18 support with gettext-go
- [ ] command docs generated spf13/cobra