mirror of
https://github.com/TeaOSLab/EdgeAdmin.git
synced 2025-11-09 00:20:26 +08:00
可以直接在节点启动时自动注册节点
This commit is contained in:
@@ -14,6 +14,7 @@ func init() {
|
|||||||
Helper(clusters.NewClusterHelper()).
|
Helper(clusters.NewClusterHelper()).
|
||||||
Prefix("/clusters/cluster").
|
Prefix("/clusters/cluster").
|
||||||
Get("", new(IndexAction)).
|
Get("", new(IndexAction)).
|
||||||
|
GetPost("/installNodes", new(InstallNodesAction)).
|
||||||
|
|
||||||
// 节点相关
|
// 节点相关
|
||||||
Get("/node", new(node.NodeAction)).
|
Get("/node", new(node.NodeAction)).
|
||||||
|
|||||||
@@ -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()
|
||||||
|
}
|
||||||
@@ -33,5 +33,5 @@ Vue.component("download-link", {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
template: `<a :href="url" target="_blank"><slot></slot></a>`,
|
template: `<a :href="url" target="_blank" style="font-weight: normal"><slot></slot></a>`,
|
||||||
})
|
})
|
||||||
@@ -2,5 +2,5 @@
|
|||||||
<menu-item :href="'/clusters/cluster?clusterId=' + clusterId" code="index">节点列表</menu-item>
|
<menu-item :href="'/clusters/cluster?clusterId=' + clusterId" code="index">节点列表</menu-item>
|
||||||
<menu-item :href="'/clusters/cluster/node/create?clusterId=' + clusterId" code="create">添加节点</menu-item>
|
<menu-item :href="'/clusters/cluster/node/create?clusterId=' + clusterId" code="create">添加节点</menu-item>
|
||||||
<!--<menu-item :href="'/clusters/cluster/node/import?clusterId=' + clusterId" code="import">批量导入</menu-item>-->
|
<!--<menu-item :href="'/clusters/cluster/node/import?clusterId=' + clusterId" code="import">批量导入</menu-item>-->
|
||||||
<!--<menu-item :href="'/clusters/cluster/node/install?clusterId=' + clusterId" code="install">安装节点</menu-item>-->
|
<menu-item :href="'/clusters/cluster/installNodes?clusterId=' + clusterId" code="install">安装节点</menu-item>
|
||||||
</second-menu>
|
</second-menu>
|
||||||
@@ -60,7 +60,9 @@
|
|||||||
<td>
|
<td>
|
||||||
<span v-if="node.ipAddresses.length == 0">-</span>
|
<span v-if="node.ipAddresses.length == 0">-</span>
|
||||||
<div v-else class="address-box">
|
<div v-else class="address-box">
|
||||||
<div v-for="addr in node.ipAddresses" class="ui label small">{{addr.ip}} <span class="small">({{addr.name}})</span></div>
|
<div v-for="addr in node.ipAddresses" style="margin-bottom:0.3em">
|
||||||
|
<div class="ui label tiny">{{addr.ip}} <span class="small">({{addr.name}})</span></div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
|
|||||||
20
web/views/@default/clusters/cluster/installNodes.html
Normal file
20
web/views/@default/clusters/cluster/installNodes.html
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
{$layout}
|
||||||
|
{$template "/left_menu"}
|
||||||
|
|
||||||
|
<div class="right-box">
|
||||||
|
{$template "menu"}
|
||||||
|
<p>可以通过节点安装包中的<code-label>configs/cluster.yaml</code-label>直接自动注册节点。</p>
|
||||||
|
<table class="ui table definition selectable">
|
||||||
|
<tr>
|
||||||
|
<td class="title">cluster.yaml<br/>
|
||||||
|
<em><download-link :v-element="'cluster-config-box'" :v-file="'cluster.yaml'">[下载]</download-link></em>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<pre id="cluster-config-box">rpc:
|
||||||
|
endpoints: [ {{cluster.endpoints}} ]
|
||||||
|
clusterId: "{{cluster.uniqueId}}"
|
||||||
|
secret: "{{cluster.secret}}"</pre>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
Reference in New Issue
Block a user