目录

用etcd-browser访问v2的etcd集群

概念

2024年了,公司还有一套老集群是用的 Etcd Version: 3.1.10,因为在预发布环境,所以准备用 etcd-browser 可视化工具来看一下 Etcd 集群的存储情况。

启动etcd-browser

1
docker run --rm --name etcd-browser -p 0.0.0.0:8000:8000 --env ETCD_HOST=10.xx.xx.xx --env ETCD_PORT=2379 -t -i buddho/etcd-browser

本地访问 localhost:8000 查看页面,可以看到这个 Etcd 其实是用于 Contiv,也就是 Kubernetes 的一个 CNI 用的。

/%E7%94%A8etcd-browser%E8%AE%BF%E9%97%AEv2%E7%9A%84etcd%E9%9B%86%E7%BE%A4/img.png

另外要注意的是,如果是生产环境或者是重要的数据,在使用 etcd-browser 的时候要注意小心把原来的值覆盖了,当然了,因为 etcd-browser 代码很简单,可以修改前端的代码,把可能会修改值的 button 和操作都去掉,把 etcd-browser 变成一个完全只读的可视化工具就更安全了,详细的修改,可以看下面的代码。

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
diff --git a/frontend/index.html b/frontend/index.html
index 7e9eba2..eb522fb 100644
--- a/frontend/index.html
+++ b/frontend/index.html
@@ -19,24 +19,25 @@
 </head>
 <body>
 <script type="text/ng-template" id="prop-block">
-  <button type="button" class="btn btn-default btn-xs" ng-click="addNode(activeNode)" title="Add Property">
-    Add Property
-  </button>
+<!--  <button type="button" class="btn btn-default btn-xs" ng-click="addNode(activeNode)" title="Add Property">-->
+<!--    Add Property-->
+<!--  </button>-->
   <table class="property-table">
     <tr ng-repeat="node in activeNode.nodes | orderBy:'name'" ng-if="!node.dir" ng-class-odd="'odd-row'">
       <td>
-        <button type="button" class="btn btn-default btn-xs" ng-click="copyNode(node)" title="Copy Node">
-          <span class="glyphicon glyphicon-floppy-open"></span>
-        </button>
-        <button type="button" class="btn btn-default btn-xs" ng-click="deleteNode(node)" title="Delete Node">
-          <span class="glyphicon glyphicon-trash"></span>
-        </button>
+<!--        <button type="button" class="btn btn-default btn-xs" ng-click="copyNode(node)" title="Copy Node">-->
+<!--          <span class="glyphicon glyphicon-floppy-open"></span>-->
+<!--        </button>-->
+<!--        <button type="button" class="btn btn-default btn-xs" ng-click="deleteNode(node)" title="Delete Node">-->
+<!--          <span class="glyphicon glyphicon-trash"></span>-->
+<!--        </button>-->
       </td>
       <td style="text-align:left;font-weight:bold;padding: 5px 4px;">
         <span>{{node.name}}:</span>
       </td>
       <td style="padding-right: 5px;">
-        <span class="value" editable-text="node.value" onbeforesave="updateNode(node,$data)">{{node.value || '(empty)'}}</span>
+<!--        <span class="value" editable-text="node.value" onbeforesave="updateNode(node,$data)">{{node.value || '(empty)'}}</span>-->
+        <span>{{node.value || '(empty)'}}</span>
       </td>
     </tr>
   </table>
@@ -46,15 +47,15 @@
   <span ng-click="toggleNode(node)" class="glyphicon glyphicon-plus toggle-icon" ng-if="!node.open"></span>
   <a href="" ng-click="setActiveNode(node)" ng-if="node.dir" class="{{node.key == activeNode.key ? 'active-node' : ''}}">{{node.name}}</a>
   <div class="btn-group" ng-if="node.key == activeNode.key">
-    <button ng-if="node.open" ng-click="createDir(node)" class="btn btn-default btn-xs" type="button" title="Create Directory">
-      <span class="glyphicon glyphicon-plus"></span>
-    </button>
-    <button ng-if="node.open" ng-click="copyDir(node)" class="btn btn-default btn-xs" type="button" title="Copy Directory">
-      <span class="glyphicon glyphicon-floppy-open"></span>
-    </button>
-    <button ng-if="node.open" type="button" class="btn btn-default btn-xs" ng-click="deleteDir(node)" title="Delete Directory">
-      <span class="glyphicon glyphicon-trash"></span>
-    </button>
+<!--    <button ng-if="node.open" ng-click="createDir(node)" class="btn btn-default btn-xs" type="button" title="Create Directory">-->
+<!--      <span class="glyphicon glyphicon-plus"></span>-->
+<!--    </button>-->
+<!--    <button ng-if="node.open" ng-click="copyDir(node)" class="btn btn-default btn-xs" type="button" title="Copy Directory">-->
+<!--      <span class="glyphicon glyphicon-floppy-open"></span>-->
+<!--    </button>-->
+<!--    <button ng-if="node.open" type="button" class="btn btn-default btn-xs" ng-click="deleteDir(node)" title="Delete Directory">-->
+<!--      <span class="glyphicon glyphicon-trash"></span>-->
+<!--    </button>-->
   </div>
   <ul >
     <li ng-repeat="node in node.nodes | orderBy:'name'" ng-include="'tree-item'" ng-if="node.dir"></li>
@@ -83,9 +84,9 @@
             <li>
               <a href="#" ng-click="setActiveNode(root)" class="{{root.key == activeNode.key ? 'active-node' : ''}}">root</a>
               <div class="btn-group">
-                <button ng-click="createDir(root)" class="btn btn-default btn-xs" type="button" title="Create Directory">
-                  <span class="glyphicon glyphicon-plus"></span>
-                </button>
+<!--                <button ng-click="createDir(root)" class="btn btn-default btn-xs" type="button" title="Create Directory">-->
+<!--                  <span class="glyphicon glyphicon-plus"></span>-->
+<!--                </button>-->
               </div>
               <button class="btn btn-primary btn-xs" data-toggle="modal" data-target="#myModal" ng-click="loadStats()">Stats</button>
               <ul>

参考资料

  1. etcd-browser