I would like to access the OpenShift and Kubernetes API from within the module to query and modify objects in the application to which the module belongs.
In the documentation ( https://docs.openshift.org/latest/dev_guide/service_accounts.html ) I found this description on how to access the api:
$ TOKEN="$(cat /var/run/secrets/kubernetes.io/serviceaccount/token)" $ curl --cacert /var/run/secrets/kubernetes.io/serviceaccount/ca.crt \ "https://openshift.default.svc.cluster.local/oapi/v1/users/~" \ -H "Authorization: Bearer $TOKEN"
The problem is that when I, for example, want to access the module, I need to know the namespace in which I am located:
https://openshift.default.svc.cluster.local/oapi/v1/namespaces/${namespace}/pods
The only way I've found so far is to represent the namespace as an environment variable, but I would not want the user to enter this information.
source share