Bootstrap FreeKB - OpenShift - List deployments using REST API
OpenShift - List deployments using REST API

Updated:   |  OpenShift articles

An image contains the code used to create a deployment. Then, a deployment can be created from an image, which should then create a replica set (which is the number of pods that should be created), and then the pods should be created.

This assumes you have used the REST API to obtain an OAuth bearer token. Let's say the bearer token is sha256~0Rs__hPuXmBD3TJTXNDisC7wRBN-nrFnYTxgdBrFT-U.

Here is how you would list the deployments in my-project using curl.

curl
--insecure
--request GET
--header "Accept: application/json"
--header "Authorization: Bearer sha256~0Rs__hPuXmBD3TJTXNDisC7wRBN-nrFnYTxgdBrFT-U"
--url "https://api.openshift.example.com:6443/apis/apps/v1/namespaces/my-project/deployments"

 

If the items array contains key value pairs, this means the namespace contains one or more deployments.

{
  "kind": "DeploymentList",
  "apiVersion": "apps/v1",
  "metadata": {
    "selfLink": "/apis/apps/v1/namespaces/my-project/deployments",
    "resourceVersion": "708878925"
  },
  "items": [
    {
      "metadata": {
        "name": "my-deployment",
        "namespace": "my-project",
        "selfLink": "/apis/apps/v1/namespaces/my-project/deployments/my-deployment",
        "uid": "7709e73e-3936-467c-86d6-5af3b01ca106",
        "resourceVersion": "696422824",
        "generation": 1,
        "creationTimestamp": "2021-12-17T18:55:58Z"
      }
    }
   ]
  }
}

 

You can list a single deployment by including the name of the deployment.

curl
--insecure
--request GET
--header "Accept: application/json"
--header "Authorization: Bearer sha256~0Rs__hPuXmBD3TJTXNDisC7wRBN-nrFnYTxgdBrFT-U"
--url "https://api.openshift.example.com:6443/apis/apps/v1/namespaces/my-project/deployments/my-deployment"

 




Did you find this article helpful?

If so, consider buying me a coffee over at Buy Me A Coffee



Comments


Add a Comment


Please enter 122cdd in the box below so that we can be sure you are a human.