mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-03 09:22:44 +00:00
Display controllers along with type when describing a pod
There're more controllers than replication controller, the patch displays annotation item with key "kuberntetes.io/created-by" in the form of "Controllers: type/name".
This commit is contained in:
parent
47b15c8896
commit
29a0fe9032
@ -276,9 +276,9 @@ runTests() {
|
|||||||
kube::test::get_object_jsonpath_assert 'pod/valid-pod' "{$id_field}" 'valid-pod'
|
kube::test::get_object_jsonpath_assert 'pod/valid-pod' "{$id_field}" 'valid-pod'
|
||||||
kube::test::get_object_jsonpath_assert 'pods/valid-pod' "{$id_field}" 'valid-pod'
|
kube::test::get_object_jsonpath_assert 'pods/valid-pod' "{$id_field}" 'valid-pod'
|
||||||
# Describe command should print detailed information
|
# Describe command should print detailed information
|
||||||
kube::test::describe_object_assert pods 'valid-pod' "Name:" "Image(s):" "Node:" "Labels:" "Status:" "Replication Controllers"
|
kube::test::describe_object_assert pods 'valid-pod' "Name:" "Image(s):" "Node:" "Labels:" "Status:" "Controllers"
|
||||||
# Describe command (resource only) should print detailed information
|
# Describe command (resource only) should print detailed information
|
||||||
kube::test::describe_resource_assert pods "Name:" "Image(s):" "Node:" "Labels:" "Status:" "Replication Controllers"
|
kube::test::describe_resource_assert pods "Name:" "Image(s):" "Node:" "Labels:" "Status:" "Controllers"
|
||||||
|
|
||||||
### Dump current valid-pod POD
|
### Dump current valid-pod POD
|
||||||
output_pod=$(kubectl get pod valid-pod -o yaml --output-version=v1 "${kube_flags[@]}")
|
output_pod=$(kubectl get pod valid-pod -o yaml --output-version=v1 "${kube_flags[@]}")
|
||||||
|
@ -18,6 +18,7 @@ package kubectl
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"reflect"
|
"reflect"
|
||||||
@ -483,7 +484,7 @@ func describePod(pod *api.Pod, rcs []api.ReplicationController, events *api.Even
|
|||||||
for _, rc := range rcs {
|
for _, rc := range rcs {
|
||||||
matchingRCs = append(matchingRCs, &rc)
|
matchingRCs = append(matchingRCs, &rc)
|
||||||
}
|
}
|
||||||
fmt.Fprintf(out, "Replication Controllers:\t%s\n", printReplicationControllersByLabels(matchingRCs))
|
fmt.Fprintf(out, "Controllers:\t%s\n", printControllers(pod.Annotations))
|
||||||
fmt.Fprintf(out, "Containers:\n")
|
fmt.Fprintf(out, "Containers:\n")
|
||||||
describeContainers(pod, out)
|
describeContainers(pod, out)
|
||||||
if len(pod.Status.Conditions) > 0 {
|
if len(pod.Status.Conditions) > 0 {
|
||||||
@ -502,6 +503,18 @@ func describePod(pod *api.Pod, rcs []api.ReplicationController, events *api.Even
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func printControllers(annotation map[string]string) string {
|
||||||
|
value, ok := annotation["kubernetes.io/created-by"]
|
||||||
|
if ok {
|
||||||
|
var r api.SerializedReference
|
||||||
|
err := json.Unmarshal([]byte(value), &r)
|
||||||
|
if err == nil {
|
||||||
|
return fmt.Sprintf("%s/%s", r.Reference.Kind, r.Reference.Name)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return "<none>"
|
||||||
|
}
|
||||||
|
|
||||||
func describeVolumes(volumes []api.Volume, out io.Writer) {
|
func describeVolumes(volumes []api.Volume, out io.Writer) {
|
||||||
if volumes == nil || len(volumes) == 0 {
|
if volumes == nil || len(volumes) == 0 {
|
||||||
fmt.Fprint(out, "No volumes.\n")
|
fmt.Fprint(out, "No volumes.\n")
|
||||||
|
@ -505,7 +505,7 @@ var _ = Describe("Kubectl client", func() {
|
|||||||
{"Reason:"},
|
{"Reason:"},
|
||||||
{"Message:"},
|
{"Message:"},
|
||||||
{"IP:"},
|
{"IP:"},
|
||||||
{"Replication Controllers:", "redis-master"}}
|
{"Controllers:", "ReplicationController/redis-master"}}
|
||||||
checkOutput(output, requiredStrings)
|
checkOutput(output, requiredStrings)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user