mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-22 19:31:44 +00:00
Merge pull request #111192 from aufarg/add-serviceaccount-to-describe
Print ServiceAccount attached to the Pod
This commit is contained in:
commit
9a8b4ab240
@ -769,6 +769,9 @@ func describePod(pod *corev1.Pod, events *corev1.EventList) (string, error) {
|
|||||||
if pod.Spec.RuntimeClassName != nil && len(*pod.Spec.RuntimeClassName) > 0 {
|
if pod.Spec.RuntimeClassName != nil && len(*pod.Spec.RuntimeClassName) > 0 {
|
||||||
w.Write(LEVEL_0, "Runtime Class Name:\t%s\n", *pod.Spec.RuntimeClassName)
|
w.Write(LEVEL_0, "Runtime Class Name:\t%s\n", *pod.Spec.RuntimeClassName)
|
||||||
}
|
}
|
||||||
|
if len(pod.Spec.ServiceAccountName) > 0 {
|
||||||
|
w.Write(LEVEL_0, "Service Account:\t%s\n", pod.Spec.ServiceAccountName)
|
||||||
|
}
|
||||||
if pod.Spec.NodeName == "" {
|
if pod.Spec.NodeName == "" {
|
||||||
w.Write(LEVEL_0, "Node:\t<none>\n")
|
w.Write(LEVEL_0, "Node:\t<none>\n")
|
||||||
} else {
|
} else {
|
||||||
|
@ -102,6 +102,30 @@ func TestDescribePod(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestDescribePodServiceAccount(t *testing.T) {
|
||||||
|
fake := fake.NewSimpleClientset(&corev1.Pod{
|
||||||
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
|
Name: "bar",
|
||||||
|
Namespace: "foo",
|
||||||
|
},
|
||||||
|
Spec: corev1.PodSpec{
|
||||||
|
ServiceAccountName: "fooaccount",
|
||||||
|
},
|
||||||
|
})
|
||||||
|
c := &describeClient{T: t, Namespace: "foo", Interface: fake}
|
||||||
|
d := PodDescriber{c}
|
||||||
|
out, err := d.Describe("foo", "bar", DescriberSettings{ShowEvents: true})
|
||||||
|
if err != nil {
|
||||||
|
t.Errorf("unexpected error: %v", err)
|
||||||
|
}
|
||||||
|
if !strings.Contains(out, "Service Account:") {
|
||||||
|
t.Errorf("unexpected out: %s", out)
|
||||||
|
}
|
||||||
|
if !strings.Contains(out, "fooaccount") {
|
||||||
|
t.Errorf("unexpected out: %s", out)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestDescribePodEphemeralContainers(t *testing.T) {
|
func TestDescribePodEphemeralContainers(t *testing.T) {
|
||||||
fake := fake.NewSimpleClientset(&corev1.Pod{
|
fake := fake.NewSimpleClientset(&corev1.Pod{
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
|
Loading…
Reference in New Issue
Block a user