How To: List the Deployments for a Kubernetes Cluster
  • 04 Sep 2024
  • 1 Minute to read
  • Contributors
  • Dark
    Light

How To: List the Deployments for a Kubernetes Cluster

  • Dark
    Light

Article summary

After deploying the RealTheory collector to a Kubernetes cluster (See Installing RealTheory in a Cluster), the cluster and its associated objects become available in the RealTheory API within minutes.

Get Deployments

To get the list of available deployments for a given cluster and namespace, call the method below on the K8sSummary endpoint.

GET <endpoint>/theory/api/v1/k8ssummary/deploymentsummaries/search/query/{query}?index={index}&count={count}&order={order}&direction={direction}

where

  • {endpoint} - is the URL of the RealTheory SaaS portal for your account.
  • {query} - is a query used to limit the results to deployments within a given namespace and cluster.
  • {index} - is the starting index of the deployment summaries to include in the list. This parameter is optional and defaults to 0 if not specified.
  • {count} - is maximum number of deployment summaries to return. This parameter is optional and defaults to 100 if not specified.
  • {order} - is a string containing the name of the attribute to sort on. This parameter is optional.
  • {direction} - is a number that controls the direction of the sort. A value equal to or greater than 0 indicates ascending order; a value less than 0 indicates descending order. This parameter is optional and defaults to 0 if not specified.

Note: All calls to RealTheory APIs must be authenticated and authorized. See Authentication for more details.

Example

GET theory/api/v1/k8ssummary/deploymentsummaries/search/query/metadata.clusterName=realtheory-cluster-01 and metadata.namespaceName=real-theory-example?index=0&count=100&order=metadata.name&direction=0

which returns a list of the first 100 deployment summaries associated with namespace realtheory-example on cluster realtheory-cluster-01, sorted by name in ascending order.

Notes:

  • A deployment summary is an object that summarizes key information related to a Kubernetes Deployment.
  • The query should be URL encoded; otherwise the request might be rejected.

Output

[
  {
    "metadata": {
      "id": "6901a5a3-7442-4045-9242-c4281fb43492",
      "name": "cart-service",
      "clusterId": "f99e055f-b35d-208b-63b1-f4222b80151a",
      "clusterName": "realtheory-cluster-01",
      "namespaceId": "53214960-fda3-4089-9e12-a7f476317352",
       "namespaceName": "realtheory-example",
      "owners": null,
      "timestamp": "2024-03-06T20:17:25.0471704Z"
    },
    ...
  },
  {
    "metadata": {
      "id": "a35c1d00-1ce3-46c5-b665-e2ccec8b1212",
      "name": "shipping-service",
      "clusterId": "f99e055f-b35d-208b-63b1-f4222b80151a",
      "clusterName": "realtheory-cluster-01",
      "namespaceId": "53214960-fda3-4089-9e12-a7f476317352",
      "namespaceName": "realtheory-example",
      "owners": null,
      "timestamp": "2024-03-06T20:16:24.2065431Z"
    },
    ...
  },
  ...
]
  

Note: Content has been omitted from the JSON response above for brevity.


Was this article helpful?