Who has created a Namespace?

6/10/2021

I have a scenario where multiple namespaces are created and I want to identify who has created and want to notify the user to delete the same. But in k8s I dont see an option to understand who has created it. Do we have any option to identify the user.

-- Vrushali
kubernetes
openshift

3 Answers

6/10/2021

I am not an Openshift master, however the first thing I though about was some Audit logs, that was already suggest you immediately in comments. Quick search showed this: Openshift Viewing audit logs:

Audit provides a security-relevant chronological set of records documenting the sequence of activities that have affected the system by individual users, administrators, or other components of the system.

Audit works at the API server level, logging all requests coming to the server. Each audit log contains the following information:

enter image description here

Also may help:

-- Vit
Source: StackOverflow

6/10/2021

case 1: if you are using managed K8S then you should be able to see those logs under cloud-watch( if not configured else where) just for reference: https://docs.aws.amazon.com/eks/latest/userguide/control-plane-logs.html

case 2: if you are using the standalone K8S cluster by default its not there you have different option to configure. if you have configured then all system logs can be stored and audit. Ref: https://docs.aws.amazon.com/eks/latest/userguide/control-plane-logs.html

-- Vinod
Source: StackOverflow

6/10/2021

Not a direct answer to your question, but in OpenShift, creating aProject"triggers the creation of a"Namespace". So you may chase after who created the"Project"

You can also configure OpenShift to restrict the creation of"Projects"as described in the doc: https://docs.openshift.com/container-platform/4.7/applications/projects/configuring-project-creation.html

-- titou10
Source: StackOverflow