Просмотр исходного кода

Added machine type and more help data to node list and node usage

jnfrati 4 лет назад
Родитель
Сommit
7b7ae0427f

+ 9 - 0
dashboard/src/main/home/cluster-dashboard/dashboard/NodeList.tsx

@@ -21,6 +21,10 @@ const NodeList: React.FC = () => {
         Header: "Node name",
         accessor: "name",
       },
+      {
+        Header: "Machine type",
+        accessor: "machine_type",
+      },
       {
         Header: "CPU Usage",
         accessor: "cpu_usage",
@@ -50,10 +54,15 @@ const NodeList: React.FC = () => {
     const percentFormatter = (number: number) =>
       `${Number(number).toFixed(2)}%`;
 
+    const getMachineType = (labels: any) => {
+      return (labels && labels["node.kubernetes.io/instance-type"]) || "N/A";
+    };
+
     return nodeList
       .map((node) => {
         return {
           name: node.name,
+          machine_type: getMachineType(node?.labels),
           cpu_usage: percentFormatter(node.fraction_cpu_reqs),
           ram_usage: percentFormatter(node.fraction_memory_reqs),
           node_conditions: node.node_conditions,

+ 11 - 0
dashboard/src/main/home/cluster-dashboard/dashboard/node-view/NodeUsage.tsx

@@ -17,6 +17,17 @@ const NodeUsage: React.FunctionComponent<NodeUsageProps> = ({ node }) => {
         <span>How to read memory and cpu units</span>
         <i className="material-icons">help_outline</i>
       </Help>
+
+      <Help
+        href="https://kubernetes.io/docs/tasks/administer-cluster/reserve-compute-resources/#node-allocatable"
+        target="_blank"
+      >
+        <span>
+          The memory value corresponds to the allocatable total on node, for
+          more info click here
+        </span>
+        <i className="material-icons">help_outline</i>
+      </Help>
       <Wrapper>
         <UsageWrapper>
           <span>

+ 4 - 4
internal/kubernetes/nodes/nodes.go

@@ -25,6 +25,7 @@ type NodeUsage struct {
 
 type NodeWithUsageData struct {
 	Name                           string             `json:"name"`
+	Labels                         map[string]string  `json:"labels"`
 	CpuReqs                        string             `json:"cpu_reqs"`
 	MemoryReqs                     string             `json:"memory_reqs"`
 	EphemeralStorageReqs           string             `json:"ephemeral_storage_reqs"`
@@ -40,6 +41,7 @@ type NodeWithUsageData struct {
 func (nu *NodeUsage) Externalize(node v1.Node) *NodeWithUsageData {
 	return &NodeWithUsageData{
 		Name:                           node.Name,
+		Labels:                         node.Labels,
 		CpuReqs:                        nu.cpuReqs,
 		MemoryReqs:                     nu.memoryReqs,
 		EphemeralStorageReqs:           nu.ephemeralStorageReqs,
@@ -87,9 +89,8 @@ func getPodsForNode(clientset kubernetes.Interface, nodeName string) *v1.PodList
 
 type NodeDetails struct {
 	NodeWithUsageData
-	Labels            map[string]string `json:"labels"`
-	AllocatableCpu    int64             `json:"allocatable_cpu"`
-	AllocatableMemory string            `json:"allocatable_memory"`
+	AllocatableCpu    int64  `json:"allocatable_cpu"`
+	AllocatableMemory string `json:"allocatable_memory"`
 }
 
 func DescribeNode(clientset kubernetes.Interface, nodeName string) *NodeDetails {
@@ -101,7 +102,6 @@ func DescribeNode(clientset kubernetes.Interface, nodeName string) *NodeDetails
 
 	return &NodeDetails{
 		NodeWithUsageData: *extNodeUsage,
-		Labels:            node.Labels,
 		AllocatableCpu:    node.Status.Allocatable.Cpu().MilliValue(),
 		AllocatableMemory: node.Status.Allocatable.Memory().String(),
 	}