Przeglądaj źródła

Added instance type to expanded node view

jnfrati 4 lat temu
rodzic
commit
c6674ba4c4

+ 11 - 2
dashboard/src/main/home/cluster-dashboard/dashboard/node-view/ExpandedNodeView.tsx

@@ -1,4 +1,4 @@
-import React, { useContext, useEffect, useState } from "react";
+import React, { useContext, useEffect, useMemo, useState } from "react";
 import { useHistory, useLocation, useParams } from "react-router";
 import styled from "styled-components";
 import closeImg from "assets/close.png";
@@ -55,6 +55,15 @@ export const ExpandedNodeView = () => {
     pushFiltered({ history, location }, "/cluster-dashboard", []);
   };
 
+  const instanceType = useMemo(() => {
+    const instanceType =
+      node?.labels && node?.labels["node.kubernetes.io/instance-type"];
+    if (instanceType) {
+      return ` (${instanceType})`;
+    }
+    return "";
+  }, [node?.labels]);
+
   return (
     <>
       <CloseOverlay onClick={closeNodeView} />
@@ -65,7 +74,7 @@ export const ExpandedNodeView = () => {
               <IconWrapper>
                 <img src={nodePng} />
               </IconWrapper>
-              {nodeId}
+              {nodeId} {instanceType}
             </Title>
           </TitleSection>
 

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

@@ -87,8 +87,9 @@ func getPodsForNode(clientset kubernetes.Interface, nodeName string) *v1.PodList
 
 type NodeDetails struct {
 	NodeWithUsageData
-	AllocatableCpu    string `json:"allocatable_cpu"`
-	AllocatableMemory string `json:"allocatable_memory"`
+	Labels            map[string]string `json:"labels"`
+	AllocatableCpu    string            `json:"allocatable_cpu"`
+	AllocatableMemory string            `json:"allocatable_memory"`
 }
 
 func DescribeNode(clientset kubernetes.Interface, nodeName string) *NodeDetails {
@@ -100,6 +101,7 @@ func DescribeNode(clientset kubernetes.Interface, nodeName string) *NodeDetails
 
 	return &NodeDetails{
 		NodeWithUsageData: *extNodeUsage,
+		Labels:            node.Labels,
 		AllocatableCpu:    node.Status.Allocatable.Cpu().String(),
 		AllocatableMemory: node.Status.Allocatable.Memory().String(),
 	}