kubernetes – Manage Kubernetes resources — Ansible Documentation

- AnsibleFest
- Products
- Community
- Webinars & Training
- Blog

Documentation

# kubernetes – Manage Kubernetes resources

New in version 2.1.

- DEPRECATED
- Synopsis
- Parameters
- Examples
- Return Values
- Status

## DEPRECATED

Removed in Ansible:
| version: 2.9
Why: | This module used the oc command line tool, where as k8s_raw goes over the REST API.
Alternative: | Use k8s_raw instead.

## Synopsis

- This module can manage Kubernetes resources on an existing cluster using the Kubernetes server API. Users can specify in-line API data, or specify an existing Kubernetes YAML file.
- Currently, this module (1) Only supports HTTP Basic Auth (2) Only supports ‘strategic merge’ for update, http://goo.gl/fCPYxT SSL certs are not working, use `validate_certs=off` to disable.

## Parameters

Parameter | Choices/Defaults | Comments
--- | --- | ---
api_endpoint - / required |  | The IPv4 API endpoint of the Kubernetes cluster. aliases: endpoint
certificate_authority_data - |  | Certificate Authority data for Kubernetes server. Should be in either standard PEM format or base64 encoded PEM data. Note that certificate verification is broken until ansible supports a version of 'match_hostname' that can match the IP address against the CA data.
file_reference - |  | Specify full path to a Kubernets YAML file to send to API endpoint. This option is mutually exclusive with `'inline_data'`.
inline_data - / required |  | The Kubernetes YAML data to send to the API endpoint. This option is mutually exclusive with `'file_reference'`.
insecure - |  | Reverts the connection to using HTTP instead of HTTPS. This option should only be used when execuing the 'kubernetes' module local to the Kubernetes cluster using the insecure local port (locahost:8080 by default).
patch_operation - added in 2.4 | Choices: JSON Patch Merge Patch Strategic Merge Patch ← | Specify patch operation for Kubernetes resource update. For details, see the description of PATCH operations at https://github.com/kubernetes/kubernetes/blob/release-1.5/docs/devel/api-conventions.md#patch-operations. aliases: patch_strategy
state - / required | Choices: absent present ← replace update | The desired action to take on the Kubernetes data.
url_password - |  | The HTTP Basic Auth password for the API endpoint. This should be set unless using the `'insecure'` option. aliases: password
url_username - | Default: "admin" | The HTTP Basic Auth username for the API endpoint. This should be set unless using the `'insecure'` option. aliases: username
validate_certs boolean | Choices: no ← yes | Enable/disable certificate validation. Note that this is set to `false` until Ansible can support IP address based certificate hostname matching (exists in >= python3.5.0).

## Examples

    # Create a new namespace with in-line YAML.
    - name: Create a kubernetes namespace
      kubernetes:
        api_endpoint: 123.45.67.89
        url_username: admin
        url_password: redacted
        inline_data:
          kind: Namespace
          apiVersion: v1
          metadata:
            name: ansible-test
            labels:
              label_env: production
              label_ver: latest
            annotations:
              a1: value1
              a2: value2
        state: present

    # Create a new namespace from a YAML file.
    - name: Create a kubernetes namespace
      kubernetes:
        api_endpoint: 123.45.67.89
        url_username: admin
        url_password: redacted
        file_reference: /path/to/create_namespace.yaml
        state: present

    # Do the same thing, but using the insecure localhost port
    - name: Create a kubernetes namespace
      kubernetes:
        api_endpoint: 123.45.67.89
        insecure: true
        file_reference: /path/to/create_namespace.yaml
        state: present

## Return Values

Common return values are documented here, the following are the fields unique to this module:

Key | Returned | Description
--- | --- | ---
api_response complex | success | Raw response from Kubernetes API, content varies with API.
| apiVersion - |  |
| kind - |  |
| metadata - |  |
| spec - |  |
| status - |  |

## Status

- This module will be removed in version 2.9. [deprecated]
- For more information see DEPRECATED.

### Authors

- Eric Johnson (@erjohnso) <erjohnso@google.com>

Hint

If you notice any issues in this documentation you can edit this document to improve it.