diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 7f2b05b4..acfef9aa 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -5,6 +5,47 @@ Kubernetes Collection Release Notes .. contents:: Topics +v2.2.0 +====== + +Minor Changes +------------- + +- add support for in-memory kubeconfig in addition to file for k8s modules. (https://github.com/ansible-collections/kubernetes.core/pull/212). +- helm - add support for history_max cli parameter (https://github.com/ansible-collections/kubernetes.core/pull/164). +- k8s - add support for label_selectors options (https://github.com/ansible-collections/kubernetes.core/issues/43). +- k8s - add support for waiting on statefulsets (https://github.com/ansible-collections/kubernetes.core/pull/195). +- k8s_log - Add since-seconds parameter to the k8s_log module (https://github.com/ansible-collections/kubernetes.core/pull/142). +- new lookup plugin to support kubernetes kustomize feature. (https://github.com/ansible-collections/kubernetes.core/issues/39). +- re-enable turbo mode for collection. The default is initially set to off (https://github.com/ansible-collections/kubernetes.core/pull/169). + +Bugfixes +-------- + +- common - import k8sdynamicclient directly to workaround Ansible upstream bug (https://github.com/ansible-collections/kubernetes.core/issues/162). +- connection plugin - add arguments information into censored command (https://github.com/ansible-collections/kubernetes.core/pull/196). +- fix resource cache not being used (https://github.com/ansible-collections/kubernetes.core/pull/228). +- k8s - Fixes a bug where diff was always returned when using apply or modifying an existing object, even when diff=no was specified. The module no longer returns diff unless requested and will now honor diff=no (https://github.com/ansible-collections/kubernetes.core/pull/146). +- k8s_cp - fix k8s_cp uploading when target container's WORKDIR is not '/' (https://github.com/ansible-collections/kubernetes.core/issues/222). +- k8s_exec - add missing deprecation notice to return_code for k8s_exec (https://github.com/ansible-collections/kubernetes.core/pull/233). +- k8s_exec - fix k8s_exec returning rc attribute, to follow ansible's common return values (https://github.com/ansible-collections/kubernetes.core/pull/230). +- lookup - recommend query instead of lookup (https://github.com/ansible-collections/kubernetes.core/issues/147). +- support the ``template`` param in all collections depending on kubernetes.core (https://github.com/ansible-collections/kubernetes.core/pull/154). + +New Plugins +----------- + +Lookup +~~~~~~ + +- kustomize - Build a set of kubernetes resources using a 'kustomization.yaml' file. + +New Modules +----------- + +- k8s_cp - Copy files and directories to and from pod. +- k8s_drain - Drain, Cordon, or Uncordon node in k8s cluster + v2.1.1 ====== diff --git a/Makefile b/Makefile index e4330983..5d9a33ab 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ # Also needs to be updated in galaxy.yml -VERSION = 2.1.1 +VERSION = 2.2.0 TEST_ARGS ?= "" PYTHON_VERSION ?= `python -c 'import platform; print(".".join(platform.python_version_tuple()[0:2]))'` diff --git a/README.md b/README.md index 6c247bb2..1ed6fe2c 100644 --- a/README.md +++ b/README.md @@ -46,6 +46,7 @@ Name | Description Name | Description --- | --- [kubernetes.core.k8s](https://github.com/ansible-collections/kubernetes.core/blob/main/docs/kubernetes.core.k8s_lookup.rst)|Query the K8s API +[kubernetes.core.kustomize](https://github.com/ansible-collections/kubernetes.core/blob/main/docs/kubernetes.core.kustomize_lookup.rst)|Build a set of kubernetes resources using a 'kustomization.yaml' file. ### Modules Name | Description @@ -84,7 +85,7 @@ You can also include it in a `requirements.yml` file and install it via `ansible --- collections: - name: kubernetes.core - version: 2.1.1 + version: 2.2.0 ``` ### Installing the Kubernetes Python Library diff --git a/changelogs/changelog.yaml b/changelogs/changelog.yaml index 2588d0fa..2a680a84 100644 --- a/changelogs/changelog.yaml +++ b/changelogs/changelog.yaml @@ -429,3 +429,60 @@ releases: fragments: - 151-check-auth-params-for-existence.yaml release_date: '2021-06-24' + 2.2.0: + changes: + bugfixes: + - common - import k8sdynamicclient directly to workaround Ansible upstream bug + (https://github.com/ansible-collections/kubernetes.core/issues/162). + - connection plugin - add arguments information into censored command (https://github.com/ansible-collections/kubernetes.core/pull/196). + - fix resource cache not being used (https://github.com/ansible-collections/kubernetes.core/pull/228). + - k8s - Fixes a bug where diff was always returned when using apply or modifying + an existing object, even when diff=no was specified. The module no longer + returns diff unless requested and will now honor diff=no (https://github.com/ansible-collections/kubernetes.core/pull/146). + - k8s_cp - fix k8s_cp uploading when target container's WORKDIR is not '/' (https://github.com/ansible-collections/kubernetes.core/issues/222). + - k8s_exec - add missing deprecation notice to return_code for k8s_exec (https://github.com/ansible-collections/kubernetes.core/pull/233). + - k8s_exec - fix k8s_exec returning rc attribute, to follow ansible's common + return values (https://github.com/ansible-collections/kubernetes.core/pull/230). + - lookup - recommend query instead of lookup (https://github.com/ansible-collections/kubernetes.core/issues/147). + - support the ``template`` param in all collections depending on kubernetes.core + (https://github.com/ansible-collections/kubernetes.core/pull/154). + minor_changes: + - add support for in-memory kubeconfig in addition to file for k8s modules. + (https://github.com/ansible-collections/kubernetes.core/pull/212). + - helm - add support for history_max cli parameter (https://github.com/ansible-collections/kubernetes.core/pull/164). + - k8s - add support for label_selectors options (https://github.com/ansible-collections/kubernetes.core/issues/43). + - k8s - add support for waiting on statefulsets (https://github.com/ansible-collections/kubernetes.core/pull/195). + - k8s_log - Add since-seconds parameter to the k8s_log module (https://github.com/ansible-collections/kubernetes.core/pull/142). + - new lookup plugin to support kubernetes kustomize feature. (https://github.com/ansible-collections/kubernetes.core/issues/39). + - re-enable turbo mode for collection. The default is initially set to off (https://github.com/ansible-collections/kubernetes.core/pull/169). + fragments: + - 142-add-sinceseconds-param-for-logs.yaml + - 146-k8s-add-support-diff-mode.yml + - 147_lookup.yml + - 154-template-param-support.yaml + - 158-k8s-add-support-label_selectors.yml + - 162_import_error.yml + - 164-add-history-max.yaml + - 169-reenable-turbo-mode.yaml + - 195-k8s-add-wait-statefulsets.yml + - 196_kubectl.yaml + - 212-in-memory-kubeconfig.yml + - 223-add-deprecation-notice.yaml + - 223-k8s-cp-uploading.yaml + - 225-kustomize-lookup-plugin.yml + - 228-fix-resource-cache.yml + - 230-k8sexec-has-new-returnvalue.yml + modules: + - description: Copy files and directories to and from pod. + name: k8s_cp + namespace: '' + - description: Drain, Cordon, or Uncordon node in k8s cluster + name: k8s_drain + namespace: '' + plugins: + lookup: + - description: Build a set of kubernetes resources using a 'kustomization.yaml' + file. + name: kustomize + namespace: null + release_date: '2021-09-15' diff --git a/changelogs/fragments/142-add-sinceseconds-param-for-logs.yaml b/changelogs/fragments/142-add-sinceseconds-param-for-logs.yaml deleted file mode 100644 index 7b2189e8..00000000 --- a/changelogs/fragments/142-add-sinceseconds-param-for-logs.yaml +++ /dev/null @@ -1,2 +0,0 @@ -minor_changes: - - k8s_log - Add since-seconds parameter to the k8s_log module (https://github.com/ansible-collections/kubernetes.core/pull/142). diff --git a/changelogs/fragments/146-k8s-add-support-diff-mode.yml b/changelogs/fragments/146-k8s-add-support-diff-mode.yml deleted file mode 100644 index 6e29732b..00000000 --- a/changelogs/fragments/146-k8s-add-support-diff-mode.yml +++ /dev/null @@ -1,2 +0,0 @@ -bugfixes: - - k8s - Fixes a bug where diff was always returned when using apply or modifying an existing object, even when diff=no was specified. The module no longer returns diff unless requested and will now honor diff=no (https://github.com/ansible-collections/kubernetes.core/pull/146). diff --git a/changelogs/fragments/147_lookup.yml b/changelogs/fragments/147_lookup.yml deleted file mode 100644 index 8dfc2e10..00000000 --- a/changelogs/fragments/147_lookup.yml +++ /dev/null @@ -1,3 +0,0 @@ ---- -bugfixes: -- lookup - recommend query instead of lookup (https://github.com/ansible-collections/kubernetes.core/issues/147). diff --git a/changelogs/fragments/154-template-param-support.yaml b/changelogs/fragments/154-template-param-support.yaml deleted file mode 100644 index e77342c3..00000000 --- a/changelogs/fragments/154-template-param-support.yaml +++ /dev/null @@ -1,3 +0,0 @@ ---- -bugfixes: - - support the ``template`` param in all collections depending on kubernetes.core (https://github.com/ansible-collections/kubernetes.core/pull/154). diff --git a/changelogs/fragments/158-k8s-add-support-label_selectors.yml b/changelogs/fragments/158-k8s-add-support-label_selectors.yml deleted file mode 100644 index a4bd473d..00000000 --- a/changelogs/fragments/158-k8s-add-support-label_selectors.yml +++ /dev/null @@ -1,3 +0,0 @@ ---- -minor_changes: -- k8s - add support for label_selectors options (https://github.com/ansible-collections/kubernetes.core/issues/43). diff --git a/changelogs/fragments/162_import_error.yml b/changelogs/fragments/162_import_error.yml deleted file mode 100644 index 780ef976..00000000 --- a/changelogs/fragments/162_import_error.yml +++ /dev/null @@ -1,3 +0,0 @@ ---- -bugfixes: -- common - import k8sdynamicclient directly to workaround Ansible upstream bug (https://github.com/ansible-collections/kubernetes.core/issues/162). diff --git a/changelogs/fragments/164-add-history-max.yaml b/changelogs/fragments/164-add-history-max.yaml deleted file mode 100644 index ebe44c57..00000000 --- a/changelogs/fragments/164-add-history-max.yaml +++ /dev/null @@ -1,2 +0,0 @@ -minor_changes: - - helm - add support for history_max cli parameter (https://github.com/ansible-collections/kubernetes.core/pull/164). diff --git a/changelogs/fragments/169-reenable-turbo-mode.yaml b/changelogs/fragments/169-reenable-turbo-mode.yaml deleted file mode 100644 index 0df8f047..00000000 --- a/changelogs/fragments/169-reenable-turbo-mode.yaml +++ /dev/null @@ -1,3 +0,0 @@ ---- -minor_changes: - - re-enable turbo mode for collection. The default is initially set to off (https://github.com/ansible-collections/kubernetes.core/pull/169). diff --git a/changelogs/fragments/195-k8s-add-wait-statefulsets.yml b/changelogs/fragments/195-k8s-add-wait-statefulsets.yml deleted file mode 100644 index 8a334a87..00000000 --- a/changelogs/fragments/195-k8s-add-wait-statefulsets.yml +++ /dev/null @@ -1,2 +0,0 @@ -minor_changes: - - k8s - add support for waiting on statefulsets (https://github.com/ansible-collections/kubernetes.core/pull/195). diff --git a/changelogs/fragments/196_kubectl.yaml b/changelogs/fragments/196_kubectl.yaml deleted file mode 100644 index 9e61cf39..00000000 --- a/changelogs/fragments/196_kubectl.yaml +++ /dev/null @@ -1,3 +0,0 @@ ---- -bugfixes: -- connection plugin - add arguments information into censored command (https://github.com/ansible-collections/kubernetes.core/pull/196). diff --git a/changelogs/fragments/212-in-memory-kubeconfig.yml b/changelogs/fragments/212-in-memory-kubeconfig.yml deleted file mode 100644 index 82e2560b..00000000 --- a/changelogs/fragments/212-in-memory-kubeconfig.yml +++ /dev/null @@ -1,2 +0,0 @@ -minor_changes: - - add support for in-memory kubeconfig in addition to file for k8s modules. (https://github.com/ansible-collections/kubernetes.core/pull/212). diff --git a/changelogs/fragments/223-add-deprecation-notice.yaml b/changelogs/fragments/223-add-deprecation-notice.yaml deleted file mode 100644 index 8c3b7ac6..00000000 --- a/changelogs/fragments/223-add-deprecation-notice.yaml +++ /dev/null @@ -1,3 +0,0 @@ ---- -bugfixes: - - k8s_exec - add missing deprecation notice to return_code for k8s_exec (https://github.com/ansible-collections/kubernetes.core/pull/233). diff --git a/changelogs/fragments/223-k8s-cp-uploading.yaml b/changelogs/fragments/223-k8s-cp-uploading.yaml deleted file mode 100644 index 03da93fb..00000000 --- a/changelogs/fragments/223-k8s-cp-uploading.yaml +++ /dev/null @@ -1,2 +0,0 @@ -bugfixes: - - k8s_cp - fix k8s_cp uploading when target container's WORKDIR is not '/' (https://github.com/ansible-collections/kubernetes.core/issues/222). diff --git a/changelogs/fragments/225-kustomize-lookup-plugin.yml b/changelogs/fragments/225-kustomize-lookup-plugin.yml deleted file mode 100644 index 3c50138e..00000000 --- a/changelogs/fragments/225-kustomize-lookup-plugin.yml +++ /dev/null @@ -1,3 +0,0 @@ ---- -minor_changes: - - new lookup plugin to support kubernetes kustomize feature. (https://github.com/ansible-collections/kubernetes.core/issues/39). diff --git a/changelogs/fragments/228-fix-resource-cache.yml b/changelogs/fragments/228-fix-resource-cache.yml deleted file mode 100644 index 807bc66f..00000000 --- a/changelogs/fragments/228-fix-resource-cache.yml +++ /dev/null @@ -1,3 +0,0 @@ ---- -bugfixes: - - fix resource cache not being used (https://github.com/ansible-collections/kubernetes.core/pull/228). diff --git a/changelogs/fragments/230-k8sexec-has-new-returnvalue.yml b/changelogs/fragments/230-k8sexec-has-new-returnvalue.yml deleted file mode 100644 index ae1e6d6a..00000000 --- a/changelogs/fragments/230-k8sexec-has-new-returnvalue.yml +++ /dev/null @@ -1,2 +0,0 @@ -bugfixes: -- k8s_exec - fix k8s_exec returning rc attribute, to follow ansible's common return values (https://github.com/ansible-collections/kubernetes.core/pull/230). diff --git a/docs/kubernetes.core.helm_module.rst b/docs/kubernetes.core.helm_module.rst index 9921c144..4205207a 100644 --- a/docs/kubernetes.core.helm_module.rst +++ b/docs/kubernetes.core.helm_module.rst @@ -231,6 +231,23 @@ Parameters
Helm option to force reinstall, ignore on new install.
+ + +
+ history_max + +
+ integer +
+
added in 2.2.0
+ + + + +
Limit the maximum number of revisions saved per release.
+
mutually exclusive with with replace.
+ +
@@ -373,6 +390,7 @@ Parameters
Reuse the given name, only if that name is a deleted release which remains in the history.
This is unsafe in production environment.
+
mutually exclusive with with history_max.
diff --git a/docs/kubernetes.core.k8s_cluster_info_module.rst b/docs/kubernetes.core.k8s_cluster_info_module.rst index e1b6c4de..bdd83ae4 100644 --- a/docs/kubernetes.core.k8s_cluster_info_module.rst +++ b/docs/kubernetes.core.k8s_cluster_info_module.rst @@ -161,13 +161,14 @@ Parameters kubeconfig
- path + raw
Path to an existing Kubernetes config file. If not provided, and no other connection options are provided, the Kubernetes client will attempt to load the default configuration file from ~/.kube/config. Can also be specified via K8S_AUTH_KUBECONFIG environment variable.
+
The kubernetes configuration can be provided as dictionary. This feature requires a python kubernetes client version >= 17.17.0. Added in version 2.2.0.
diff --git a/docs/kubernetes.core.k8s_cp_module.rst b/docs/kubernetes.core.k8s_cp_module.rst index 5637cb01..1cf34449 100644 --- a/docs/kubernetes.core.k8s_cp_module.rst +++ b/docs/kubernetes.core.k8s_cp_module.rst @@ -173,13 +173,14 @@ Parameters kubeconfig
- path + raw
Path to an existing Kubernetes config file. If not provided, and no other connection options are provided, the Kubernetes client will attempt to load the default configuration file from ~/.kube/config. Can also be specified via K8S_AUTH_KUBECONFIG environment variable.
+
The kubernetes configuration can be provided as dictionary. This feature requires a python kubernetes client version >= 17.17.0. Added in version 2.2.0.
diff --git a/docs/kubernetes.core.k8s_drain_module.rst b/docs/kubernetes.core.k8s_drain_module.rst index 741b632c..8b482333 100644 --- a/docs/kubernetes.core.k8s_drain_module.rst +++ b/docs/kubernetes.core.k8s_drain_module.rst @@ -8,6 +8,7 @@ kubernetes.core.k8s_drain **Drain, Cordon, or Uncordon node in k8s cluster** +Version added: 2.2.0 .. contents:: :local: @@ -271,13 +272,14 @@ Parameters kubeconfig
- path + raw
Path to an existing Kubernetes config file. If not provided, and no other connection options are provided, the Kubernetes client will attempt to load the default configuration file from ~/.kube/config. Can also be specified via K8S_AUTH_KUBECONFIG environment variable.
+
The kubernetes configuration can be provided as dictionary. This feature requires a python kubernetes client version >= 17.17.0. Added in version 2.2.0.
diff --git a/docs/kubernetes.core.k8s_exec_module.rst b/docs/kubernetes.core.k8s_exec_module.rst index a43c0fa9..efadf5b5 100644 --- a/docs/kubernetes.core.k8s_exec_module.rst +++ b/docs/kubernetes.core.k8s_exec_module.rst @@ -172,13 +172,14 @@ Parameters kubeconfig
- path + raw
Path to an existing Kubernetes config file. If not provided, and no other connection options are provided, the Kubernetes client will attempt to load the default configuration file from ~/.kube/config. Can also be specified via K8S_AUTH_KUBECONFIG environment variable.
+
The kubernetes configuration can be provided as dictionary. This feature requires a python kubernetes client version >= 17.17.0. Added in version 2.2.0.
@@ -382,7 +383,8 @@ Notes ----- .. note:: - - Return code ``rc`` for the command executed is added in output in version 1.0.0. + - Return code ``rc`` for the command executed is added in output in version 2.2.0, and deprecates return code ``return_code``. + - Return code ``return_code`` for the command executed is added in output in version 1.0.0. - The authenticated user must have at least read access to the pods resource and write access to the pods/exec resource. - To avoid SSL certificate validation errors when ``validate_certs`` is *True*, the full certificate chain for the API server must be provided via ``ca_cert`` or in the kubeconfig file. @@ -441,8 +443,8 @@ Common return values are documented `here - -   + +  
rc @@ -450,6 +452,7 @@ Common return values are documented `here integer +
added in 2.2.0
@@ -457,8 +460,7 @@ Common return values are documented `here - - +  
@@ -470,7 +472,7 @@ Common return values are documented `here -
The command status code. This attribute is deprecated and will be removed in future release. Please use rc instead.
+
The command status code. This attribute is deprecated and will be removed in a future release. Please use rc instead.

diff --git a/docs/kubernetes.core.k8s_info_module.rst b/docs/kubernetes.core.k8s_info_module.rst index be82dce5..518a4599 100644 --- a/docs/kubernetes.core.k8s_info_module.rst +++ b/docs/kubernetes.core.k8s_info_module.rst @@ -198,13 +198,14 @@ Parameters kubeconfig
- path + raw
Path to an existing Kubernetes config file. If not provided, and no other connection options are provided, the Kubernetes client will attempt to load the default configuration file from ~/.kube/config. Can also be specified via K8S_AUTH_KUBECONFIG environment variable.
+
The kubernetes configuration can be provided as dictionary. This feature requires a python kubernetes client version >= 17.17.0. Added in version 2.2.0.
diff --git a/docs/kubernetes.core.k8s_json_patch_module.rst b/docs/kubernetes.core.k8s_json_patch_module.rst index 45ad392d..dad68d7b 100644 --- a/docs/kubernetes.core.k8s_json_patch_module.rst +++ b/docs/kubernetes.core.k8s_json_patch_module.rst @@ -18,7 +18,7 @@ Version added: 2.0.0 Synopsis -------- - This module is used to apply RFC 6902 JSON patch operations only. -- Use the :ref:`k8s ` module for strategic merge or JSON merge operations. +- Use the :ref:`kubernetes.core.k8s ` module for strategic merge or JSON merge operations. - The jsonpatch library is required for check mode. @@ -178,13 +178,14 @@ Parameters kubeconfig
- path + raw
Path to an existing Kubernetes config file. If not provided, and no other connection options are provided, the Kubernetes client will attempt to load the default configuration file from ~/.kube/config. Can also be specified via K8S_AUTH_KUBECONFIG environment variable.
+
The kubernetes configuration can be provided as dictionary. This feature requires a python kubernetes client version >= 17.17.0. Added in version 2.2.0.
diff --git a/docs/kubernetes.core.k8s_log_module.rst b/docs/kubernetes.core.k8s_log_module.rst index edea0a8c..964c1527 100644 --- a/docs/kubernetes.core.k8s_log_module.rst +++ b/docs/kubernetes.core.k8s_log_module.rst @@ -198,13 +198,14 @@ Parameters kubeconfig
- path + raw
Path to an existing Kubernetes config file. If not provided, and no other connection options are provided, the Kubernetes client will attempt to load the default configuration file from ~/.kube/config. Can also be specified via K8S_AUTH_KUBECONFIG environment variable.
+
The kubernetes configuration can be provided as dictionary. This feature requires a python kubernetes client version >= 17.17.0. Added in version 2.2.0.
@@ -383,6 +384,22 @@ Parameters + + +
+ since_seconds + +
+ string +
+
added in 2.2.0
+ + + + +
A relative time in seconds before the current time from which to show logs.
+ +
@@ -457,6 +474,7 @@ Examples kind: Deployment namespace: testing name: example + since_seconds: "4000" register: log # This will get the log from a single Pod managed by this DeploymentConfig diff --git a/docs/kubernetes.core.k8s_lookup.rst b/docs/kubernetes.core.k8s_lookup.rst index 9337796a..9e428c8b 100644 --- a/docs/kubernetes.core.k8s_lookup.rst +++ b/docs/kubernetes.core.k8s_lookup.rst @@ -381,6 +381,12 @@ Parameters
+Notes +----- + +.. note:: + - While querying, please use ``query`` or ``lookup`` format with ``wantlist=True`` to provide an easier and more consistent interface. For more details, see https://docs.ansible.com/ansible/latest/plugins/lookup.html#forcing-lookups-to-return-lists-query-and-wantlist-true. + Examples @@ -390,23 +396,23 @@ Examples - name: Fetch a list of namespaces set_fact: - projects: "{{ lookup('kubernetes.core.k8s', api_version='v1', kind='Namespace') }}" + projects: "{{ query('kubernetes.core.k8s', api_version='v1', kind='Namespace') }}" - name: Fetch all deployments set_fact: - deployments: "{{ lookup('kubernetes.core.k8s', kind='Deployment') }}" + deployments: "{{ query('kubernetes.core.k8s', kind='Deployment') }}" - name: Fetch all deployments in a namespace set_fact: - deployments: "{{ lookup('kubernetes.core.k8s', kind='Deployment', namespace='testing') }}" + deployments: "{{ query('kubernetes.core.k8s', kind='Deployment', namespace='testing') }}" - name: Fetch a specific deployment by name set_fact: - deployments: "{{ lookup('kubernetes.core.k8s', kind='Deployment', namespace='testing', resource_name='elastic') }}" + deployments: "{{ query('kubernetes.core.k8s', kind='Deployment', namespace='testing', resource_name='elastic') }}" - name: Fetch with label selector set_fact: - service: "{{ lookup('kubernetes.core.k8s', kind='Service', label_selector='app=galaxy') }}" + service: "{{ query('kubernetes.core.k8s', kind='Service', label_selector='app=galaxy') }}" # Use parameters from a YAML config @@ -416,11 +422,11 @@ Examples - name: Using the config (loaded from a file in prior task), fetch the latest version of the object set_fact: - service: "{{ lookup('kubernetes.core.k8s', resource_definition=config) }}" + service: "{{ query('kubernetes.core.k8s', resource_definition=config) }}" - name: Use a config from the local filesystem set_fact: - service: "{{ lookup('kubernetes.core.k8s', src='service.yml') }}" + service: "{{ query('kubernetes.core.k8s', src='service.yml') }}" diff --git a/docs/kubernetes.core.k8s_module.rst b/docs/kubernetes.core.k8s_module.rst index acec37d3..058b6b96 100644 --- a/docs/kubernetes.core.k8s_module.rst +++ b/docs/kubernetes.core.k8s_module.rst @@ -375,13 +375,31 @@ Parameters kubeconfig
- path + raw
Path to an existing Kubernetes config file. If not provided, and no other connection options are provided, the Kubernetes client will attempt to load the default configuration file from ~/.kube/config. Can also be specified via K8S_AUTH_KUBECONFIG environment variable.
+
The kubernetes configuration can be provided as dictionary. This feature requires a python kubernetes client version >= 17.17.0. Added in version 2.2.0.
+ + + + +
+ label_selectors + +
+ list + / elements=string +
+
added in 2.2.0
+ + + + +
Selector (label query) to filter on.
@@ -639,6 +657,7 @@ Parameters
Provide a valid YAML template definition file for an object when creating or updating.
Value can be provided as string or dictionary.
+
The parameter accepts multiple template files. Added in version 2.0.0.
Mutually exclusive with src and resource_definition.
Template files needs to be present on the Ansible Controller's file system.
Additional parameters can be specified using dictionary.
@@ -975,6 +994,15 @@ Examples variable_start_string: '[[' variable_end_string: ']]' + - name: Read multiple definition template file from the Ansible controller file system + kubernetes.core.k8s: + state: present + template: + - path: '/testing/deployment_one.j2' + - path: '/testing/deployment_two.j2' + variable_start_string: '[[' + variable_end_string: ']]' + - name: fail on validation errors kubernetes.core.k8s: state: present diff --git a/docs/kubernetes.core.k8s_rollback_module.rst b/docs/kubernetes.core.k8s_rollback_module.rst index 48e2d35c..a559ce2e 100644 --- a/docs/kubernetes.core.k8s_rollback_module.rst +++ b/docs/kubernetes.core.k8s_rollback_module.rst @@ -196,13 +196,14 @@ Parameters kubeconfig
- path + raw
Path to an existing Kubernetes config file. If not provided, and no other connection options are provided, the Kubernetes client will attempt to load the default configuration file from ~/.kube/config. Can also be specified via K8S_AUTH_KUBECONFIG environment variable.
+
The kubernetes configuration can be provided as dictionary. This feature requires a python kubernetes client version >= 17.17.0. Added in version 2.2.0.
diff --git a/docs/kubernetes.core.k8s_scale_module.rst b/docs/kubernetes.core.k8s_scale_module.rst index 07483f9d..9f7ddebc 100644 --- a/docs/kubernetes.core.k8s_scale_module.rst +++ b/docs/kubernetes.core.k8s_scale_module.rst @@ -213,13 +213,14 @@ Parameters kubeconfig
- path + raw
Path to an existing Kubernetes config file. If not provided, and no other connection options are provided, the Kubernetes client will attempt to load the default configuration file from ~/.kube/config. Can also be specified via K8S_AUTH_KUBECONFIG environment variable.
+
The kubernetes configuration can be provided as dictionary. This feature requires a python kubernetes client version >= 17.17.0. Added in version 2.2.0.
diff --git a/docs/kubernetes.core.k8s_service_module.rst b/docs/kubernetes.core.k8s_service_module.rst index 3ac7e918..fa40e51f 100644 --- a/docs/kubernetes.core.k8s_service_module.rst +++ b/docs/kubernetes.core.k8s_service_module.rst @@ -178,13 +178,14 @@ Parameters kubeconfig
- path + raw
Path to an existing Kubernetes config file. If not provided, and no other connection options are provided, the Kubernetes client will attempt to load the default configuration file from ~/.kube/config. Can also be specified via K8S_AUTH_KUBECONFIG environment variable.
+
The kubernetes configuration can be provided as dictionary. This feature requires a python kubernetes client version >= 17.17.0. Added in version 2.2.0.
diff --git a/docs/kubernetes.core.kustomize_lookup.rst b/docs/kubernetes.core.kustomize_lookup.rst new file mode 100644 index 00000000..38d328ed --- /dev/null +++ b/docs/kubernetes.core.kustomize_lookup.rst @@ -0,0 +1,251 @@ +.. _kubernetes.core.kustomize_lookup: + + +************************* +kubernetes.core.kustomize +************************* + +**Build a set of kubernetes resources using a 'kustomization.yaml' file.** + + +Version added: 2.2.0 + +.. contents:: + :local: + :depth: 1 + + +Synopsis +-------- +- Uses the kustomize or the kubectl tool. +- Return the result of ``kustomize build`` or ``kubectl kustomize``. + + + +Requirements +------------ +The below requirements are needed on the local Ansible controller node that executes this lookup. + +- python >= 3.6 + + +Parameters +---------- + +.. raw:: html + + + + + + + + + + + + + + + + + + + + + + + + + + +
ParameterChoices/DefaultsConfigurationComments
+
+ binary_path + +
+ - +
+
+ + +
The path of a kustomize or kubectl binary to use.
+
+
+ dir + +
+ - +
+
+ Default:
"."
+
+ +
The directory path containing 'kustomization.yaml', or a git repository URL with a path suffix specifying same with respect to the repository root.
+
If omitted, '.' is assumed.
+
+
+ opt_dirs + +
+ - +
+
+ + +
An optional list of directories to search for the executable in addition to PATH.
+
+
+ + +Notes +----- + +.. note:: + - If both kustomize and kubectl are part of the PATH, kustomize will be used by the plugin. + + + +Examples +-------- + +.. code-block:: yaml + + - name: Run lookup using kustomize + set_fact: + resources: "{{ lookup('kubernetes.core.kustomize', binary_path='/path/to/kustomize') }}" + + - name: Run lookup using kubectl kustomize + set_fact: + resources: "{{ lookup('kubernetes.core.kustomize', binary_path='/path/to/kubectl') }}" + + - name: Create kubernetes resources for lookup output + k8s: + definition: "{{ lookup('kubernetes.core.kustomize', dir='/path/to/kustomization') }}" + + + +Return Values +------------- +Common return values are documented `here `_, the following are the fields unique to this lookup: + +.. raw:: html + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
KeyReturnedDescription
+
+ _list + +
+ complex +
+
+
One ore more object definitions returned from the tool execution.
+
+
  +
+ api_version + +
+ string +
+
success +
The versioned schema of this representation of an object.
+
+
  +
+ kind + +
+ string +
+
success +
Represents the REST resource this object represents.
+
+
  +
+ metadata + +
+ complex +
+
success +
Standard object metadata. Includes name, namespace, annotations, labels, etc.
+
+
  +
+ spec + +
+ complex +
+
success +
Specific attributes of the object. Will vary based on the api_version and kind.
+
+
  +
+ status + +
+ complex +
+
success +
Current status details for the object.
+
+
+

+ + +Status +------ + + +Authors +~~~~~~~ + +- Aubin Bikouo <@abikouo> + + +.. hint:: + Configuration entries for each entry type have a low to high priority order. For example, a variable that is lower in the list will override a variable that is higher up. diff --git a/galaxy.yml b/galaxy.yml index e2d8c6da..fb9238b3 100644 --- a/galaxy.yml +++ b/galaxy.yml @@ -25,7 +25,7 @@ tags: - openshift - okd - cluster -version: 2.1.1 +version: 2.2.0 build_ignore: - .DS_Store - '*.tar.gz' diff --git a/meta/runtime.yml b/meta/runtime.yml index ff4c1484..25f931a0 100644 --- a/meta/runtime.yml +++ b/meta/runtime.yml @@ -15,6 +15,7 @@ action_groups: - k8s_scale - k8s_service - k8s_cp + - k8s_drain plugin_routing: action: @@ -32,6 +33,10 @@ plugin_routing: redirect: kubernetes.core.k8s_info k8s_cluster_info: redirect: kubernetes.core.k8s_info + k8s_cp: + redirect: kubernetes.core.k8s_info + k8s_drain: + redirect: kubernetes.core.k8s_info k8s_event_info: redirect: kubernetes.core.k8s_info k8s_exec: @@ -44,8 +49,6 @@ plugin_routing: redirect: kubernetes.core.k8s_info k8s_service: redirect: kubernetes.core.k8s_info - k8s_cp: - redirect: kubernetes.core.k8s_info inventory: openshift: redirect: community.okd.openshift diff --git a/plugins/action/k8s_drain.py b/plugins/action/k8s_drain.py new file mode 120000 index 00000000..667980ed --- /dev/null +++ b/plugins/action/k8s_drain.py @@ -0,0 +1 @@ +k8s_info.py \ No newline at end of file diff --git a/plugins/modules/k8s_drain.py b/plugins/modules/k8s_drain.py index 837bc963..dd4f9641 100644 --- a/plugins/modules/k8s_drain.py +++ b/plugins/modules/k8s_drain.py @@ -15,6 +15,8 @@ module: k8s_drain short_description: Drain, Cordon, or Uncordon node in k8s cluster +version_added: "2.2.0" + author: Aubin Bikouo (@abikouo) description: diff --git a/plugins/modules/k8s_exec.py b/plugins/modules/k8s_exec.py index 3ce10d0f..fcd462eb 100644 --- a/plugins/modules/k8s_exec.py +++ b/plugins/modules/k8s_exec.py @@ -108,7 +108,7 @@ result: rc: description: The command status code type: int - version_added: 2.3.0 + version_added: 2.2.0 return_code: description: The command status code. This attribute is deprecated and will be removed in a future release. Please use rc instead. type: int