Skip to content
This repository has been archived by the owner on Feb 6, 2025. It is now read-only.

Commit

Permalink
Show node's role in 'skuba cluster status'
Browse files Browse the repository at this point in the history
  • Loading branch information
Chang Lee committed Jan 27, 2020
1 parent 8e3191c commit c5d1a13
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 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,25 @@ 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, value := range node.Labels {
_ = value
if strings.Contains(label, "node-role.kubernetes.io") && len(strings.Split(label, "/")) > 0 {
node.Labels["caasp-role.kubernetes.io"] = strings.Split(label, "/")[1]
}
}
}

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

0 comments on commit c5d1a13

Please sign in to comment.