diff --git a/internal/web/actions/default/clusters/cluster/init.go b/internal/web/actions/default/clusters/cluster/init.go index 114ec276..bf3646d2 100644 --- a/internal/web/actions/default/clusters/cluster/init.go +++ b/internal/web/actions/default/clusters/cluster/init.go @@ -14,6 +14,7 @@ func init() { Helper(clusters.NewClusterHelper()). Prefix("/clusters/cluster"). Get("", new(IndexAction)). + GetPost("/installNodes", new(InstallNodesAction)). // 节点相关 Get("/node", new(node.NodeAction)). diff --git a/internal/web/actions/default/clusters/cluster/installNodes.go b/internal/web/actions/default/clusters/cluster/installNodes.go new file mode 100644 index 00000000..eb0f9642 --- /dev/null +++ b/internal/web/actions/default/clusters/cluster/installNodes.go @@ -0,0 +1,72 @@ +package cluster + +import ( + "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils" + "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" + "github.com/iwind/TeaGo/maps" + "strings" +) + +type InstallNodesAction struct { + actionutils.ParentAction +} + +func (this *InstallNodesAction) Init() { + this.Nav("", "node", "install") + this.SecondMenu("nodes") +} + +func (this *InstallNodesAction) RunGet(params struct { + ClusterId int64 +}) { + clusterResp, err := this.RPC().NodeClusterRPC().FindEnabledNodeCluster(this.AdminContext(), &pb.FindEnabledNodeClusterRequest{ClusterId: params.ClusterId}) + if err != nil { + this.ErrorPage(err) + return + } + if clusterResp.Cluster == nil { + this.NotFound("nodeCluster", params.ClusterId) + return + } + + cluster := clusterResp.Cluster + + clusterAPINodesResp, err := this.RPC().NodeClusterRPC().FindAPINodesWithNodeCluster(this.AdminContext(), &pb.FindAPINodesWithNodeClusterRequest{ClusterId: params.ClusterId}) + if err != nil { + this.ErrorPage(err) + return + } + if err != nil { + this.ErrorPage(err) + return + } + apiNodeAddrs := []string{} + if clusterAPINodesResp.UseAllAPINodes { + apiNodesResp, err := this.RPC().APINodeRPC().FindAllEnabledAPINodes(this.AdminContext(), &pb.FindAllEnabledAPINodesRequest{}) + if err != nil { + this.ErrorPage(err) + return + } + for _, apiNode := range apiNodesResp.Nodes { + if !apiNode.IsOn { + continue + } + apiNodeAddrs = append(apiNodeAddrs, apiNode.AccessAddrs...) + } + } else { + for _, apiNode := range clusterAPINodesResp.ApiNodes { + if !apiNode.IsOn { + continue + } + apiNodeAddrs = append(apiNodeAddrs, apiNode.AccessAddrs...) + } + } + + this.Data["cluster"] = maps.Map{ + "uniqueId": cluster.UniqueId, + "secret": cluster.Secret, + "endpoints": "\"" + strings.Join(apiNodeAddrs, "\", \"") + "\"", + } + + this.Show() +} diff --git a/web/public/js/components/common/download-link.js b/web/public/js/components/common/download-link.js index cc79df0e..03f15721 100644 --- a/web/public/js/components/common/download-link.js +++ b/web/public/js/components/common/download-link.js @@ -33,5 +33,5 @@ Vue.component("download-link", { }) } }, - template: ``, + template: ``, }) \ No newline at end of file diff --git a/web/views/@default/clusters/cluster/@menu.html b/web/views/@default/clusters/cluster/@menu.html index c4899af5..a9e8ed1f 100644 --- a/web/views/@default/clusters/cluster/@menu.html +++ b/web/views/@default/clusters/cluster/@menu.html @@ -2,5 +2,5 @@ 节点列表 添加节点 - + 安装节点 \ No newline at end of file diff --git a/web/views/@default/clusters/cluster/index.html b/web/views/@default/clusters/cluster/index.html index 92350535..73eda244 100644 --- a/web/views/@default/clusters/cluster/index.html +++ b/web/views/@default/clusters/cluster/index.html @@ -60,7 +60,9 @@ -
-
{{addr.ip}} ({{addr.name}})
+
+
{{addr.ip}} ({{addr.name}})
+
diff --git a/web/views/@default/clusters/cluster/installNodes.html b/web/views/@default/clusters/cluster/installNodes.html new file mode 100644 index 00000000..ba06d008 --- /dev/null +++ b/web/views/@default/clusters/cluster/installNodes.html @@ -0,0 +1,20 @@ +{$layout} +{$template "/left_menu"} + +
+ {$template "menu"} +

可以通过节点安装包中的configs/cluster.yaml直接自动注册节点。

+ + + + + +
cluster.yaml
+ [下载] +
+
rpc:
+  endpoints: [ {{cluster.endpoints}} ]
+clusterId: "{{cluster.uniqueId}}"
+secret: "{{cluster.secret}}"
+
+
\ No newline at end of file