diff --git a/pkg/ha/html.go b/pkg/ha/html.go index f43c371..b064e6f 100644 --- a/pkg/ha/html.go +++ b/pkg/ha/html.go @@ -1,32 +1,34 @@ package ha -var HtmlPage = ` - - - - - - - - - - - - - - - {{range .Items}} - - - - - - - - - - {{end}} - -
NameTypeReplicasRollout StrategyAnti-AffinityPVCsRank
{{.Name}}{{.Type}}{{.Replicas}}{{.RolloutStrategy}}{{.PodAntiAffinity}}{{.PVC}}{{.Rank}}
- -` +var HtmlPage = ` +

High Availability

+ + + + + + + + + + + + + + + {{range .Items}} + + + + + + + + + + + {{end}} + +
NamespaceNameTypeReplicasRollout StrategyAnti-AffinityPVCsRank
{{.Namespace}}{{.Name}}{{.Type}}{{.Replicas}}{{.RolloutStrategy}}{{.PodAntiAffinity}}{{.PVC}}{{.Rank}}
+
+
%s
` diff --git a/pkg/ha/types.go b/pkg/ha/types.go index e5e405d..d3cfb94 100644 --- a/pkg/ha/types.go +++ b/pkg/ha/types.go @@ -10,6 +10,22 @@ import ( "k8s.io/client-go/tools/clientcmd" ) +var description = ` + +Ranks +0: Undefined (detection was not possible) +1: High-available (failure-resilient, zero-downtime-deployment capable) +2: Zero-downtime-deployment capable: (non failure-resilient) +3: Single-point-of-failure +4: Standalone pod + +Definitions +Failure resilient: If a single pod or node crashes, the availability of the workload is not affected. +Zero-downtime-deployment: The workload can be updated without downtime +Single-point-of-failure: If a single pod or the node crashes, the availability of the workload is degraded. +Standalone pod: If the pod is removed or crashes, it disappears without replacement. +` + type HighAvailability struct { KubeOverrides *clientcmd.ConfigOverrides KubeClient *kubernetes.KubeClient @@ -40,7 +56,7 @@ func (p PodAvailabilityList) ToJson() (string, error) { } func (p PodAvailabilityList) ToHtml() (string, error) { - return printer.ToHtml(HtmlPage, p) + return printer.ToHtml(fmt.Sprintf(HtmlPage, description), p) } func (p PodAvailabilityList) ToTable() (string, error) { @@ -51,6 +67,7 @@ func (p PodAvailabilityList) ToTable() (string, error) { table.SetAlignment(tablewriter.ALIGN_LEFT) table.SetHeader([]string{ + "Namespace", "Name", "Type", "Replicas", @@ -62,6 +79,7 @@ func (p PodAvailabilityList) ToTable() (string, error) { for _, v := range p.Items { table.Append([]string{ + v.Namespace, v.Name, v.Type, fmt.Sprint(v.Replicas), @@ -73,5 +91,6 @@ func (p PodAvailabilityList) ToTable() (string, error) { } table.Render() - return buf.String(), nil + content := buf.String() + return fmt.Sprintf("%s %s", content, description), nil } diff --git a/pkg/printer/html_container.go b/pkg/printer/html_container.go new file mode 100644 index 0000000..b5af35d --- /dev/null +++ b/pkg/printer/html_container.go @@ -0,0 +1,17 @@ +package printer + +var HtmlContainer = ` + + + + + + +
+ %s +
+ + +` diff --git a/pkg/printer/printer.go b/pkg/printer/printer.go index 53ea2ee..c7748e2 100644 --- a/pkg/printer/printer.go +++ b/pkg/printer/printer.go @@ -58,5 +58,6 @@ func ToHtml(html string, v interface{}) (string, error) { } err = tpl.Execute(buf, v) - return buf.String(), err + content := buf.String() + return fmt.Sprintf(HtmlContainer, content), err } diff --git a/pkg/resources/html.go b/pkg/resources/html.go index 81bb2a6..3e55250 100644 --- a/pkg/resources/html.go +++ b/pkg/resources/html.go @@ -1,28 +1,28 @@ package resources -var HtmlPage = ` - - - - - - - - - - - - - {{range .Items}} - - - - - - - - {{end}} - -
PodMemory RequestsMemory LimitsCPU RequestsCPU Limits
{{.Pod}}{{.MemoryRequests.Min.FormatMemory}}
{{.MemoryRequests.Avg.FormatMemory}}
{{.MemoryRequests.Max.FormatMemory}}
{{.MemoryLimits.Min.FormatMemory}}
{{.MemoryLimits.Avg.FormatMemory}}
{{.MemoryLimits.Max.FormatMemory}}
{{.CPURequests.Min.FormatCPU}}
{{.CPURequests.Avg.FormatCPU}}
{{.CPURequests.Max.FormatCPU}}
{{.CPULimits.Min.FormatCPU}}
{{.CPULimits.Avg.FormatCPU}}
{{.CPULimits.Max.FormatCPU}}
- -` +var HtmlPage = ` +

Resource usage

+ + + + + + + + + + + + + {{range .Items}} + + + + + + + + + {{end}} + +
NamespacePodMemory RequestsMemory LimitsCPU RequestsCPU Limits
{{.Namespace}}{{.Pod}}{{.MemoryRequests.Min.FormatMemory}}
{{.MemoryRequests.Avg.FormatMemory}}
{{.MemoryRequests.Max.FormatMemory}}
{{.MemoryLimits.Min.FormatMemory}}
{{.MemoryLimits.Avg.FormatMemory}}
{{.MemoryLimits.Max.FormatMemory}}
{{.CPURequests.Min.FormatCPU}}
{{.CPURequests.Avg.FormatCPU}}
{{.CPURequests.Max.FormatCPU}}
{{.CPULimits.Min.FormatCPU}}
{{.CPULimits.Avg.FormatCPU}}
{{.CPULimits.Max.FormatCPU}}
` diff --git a/pkg/resources/types.go b/pkg/resources/types.go index 4362cd9..ff0fafc 100644 --- a/pkg/resources/types.go +++ b/pkg/resources/types.go @@ -56,6 +56,7 @@ func (p PodValuesList) ToTable() (string, error) { table.SetAlignment(tablewriter.ALIGN_LEFT) table.SetHeader([]string{ + "Namespace", "Pod", "Memory Requests", "Memory Limits", @@ -65,6 +66,7 @@ func (p PodValuesList) ToTable() (string, error) { for _, v := range p.Items { table.Append([]string{ + v.Namespace, v.Pod, v.MemoryRequests.Min.FormatMemory() + "\n" + v.MemoryRequests.Avg.FormatMemory() + "\n" + v.MemoryRequests.Max.FormatMemory(), v.MemoryLimits.Min.FormatMemory() + "\n" + v.MemoryLimits.Avg.FormatMemory() + "\n" + v.MemoryLimits.Max.FormatMemory(),