This action requires a Kubernetes service account token.

GetKubernetesResource — retrieves a resource from a Kubernetes cluster.

Request example

group: managed-services.deckhouse.io
version: v1alpha1
resource_type: postgres
resource_name: example-postgres
namespace: default
ignore_not_found: true

Request specification

NameRequiredDescriptionPossible values
groupYesAPI group of the resource. Specifies the API group to which the requested object belongsDetermining the required Group and Version
versionYesAPI version of the resourceDetermining the required Group and Version
resource_typeYesType of resource to retrieve-
resource_nameYesName of the resource to retrieve-
namespaceYesNamespace containing the resource-
ignore_not_foundNoIf true, a missing object is not treated as an error. Defaults to falsetrue, false

Response

On success, the action returns the found flag and the object in the resource field. If the object is not found and ignore_not_found is not enabled, the action fails with an error. With ignore_not_found: true, the action succeeds with found: false and without the resource field.

NameDescription
foundtrue if the object is found
resourceResource object in Kubernetes format

Determining the required Group and Version

Each resource type has its own API group (Group) and version (Version). A complete list of API resources, groups, and versions is available in the Kubernetes documentation.

If you do not know which API groups and versions are required, you can look up the current values. There are several ways to determine them:

Using the d8 k utility

The d8 k explain command shows the apiVersion for a resource.

Example:

d8 k explain deployment

Example output:

GROUP:      apps
KIND:       Deployment
VERSION:    v1

DESCRIPTION:
    Deployment enables declarative updates for Pods and ReplicaSets.
    
FIELDS:
...

Using the documentation

  1. Find the resource you need (for example, Deployment).

  2. Find the API group and version in the header. For example, for Deployment:

    apiVersion: apps/v1

    Here:

    • API Group is apps;
    • Version is v1.