The Python kubernetes module provides two methods for listing secrets:
list_namespaced_secretlist_secret_for_all_namespaces
I want to list the secrets for the namespace in which a container is running.
The list_secret_all_for_namespaces method isn't appropriate because it attempts to list secrets at the cluster scope, and I don't need or want that level of access.
The list_namespaced_secret method requires an explicit namespace name. I can provide that as an argument to my Python code...
apiVersion: v1
kind: Pod
metadata:
name: example
namespace: my-sandbox
spec:
containers:
- command:
- /path/to/my-python-code.py
arguments:
- my-sandbox
...but that's clumsy, because it means the pod manifest needs to be modified every time it's deployed to a new namespace.
Is there a way to acquire the current namespace name via the API?