ansible.builtin.kubectl (v2.9.27) — connection

Execute tasks in pods running on Kubernetes.

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

Authors: xuxinkun

Install Ansible via pip

Install with pip install ansible==2.9.27

Description

Use the kubectl exec command to run tasks in, or put/fetch files to, pods running on the Kubernetes container platform.


Requirements

Inputs

    
ca_cert:
    aliases:
    - kubectl_ssl_ca_cert
    default: ''
    description:
    - Path to a CA certificate used to authenticate with the API.
    env:
    - name: K8S_AUTH_SSL_CA_CERT
    vars:
    - name: ansible_kubectl_ssl_ca_cert
    - name: ansible_kubectl_ca_cert

client_key:
    aliases:
    - kubectl_key_file
    default: ''
    description:
    - Path to a key file used to authenticate with the API.
    env:
    - name: K8S_AUTH_KEY_FILE
    vars:
    - name: ansible_kubectl_key_file
    - name: ansible_kubectl_client_key

client_cert:
    aliases:
    - kubectl_cert_file
    default: ''
    description:
    - Path to a certificate used to authenticate with the API.
    env:
    - name: K8S_AUTH_CERT_FILE
    vars:
    - name: ansible_kubectl_cert_file
    - name: ansible_kubectl_client_cert

kubectl_pod:
    default: ''
    description:
    - Pod name.
    - Required when the host name does not match pod name.
    env:
    - name: K8S_AUTH_POD
    vars:
    - name: ansible_kubectl_pod

kubectl_host:
    default: ''
    description:
    - URL for accessing the API.
    env:
    - name: K8S_AUTH_HOST
    - name: K8S_AUTH_SERVER
    vars:
    - name: ansible_kubectl_host
    - name: ansible_kubectl_server

kubectl_token:
    description:
    - API authentication bearer token.
    - Please be aware that this passes information directly on the command line and it
      could expose sensitive data. We recommend using the file based authentication options
      instead.
    env:
    - name: K8S_AUTH_TOKEN
    - name: K8S_AUTH_API_KEY
    vars:
    - name: ansible_kubectl_token
    - name: ansible_kubectl_api_key

validate_certs:
    aliases:
    - kubectl_verify_ssl
    default: ''
    description:
    - Whether or not to verify the API server's SSL certificate. Defaults to I(true).
    env:
    - name: K8S_AUTH_VERIFY_SSL
    vars:
    - name: ansible_kubectl_verify_ssl
    - name: ansible_kubectl_validate_certs

kubectl_context:
    default: ''
    description:
    - The name of a context found in the K8s config file.
    env:
    - name: k8S_AUTH_CONTEXT
    vars:
    - name: ansible_kubectl_context

kubectl_password:
    default: ''
    description:
    - Provide a password for authenticating with the API.
    - Please be aware that this passes information directly on the command line and it
      could expose sensitive data. We recommend using the file based authentication options
      instead.
    env:
    - name: K8S_AUTH_PASSWORD
    vars:
    - name: ansible_kubectl_password

kubectl_username:
    default: ''
    description:
    - Provide a username for authenticating with the API.
    env:
    - name: K8S_AUTH_USERNAME
    vars:
    - name: ansible_kubectl_username
    - name: ansible_kubectl_user

kubectl_container:
    default: ''
    description:
    - Container name.
    - Required when a pod contains more than one container.
    env:
    - name: K8S_AUTH_CONTAINER
    vars:
    - name: ansible_kubectl_container

kubectl_namespace:
    default: ''
    description:
    - The namespace of the pod
    env:
    - name: K8S_AUTH_NAMESPACE
    vars:
    - name: ansible_kubectl_namespace

kubectl_extra_args:
    default: ''
    description:
    - Extra arguments to pass to the kubectl command line.
    - Please be aware that this passes information directly on the command line and it
      could expose sensitive data.
    env:
    - name: K8S_AUTH_EXTRA_ARGS
    vars:
    - name: ansible_kubectl_extra_args

kubectl_kubeconfig:
    default: ''
    description:
    - Path to a kubectl config file. Defaults to I(~/.kube/config)
    env:
    - name: K8S_AUTH_KUBECONFIG
    vars:
    - name: ansible_kubectl_kubeconfig
    - name: ansible_kubectl_config