I am doing some recon work on projects in our openshift cluster and I am looking for an easy way to get all the Projects in a certain group.
I know there is an openshift API that has access to certain openshift artifacts:
For example I could make an API call to the openshift cluster like this:
/oapi/v1/projects/{name}
To get a project of a specific name. Is there a way to then get all the deployments for that project... Something like this:
/oapi/v1/projects/{name}/deployments
So I could know what deployments are in a certain environment in our openshift cluster.
Any thoughts on this would be great.
OCP"Projects"
being a superset or "encapsulation" of k8s"Namespaces"
, you can list the deployments of a specific"Project/Namespace"
with this API:
GET /apis/apps/v1/namespaces/{namespace}/deployments
Of course you need the correct autorizations to be able to list such objects as explained in the following docs
Reference: https://kubernetes.io/docs/reference/kubernetes-api/workload-resources/deployment-v1/#http-request-2
OCP API Reference: https://docs.okd.io/latest/rest_api/index.html K8S API Reference: https://kubernetes.io/docs/reference/kubernetes-api/