mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-29 22:46:12 +00:00
Merge pull request #16422 from hurf/created_by
Display controllers along with type when describing a pod
This commit is contained in:
commit
f15b2e32a7
@ -283,9 +283,9 @@ runTests() {
|
||||
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'
|
||||
# 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
|
||||
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
|
||||
output_pod=$(kubectl get pod valid-pod -o yaml --output-version=v1 "${kube_flags[@]}")
|
||||
|
@ -18,6 +18,7 @@ package kubectl
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
"reflect"
|
||||
@ -476,7 +477,7 @@ func describePod(pod *api.Pod, rcs []api.ReplicationController, events *api.Even
|
||||
for _, rc := range rcs {
|
||||
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")
|
||||
describeContainers(pod, out)
|
||||
if len(pod.Status.Conditions) > 0 {
|
||||
@ -495,6 +496,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) {
|
||||
if volumes == nil || len(volumes) == 0 {
|
||||
fmt.Fprint(out, "No volumes.\n")
|
||||
|
@ -497,7 +497,7 @@ var _ = Describe("Kubectl client", func() {
|
||||
{"Reason:"},
|
||||
{"Message:"},
|
||||
{"IP:"},
|
||||
{"Replication Controllers:", "redis-master"}}
|
||||
{"Controllers:", "ReplicationController/redis-master"}}
|
||||
checkOutput(output, requiredStrings)
|
||||
})
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user