I want to know who create pod from kubectl get or describe command. Can I insert this field into Pod? or Custom Resource Definition? Please help.
when I access to kubernetes cluster as user 'Alice' and create pod 'sample-pod' I want to see as follows when exec 'kubectl get pod sample-pod' command.
NAME READY STATUS RESTARTS AGE CREATEUSER
sample-pod 1/1 Running 0 10s Alice
kubectl get pods -n -o yaml will give the pod definition. you can edit and use it for deploying pods.
I assume that the information about authenticated Kubernetes users is not included in the general API reference list for Pod core schema objects. Therefore, it's not possible to retrieve user data from Pod specification. Actually, you might try to use Service accounts that granted to manage Kubernetes API via RBAC mechanism, in that way you can create a particular SA in namespace related to a specific user, and use it for any resource Kubernetes creation purpose. Although the information about SA name for specific resource propagated through .spec.serviceAccountName
field in relevant object configuration template, you can invoke it using custom-columns=
option in kubectl get
command:
kubectl get pods -o custom-columns=NAME:.metadata.name,SERVICE_ACCOUNT:.spec.serviceAccountName