Merge pull request #111192 from aufarg/add-serviceaccount-to-describe
Print ServiceAccount attached to the Pod Kubernetes-commit: 9a8b4ab2402655162d1b51dbb7f228c6fe690949
This commit is contained in:
commit
27f9f75ef1
4
go.mod
4
go.mod
|
@ -33,7 +33,7 @@ require (
|
|||
k8s.io/api v0.0.0-20220722161209-f77fa25e8904
|
||||
k8s.io/apimachinery v0.0.0-20220722160307-915d89afb4cb
|
||||
k8s.io/cli-runtime v0.0.0-20220722175031-be601c12109c
|
||||
k8s.io/client-go v0.0.0-20220722162231-4db4856058cc
|
||||
k8s.io/client-go v0.0.0-20220722162234-b2097e607c19
|
||||
k8s.io/component-base v0.0.0-20220722164051-d68b4289d0d7
|
||||
k8s.io/component-helpers v0.0.0-20220722164708-7cd6476d8900
|
||||
k8s.io/klog/v2 v2.70.1
|
||||
|
@ -97,7 +97,7 @@ replace (
|
|||
k8s.io/api => k8s.io/api v0.0.0-20220722161209-f77fa25e8904
|
||||
k8s.io/apimachinery => k8s.io/apimachinery v0.0.0-20220722160307-915d89afb4cb
|
||||
k8s.io/cli-runtime => k8s.io/cli-runtime v0.0.0-20220722175031-be601c12109c
|
||||
k8s.io/client-go => k8s.io/client-go v0.0.0-20220722162231-4db4856058cc
|
||||
k8s.io/client-go => k8s.io/client-go v0.0.0-20220722162234-b2097e607c19
|
||||
k8s.io/code-generator => k8s.io/code-generator v0.0.0-20220719123406-a08f67b4c688
|
||||
k8s.io/component-base => k8s.io/component-base v0.0.0-20220722164051-d68b4289d0d7
|
||||
k8s.io/component-helpers => k8s.io/component-helpers v0.0.0-20220722164708-7cd6476d8900
|
||||
|
|
4
go.sum
4
go.sum
|
@ -747,8 +747,8 @@ k8s.io/apimachinery v0.0.0-20220722160307-915d89afb4cb h1:CkEjGDsYVgTZod3JtHw5+t
|
|||
k8s.io/apimachinery v0.0.0-20220722160307-915d89afb4cb/go.mod h1:E6C2QnwpsJTXktTwPqd4nAJ/xmsdi1AHqDD0iPB61j0=
|
||||
k8s.io/cli-runtime v0.0.0-20220722175031-be601c12109c h1:3Pt53df9gpA8ag85fLTsSyk9iGuHkwECtnaRW6qD+UM=
|
||||
k8s.io/cli-runtime v0.0.0-20220722175031-be601c12109c/go.mod h1:po7EOvUazqFFYOb4kOhPOiXcSZJWCYiJB02p7D7Woi8=
|
||||
k8s.io/client-go v0.0.0-20220722162231-4db4856058cc h1:3mrn9B1x+4hTiKqQ3yz1Q6ojGJTwQtGE9aPvWL2kYFk=
|
||||
k8s.io/client-go v0.0.0-20220722162231-4db4856058cc/go.mod h1:3zUxVad6vwmBCMeqE4RAlOrAuioKG3MQgO6Zl4PJwqo=
|
||||
k8s.io/client-go v0.0.0-20220722162234-b2097e607c19 h1:MlhjUMLx4h1NsbY/bO3noaY+s6Wtt21SpqNrKZDDHfo=
|
||||
k8s.io/client-go v0.0.0-20220722162234-b2097e607c19/go.mod h1:7TyeX2vy8G+EisTteawMgmRjEf47thI1Qgfa93IkyQA=
|
||||
k8s.io/component-base v0.0.0-20220722164051-d68b4289d0d7 h1:RpWbFycy+h6+lA57wCIP4GAntYp1YXQ6BibP4Db20mQ=
|
||||
k8s.io/component-base v0.0.0-20220722164051-d68b4289d0d7/go.mod h1:MKzPOLrISkhaw9g2iJytMZf0obKe8Z/P7IVIotfVbeA=
|
||||
k8s.io/component-helpers v0.0.0-20220722164708-7cd6476d8900 h1:lZRiZ42GZuXZfPXa5A+Vbed4mr00HiH4H1Spmq8zraI=
|
||||
|
|
|
@ -769,6 +769,9 @@ func describePod(pod *corev1.Pod, events *corev1.EventList) (string, error) {
|
|||
if pod.Spec.RuntimeClassName != nil && len(*pod.Spec.RuntimeClassName) > 0 {
|
||||
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 == "" {
|
||||
w.Write(LEVEL_0, "Node:\t<none>\n")
|
||||
} 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) {
|
||||
fake := fake.NewSimpleClientset(&corev1.Pod{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
|
|
Loading…
Reference in New Issue