mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-31 23:37:01 +00:00
Add more information to node describe
This commit is contained in:
parent
fb0f23d7f7
commit
58776da6a4
@ -50,3 +50,32 @@ kube::test::get_object_assert() {
|
|||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
kube::test::describe_object_assert() {
|
||||||
|
local resource=$1
|
||||||
|
local object=$2
|
||||||
|
local matches=${@:3}
|
||||||
|
|
||||||
|
result=$(eval kubectl describe "${kube_flags[@]}" $resource $object)
|
||||||
|
|
||||||
|
for match in ${matches}; do
|
||||||
|
if [[ ! $(echo "$result" | grep ${match}) ]]; then
|
||||||
|
echo ${bold}${red}
|
||||||
|
echo "FAIL!"
|
||||||
|
echo "Describe $resource $object"
|
||||||
|
echo " Expected Match: $match"
|
||||||
|
echo " Not found in:"
|
||||||
|
echo "$result"
|
||||||
|
echo ${reset}${red}
|
||||||
|
caller
|
||||||
|
echo ${reset}
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
echo -n ${green}
|
||||||
|
echo "Successful describe $resource $object:"
|
||||||
|
echo "$result"
|
||||||
|
echo -n ${reset}
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
@ -104,7 +104,7 @@ CTLRMGR_PID=$!
|
|||||||
kube::util::wait_for_url "http://127.0.0.1:${CTLRMGR_PORT}/healthz" "controller-manager: "
|
kube::util::wait_for_url "http://127.0.0.1:${CTLRMGR_PORT}/healthz" "controller-manager: "
|
||||||
kube::util::wait_for_url "http://127.0.0.1:${API_PORT}/api/v1beta1/minions/127.0.0.1" "apiserver(minions): " 0.2 25
|
kube::util::wait_for_url "http://127.0.0.1:${API_PORT}/api/v1beta1/minions/127.0.0.1" "apiserver(minions): " 0.2 25
|
||||||
|
|
||||||
# expose kubectl directly for readability
|
# Expose kubectl directly for readability
|
||||||
PATH="${KUBE_OUTPUT_HOSTBIN}":$PATH
|
PATH="${KUBE_OUTPUT_HOSTBIN}":$PATH
|
||||||
|
|
||||||
kube_api_versions=(
|
kube_api_versions=(
|
||||||
@ -139,7 +139,7 @@ for version in "${kube_api_versions[@]}"; do
|
|||||||
rc_replicas_field="spec.replicas"
|
rc_replicas_field="spec.replicas"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# passing no arguments to create is an error
|
# Passing no arguments to create is an error
|
||||||
! kubectl create
|
! kubectl create
|
||||||
|
|
||||||
###########################
|
###########################
|
||||||
@ -502,6 +502,8 @@ __EOF__
|
|||||||
|
|
||||||
kube::test::get_object_assert nodes "{{range.items}}{{.$id_field}}:{{end}}" '127.0.0.1:'
|
kube::test::get_object_assert nodes "{{range.items}}{{.$id_field}}:{{end}}" '127.0.0.1:'
|
||||||
|
|
||||||
|
kube::test::describe_object_assert nodes "127.0.0.1" "Name:" "Conditions:" "Addresses:" "Capacity:" "Pods:"
|
||||||
|
|
||||||
###########
|
###########
|
||||||
# Minions #
|
# Minions #
|
||||||
###########
|
###########
|
||||||
@ -513,6 +515,8 @@ __EOF__
|
|||||||
|
|
||||||
# TODO: I should be a MinionList instead of List
|
# TODO: I should be a MinionList instead of List
|
||||||
kube::test::get_object_assert minions '{{.kind}}' 'List'
|
kube::test::get_object_assert minions '{{.kind}}' 'List'
|
||||||
|
|
||||||
|
kube::test::describe_object_assert minions "127.0.0.1" "Name:" "Conditions:" "Addresses:" "Capacity:" "Pods:"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
kube::test::clear_all
|
kube::test::clear_all
|
||||||
|
@ -46,7 +46,7 @@ func DescriberFor(kind string, c *client.Client) (Describer, bool) {
|
|||||||
case "Service":
|
case "Service":
|
||||||
return &ServiceDescriber{c}, true
|
return &ServiceDescriber{c}, true
|
||||||
case "Minion", "Node":
|
case "Minion", "Node":
|
||||||
return &MinionDescriber{c}, true
|
return &NodeDescriber{c}, true
|
||||||
case "LimitRange":
|
case "LimitRange":
|
||||||
return &LimitRangeDescriber{c}, true
|
return &LimitRangeDescriber{c}, true
|
||||||
case "ResourceQuota":
|
case "ResourceQuota":
|
||||||
@ -283,14 +283,14 @@ func (d *ServiceDescriber) Describe(namespace, name string) (string, error) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// MinionDescriber generates information about a minion.
|
// NodeDescriber generates information about a node.
|
||||||
type MinionDescriber struct {
|
type NodeDescriber struct {
|
||||||
client.Interface
|
client.Interface
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *MinionDescriber) Describe(namespace, name string) (string, error) {
|
func (d *NodeDescriber) Describe(namespace, name string) (string, error) {
|
||||||
mc := d.Nodes()
|
mc := d.Nodes()
|
||||||
minion, err := mc.Get(name)
|
node, err := mc.Get(name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
@ -307,13 +307,13 @@ func (d *MinionDescriber) Describe(namespace, name string) (string, error) {
|
|||||||
pods = append(pods, pod)
|
pods = append(pods, pod)
|
||||||
}
|
}
|
||||||
|
|
||||||
events, _ := d.Events(namespace).Search(minion)
|
events, _ := d.Events(namespace).Search(node)
|
||||||
|
|
||||||
return tabbedString(func(out io.Writer) error {
|
return tabbedString(func(out io.Writer) error {
|
||||||
fmt.Fprintf(out, "Name:\t%s\n", minion.Name)
|
fmt.Fprintf(out, "Name:\t%s\n", node.Name)
|
||||||
if len(minion.Status.Conditions) > 0 {
|
if len(node.Status.Conditions) > 0 {
|
||||||
fmt.Fprint(out, "Conditions:\n Type\tStatus\tLastProbeTime\tLastTransitionTime\tReason\tMessage\n")
|
fmt.Fprint(out, "Conditions:\n Type\tStatus\tLastProbeTime\tLastTransitionTime\tReason\tMessage\n")
|
||||||
for _, c := range minion.Status.Conditions {
|
for _, c := range node.Status.Conditions {
|
||||||
fmt.Fprintf(out, " %v \t%v \t%s \t%s \t%v \t%v\n",
|
fmt.Fprintf(out, " %v \t%v \t%s \t%s \t%v \t%v\n",
|
||||||
c.Type,
|
c.Type,
|
||||||
c.Status,
|
c.Status,
|
||||||
@ -323,12 +323,23 @@ func (d *MinionDescriber) Describe(namespace, name string) (string, error) {
|
|||||||
c.Message)
|
c.Message)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if len(minion.Spec.Capacity) > 0 {
|
var addresses []string
|
||||||
|
for _, address := range node.Status.Addresses {
|
||||||
|
addresses = append(addresses, address.Address)
|
||||||
|
}
|
||||||
|
fmt.Fprintf(out, "Addresses:\t%s\n", strings.Join(addresses, ","))
|
||||||
|
if len(node.Spec.Capacity) > 0 {
|
||||||
fmt.Fprintf(out, "Capacity:\n")
|
fmt.Fprintf(out, "Capacity:\n")
|
||||||
for resource, value := range minion.Spec.Capacity {
|
for resource, value := range node.Spec.Capacity {
|
||||||
fmt.Fprintf(out, " %s:\t%s\n", resource, value.String())
|
fmt.Fprintf(out, " %s:\t%s\n", resource, value.String())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if len(node.Spec.PodCIDR) > 0 {
|
||||||
|
fmt.Fprintf(out, "PodCIDR:\t%s\n", node.Spec.PodCIDR)
|
||||||
|
}
|
||||||
|
if len(node.Spec.ExternalID) > 0 {
|
||||||
|
fmt.Fprintf(out, "ExternalID:\t%s\n", node.Spec.ExternalID)
|
||||||
|
}
|
||||||
fmt.Fprintf(out, "Pods:\t(%d in total)\n", len(pods))
|
fmt.Fprintf(out, "Pods:\t(%d in total)\n", len(pods))
|
||||||
for _, pod := range pods {
|
for _, pod := range pods {
|
||||||
if pod.Status.Host != name {
|
if pod.Status.Host != name {
|
||||||
|
Loading…
Reference in New Issue
Block a user