---
title: KS8 Info
slug: homologacao-atmosphere/ks8-info
description: Learn about the parameters, examples, and returned values of the Kubernetes (K8s) module in this comprehensive document. Discover how to manipulate object types, apply label and field selectors, and retrieve existing service objects and pods. Gain insight
createdAt: 2022-12-14T19:19:54.000Z
---

## Resumo

- Descrever objetos do Kubernetes (K8s).

## Parâmetros

| **Parâmetro**                      | **Tipo** | **Escolhas \| Valor Padrão** | **Comentários**                                                                                                                                                                                                                                                                                                                                                                 |
| ---------------------------------- | -------- | ---------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| kind                               | string   |                              | - Use para especificar um modelo de objeto<br />- Use para criar, excluir ou descobrir um objeto sem fornecer uma definição de recurso completa<br />- Use em conjunto com I(api\_version), I(name) e I(namespace) para identificar um objeto específico.<br />- Se I(definição de recurso) for fornecido, o valor I(tipo) de I(definição\_de\_recurso) substituirá esta opção. |
| label\_selectors                   | list     | **                           | Lista de seletores de rótulos a serem usados ​​para filtrar resultados.                                                                                                                                                                                                                                                                                                         |
| field\_selectors                   | list     |                              | Lista de seletores de campo a serem usados ​​para filtrar resultados.                                                                                                                                                                                                                                                                                                           |

Utiliza parâmetros dos módulos k8s auth options, k8s name options, k8s wait options.

## Exemplos

```yaml
- name: Get an existing Service object
  k8s_info:
    api_version: v1
    kind: Service
    name: web
    namespace: testing
  register: web_service
  
- name: Get a list of all service objects
  k8s_info:
    api_version: v1
    kind: Service
    namespace: testing
  register: service_list

- name: Get a list of all pods from any namespace
  k8s_info:
    kind: Pod
  register: pod_list

- name: Search for all Pods labelled app=web
  k8s_info:
    kind: Pod
    label_selectors:
      - app = web
      - tier in (dev, test)

- name: Using vars while using label_selectors
  k8s_info:
    kind: Pod
    label_selectors:
      - "app = {{ app_label_web }}"
  vars:
    app_label_web: web

- name: Search for all running pods
  k8s_info:
    kind: Pod
    field_selectors:
      - status.phase=Running

- name: List custom objects created using CRD
  k8s_info:
    kind: MyCustomObject
    api_version: "stable.example.com/v1"

- name: Wait till the Object is created
  k8s_info:
    kind: Pod
    wait: yes
    name: pod-not-yet-created
    namespace: default
    wait_sleep: 10
    wait_timeout: 360
```

## Valores retornados

| **Chave**  | **Tipo** | **Retornado quando** | **Descrição**                                                                                                   |
| ---------- | -------- | -------------------- | --------------------------------------------------------------------------------------------------------------- |
| api\_found | boolean  | sempre               | Se a api\_version e o tipo especificados foram mapeados com êxito para uma API existente no cluster de destino. |
| resources  | string   | sucesso              | O objeto existente                                                                                              |



## Valores retornados subcampos de Resources

| **Chave**    | **Tipo** | **Retornado quando** | **Descrição**                                                                        |
| ------------ | -------- | -------------------- | ------------------------------------------------------------------------------------ |
| api\_version | boolean  | sucesso              | O esquema versionado desta representação de um objeto                                |
| kind         | string   | sucesso              | Representa o recurso REST que este objeto representa                                 |
| metadata     | dict     | sucesso              | Metadados de objeto padrão. Inclui nome, namespace, anotações, rótulos, etc.         |
| spec         | dict     | sucesso              | Atributos específicos do objeto. Irá variar de acordo com I(api\_version) e I(kind). |
| status       | dict     | sucesso              | Detalhes do status atual do objeto                                                   |

