ansible.builtin.kubernetes (v2.3.3.0-1) — module

Manage Kubernetes resources.

| "added in version" 2.1 of ansible.builtin"

Authors: Eric Johnson (@erjohnso) <erjohnso@google.com>

preview | supported by community

Install Ansible via pip

Install with pip install ansible==2.3.3.0.post1

Description

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, Only supports HTTP Basic Auth Only supports 'strategic merge' for update, http://goo.gl/fCPYxT SSL certs are not working, use 'validate_certs=off' to disable

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
# 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
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
# 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
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
# 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

Inputs

    
state:
    choices:
    - present
    - absent
    - update
    - replace
    default: present
    description:
    - The desired action to take on the Kubernetes data.
    required: true

insecure:
    description:
    - Reverts the connection to using HTTP instead of HTTPS. This option should only be
      used when execuing the M('kubernetes') module local to the Kubernetes cluster using
      the insecure local port (locahost:8080 by default).

inline_data:
    default: null
    description:
    - The Kubernetes YAML data to send to the API I(endpoint). This option is mutually
      exclusive with C('file_reference').
    required: true

api_endpoint:
    aliases:
    - endpoint
    default: null
    description:
    - The IPv4 API endpoint of the Kubernetes cluster.
    required: true

url_password:
    aliases:
    - password
    default: null
    description:
    - The HTTP Basic Auth password for the API I(endpoint). This should be set unless
      using the C('insecure') option.

url_username:
    aliases:
    - username
    default: admin
    description:
    - The HTTP Basic Auth username for the API I(endpoint). This should be set unless
      using the C('insecure') option.

file_reference:
    default: null
    description:
    - Specify full path to a Kubernets YAML file to send to API I(endpoint). This option
      is mutually exclusive with C('inline_data').
    required: false

validate_certs:
    default: false
    description:
    - Enable/disable certificate validation. Note that this is set to C(false) until Ansible
      can support IP address based certificate hostname matching (exists in >= python3.5.0).
    required: false

certificate_authority_data:
    default: null
    description:
    - 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.
    required: false

Outputs

api_response:
  contains:
    apiVersion: v1
    kind: Namespace
    metadata:
      creationTimestamp: '2016-01-04T21:16:32Z'
      name: test-namespace
      resourceVersion: '509635'
      selfLink: /api/v1/namespaces/test-namespace
      uid: 6dbd394e-b328-11e5-9a02-42010af0013a
    spec:
      finalizers:
      - kubernetes
    status:
      phase: Active
  description: Raw response from Kubernetes API, content varies with API.
  returned: success
  type: dictionary