Skip to content
This repository has been archived by the owner on Dec 16, 2024. It is now read-only.

Show node's role in 'skuba cluster status' #928

Merged
merged 1 commit into from
Jan 27, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion pkg/skuba/actions/cluster/status/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package cluster

import (
"os"
"strings"

"github.com/pkg/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand All @@ -34,7 +35,24 @@ func Status(client clientset.Interface) error {
return errors.Wrap(err, "could not retrieve node list")
}

outputFormat := "custom-columns=NAME:.metadata.name,OS-IMAGE:.status.nodeInfo.osImage,KERNEL-VERSION:.status.nodeInfo.kernelVersion,KUBELET-VERSION:.status.nodeInfo.kubeletVersion,CONTAINER-RUNTIME:.status.nodeInfo.containerRuntimeVersion,HAS-UPDATES:.metadata.annotations.caasp\\.suse\\.com/has-updates,HAS-DISRUPTIVE-UPDATES:.metadata.annotations.caasp\\.suse\\.com/has-disruptive-updates,CAASP-RELEASE-VERSION:.metadata.annotations.caasp\\.suse\\.com/caasp-release-version"
for _, node := range nodeList.Items {
for label := range node.Labels {
if strings.Contains(label, "node-role.kubernetes.io") && len(strings.Split(label, "/")) > 0 {
node.Labels["caasp-role.kubernetes.io"] = strings.Split(label, "/")[1]
Klaven marked this conversation as resolved.
Show resolved Hide resolved
}
}
}

outputFormat := "custom-columns=" +
"NAME:.metadata.name," +
"ROLE:.metadata.labels.caasp-role\\.kubernetes\\.io," +
"OS-IMAGE:.status.nodeInfo.osImage," +
"KERNEL-VERSION:.status.nodeInfo.kernelVersion," +
"KUBELET-VERSION:.status.nodeInfo.kubeletVersion," +
"CONTAINER-RUNTIME:.status.nodeInfo.containerRuntimeVersion," +
"HAS-UPDATES:.metadata.annotations.caasp\\.suse\\.com/has-updates," +
"HAS-DISRUPTIVE-UPDATES:.metadata.annotations.caasp\\.suse\\.com/has-disruptive-updates," +
"CAASP-RELEASE-VERSION:.metadata.annotations.caasp\\.suse\\.com/caasp-release-version"

printFlags := kubectlget.NewGetPrintFlags()
printFlags.OutputFormat = &outputFormat
Expand Down