Commit Graph

502 Commits

Author SHA1 Message Date
Gonéri Le Bouder
9384742bdc gc.yml: address a race condition (#80)
Wait until the job is actually deleted before checking the final state.
2021-04-22 13:51:02 -04:00
abikouo
361061c727 k8s loop flattening for template argument (#49)
* repo migration

* Update and rename 411-k8s-loop-flattening-and-continue_on_error.yaml to 49-k8s-loop-flattening-and-continue_on_error.yaml

* Update plugins/modules/k8s.py

Co-authored-by: Mike Graves <mgraves@redhat.com>

* split into multiple lines

* linting

* Update .gitignore

* Update template.yml

* merge

* Update template.yml

* deep copy environment

* deepcopy

* lint

* remove useless comment

* multiple definition

* tests update

* jmespath

* Update ci.yml

* Update template.yml

Co-authored-by: Mike Graves <mgraves@redhat.com>
2021-04-22 19:28:07 +02:00
Gonéri Le Bouder
c516d7ecb9 k8s_exec: reuse existing connection (#76)
Initialize the CoreV1Api object with the existing Kubernetes connection.
2021-04-22 12:50:40 -04:00
Gonéri Le Bouder
9a529fc8f3 helm: accept context and validate_certs (#74)
I've got the following environment variable set:
- `K8S_AUTH_VERIFY_SSL=False`

Helm's `validate_certs` parameter fallback on this environment variable.
Which means, on my system, the `validate_certs` will already be set.

So we cannot make this parameter exclusive wih another one.
2021-04-22 10:30:38 -04:00
abikouo
b59336e6b2 ignore .cache directory used for tests (#77) 2021-04-22 16:11:59 +02:00
Mike Graves
47acf53909 Cleanup sample_plugin during helm tests (#75) 2021-04-22 09:25:03 +05:30
Gonéri Le Bouder
e4469f72bc yamllint and flake8 should ignore .cache (#73)
The content of .cache is not maintained in this repository. There
is no point raising an error when there is problem in one of these
3rd party dependencies.
2021-04-22 09:22:09 +05:30
Alina Buzachis
c214376cac Add cache_file parameter for DynamicClient (#46) 2021-04-21 09:57:52 +05:30
Abhijeet Kasurde
a5a850d1da Remove KubernetesAnsibleModule class (#70)
Co-authored-by: Mike Graves <mgraves@redhat.com>
2021-04-20 21:02:59 +05:30
Alina Buzachis
edc48ee577 Add configmap/secret hash functionality (#48)
* * * Add configmap/secret hash functionality

Signed-off-by: Alina Buzachis <abuzachis@redhat.com>

* * Add changelog fragment

Signed-off-by: Alina Buzachis <abuzachis@redhat.com>
2021-04-20 08:27:25 -04:00
Abhijeet Kasurde
cc10268adf k8s inventory - remove trailing slashes from hostname (#63)
When the user provides a hostname with trailing slashes like
https://localhost:6443/, the openshift library fails to
enumerate the APIs from the given cluster.

This fix removes any extra trailing slashes before sending it
to the openshift DynamicClient.

Fixes: #52

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
2021-04-20 13:15:29 +05:30
Abhijeet Kasurde
5a0f5d6b93 helm: handle multiline output (#64)
Fixes: #399

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
2021-04-20 12:07:28 +05:30
Abhijeet Kasurde
5f993e6028 Update kubeconfig file location in docs (#65)
Fixes: #53 

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
2021-04-19 19:50:14 +05:30
abikouo
8cee069ff1 Fix apis being overwritten when using k8s_cluster_info (#47)
* Update and rename 389-fix-apis-being-overwritten-in-k8s_cluster_info.yaml to 41-fix-apis-being-overwritten-in-k8s_cluster_info.yaml

* Update changelogs/fragments/41-fix-apis-being-overwritten-in-k8s_cluster_info.yaml

Co-authored-by: Abhijeet Kasurde <akasurde@redhat.com>

Co-authored-by: Abhijeet Kasurde <akasurde@redhat.com>
2021-04-19 09:05:13 -04:00
Mike Graves
b68bf7c065 Add support for tags to molecule tests (#62) 2021-04-19 10:00:21 +05:30
Abhijeet Kasurde
28223dbe36 Fix broken links in docs (#61) 2021-04-16 10:19:47 +05:30
Abhijeet Kasurde
8182a3afd4 Added docs for the collection (#50) 2021-04-12 22:25:10 +05:30
Abhijeet Kasurde
4aa983509b Remove old changelog fragment files (#51) 2021-04-12 18:32:47 +05:30
Mike Graves
ba586a8ed8 Rename from community.kubernetes to kubernetes.core (#6)
* Rename from community.kubernetes to kubernetes.core

This goes through and renames community.kubernetes to kubernetes.core.
Most of this was generated from the downstream build script that was
used on the community repository, plus whatever hand edits I could find
that were needed.

The downstream build and test process has also been removed as this
repository is now the downstream repository.

* Fix CONTRIBUTING.md
2021-04-08 08:48:27 -04:00
Andrew Klychkov
a55edac38f Add ignore.txt for 2.12 (#7) 2021-04-08 14:00:02 +05:30
Mike Graves
d6f251173e Add unit tests to CI (#407)
* Add unit tests to CI

The unit tests were not being run during CI. This adds a GitHub Action
for it.

* Add changelog fragment
2021-04-05 09:39:01 -04:00
Abhijeet Kasurde
c9157ce713 k8s: fix get_api_client usage in inventory plugin (#395)
Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
2021-03-26 14:36:47 -04:00
Mike Graves
34e6e09fb8 Restrict molecule version to <3.3.0 (#396)
The 3.3.0 version of molecule broke the test suite. Restricting the
version until we can either fix upstream or decide on the best
workaround.
2021-03-25 09:22:59 +05:30
Timothy Appnel
5fc3dd02bf Adds a wait example to k8s.py (#386)
Co-authored-by: Abhijeet Kasurde <akasurde@redhat.com>
2021-03-18 14:48:07 +05:30
Gonéri Le Bouder
39660dd40e refactoring for ansible_module.turbo integration (#313)
* refactoring for ansible_module.turbo integration

This refactoring prepares the integration of `ansible_module.turbo`

- Delay the loading of `common.py`, move the shared structure in
  `args_common`.
- Avoid the use of one single object per module, this to increase the
  amount of Python structure that we can cache.
- Cache the Kubernetes client.

See: https://github.com/ansible-collections/community.kubernetes/pull/270

Co-authored-by: Jill Rouleau <jill.rouleau@bespokess.com>
2021-03-16 17:16:18 -04:00
Abhijeet Kasurde
2f6fae322c Removed openshift inventory for community.kubernetes (#377) 2021-03-16 18:43:07 +05:30
Mike Graves
af928a255f Remove old openshift integration tests (#382) 2021-03-16 09:05:52 -04:00
Mike Graves
07915509c1 Remove deprecated KubernetesRawModule (#379)
* Remove deprecated KubernetesRawModule

* Add changelog fragment
2021-03-16 09:05:07 -04:00
Mike Graves
c4182ad84f Fix helm ignoring given context (#387)
Fixes: #385
2021-03-15 10:04:06 +05:30
Timothy Appnel
af41efdf46 Fix typo in README.md
helm_template had a typo in it.
2021-03-08 18:49:45 -05:00
Abhijeet Kasurde
1e511113a5 k8s_auth: remove module (#376) 2021-03-08 22:54:22 +05:30
Timothy Appnel
8caca90c11 Update README.md with helm_template module under Included Content (#375) 2021-03-04 19:43:42 +05:30
Mike Graves
5eb280f35a Prep for 1.2 release (#370) 2021-02-19 13:02:07 -05:00
Mike Graves
a4ac078625 Add support for helm template (#368)
* Add support for helm template
This commit adds basic support for helm template. The functionality
allows one to either render a chart's templates to a specific directory,
or capture the rendered templates as a string of concatenated yaml
documents.
* Add changelog fragment
* Address PR feedback
* Set changed to true
2021-02-17 08:01:49 -05:00
Abhijeet Kasurde
dc80c418e9 Update minimum version of Ansible required (#366)
https://github.com/ansible-collections/community.kubernetes/pull/276
is backported to 2.9.17
Any Ansible version lesser than this will not work due to
Kubernetes-python compatibility issues.

Fixes: #314
Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
2021-02-16 15:05:53 -05:00
Joshua Hügli
8f098b14f2 make has_plugin detection method more reliable (#362)
* fix has_plugin detection method
* use even better method :)
* add changelog fragment
* fix forgotten file extension
* Double Backticks ;)
* Add PR link to changelog
Co-authored-by: Mike Graves <mgraves@redhat.com>
2021-02-16 12:38:29 -05:00
Mike Graves
9f7b6fb3ff Honor wait_timeout in k8s_info for missing resource (#360)
* Honor wait in k8s_info for missing resource

The wait logic in the k8s_info module immediately returns when no
resources are found, regardless whether a wait_timeout has been
specified. This expands the logic to wait when a name has been provided.
The case this is specifically meant to address is when querying for a
resource that is indirectly created by another resource, for example, a
pod created by a deployment or an operator.

The existing logic in every other case should remain as it was before.
This means if a query might return more than one resource--all pods with
some label, for example--the module will return immediately if no pods
are found, even if a wait_timeout has been provided.

* Add changelog fragment
2021-02-16 10:19:22 -07:00
Mike Graves
80b914021f Add skip_crds option to helm (#349)
This adds an option to skip the installation of CRDs when installing or
upgrading a chart.

Closes: #296
2021-02-09 09:51:10 +05:30
Mike Graves
981493dfb6 Add note about required permissions for k8s_exec (#361) 2021-02-08 19:42:13 -05:00
Abhijeet Kasurde
92e373239c k8s: Add example for download and apply manifest from URL (#359)
Fixes: #352

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
2021-02-03 21:16:44 +05:30
Mike Graves
2640084143 Add optional support for helm diff (#355)
There are some cases where the existing module has difficulty
determining if an upgrade would result in changes. This can particularly
be a problem when changes are made to a local chart.

This adds optional support for helm diff. If the plugin is present it
will be used. Otherwise, the default implementation will be used and a
warning will be issued. One caveat: helm diff does not currently support
using a repo url, so the default implementation will be used in this
case, as well.

Closes: #248
2021-02-03 13:46:26 +05:30
Abhijeet Kasurde
86c5c446dd Make unused release_namespace parameter as optional (#358) 2021-02-03 13:45:25 +05:30
Gonéri Le Bouder
5a5ed79b89 Revert "helm - remove trailing whitespaces (#337) (#345)" (#346)
This reverts commit 003d802065.

See: https://github.com/ansible-collections/community.kubernetes/pull/345#issuecomment-760291333
2021-01-14 11:19:12 -05:00
Mike Graves
b26afc3518 Fix Secret check_mode (#343)
When adding a Secret and using stringData, check_mode will always show
changes. An existing resource fetched from Kubernetes will have the
stringData already base64 encoded and merged into the data attribute.
This change performs the base64 encoding and merging with the provided
definition to more accurately represent the current state of the
cluster.

This change only affects check_mode. When making any changes to the
cluster the stringData is passed along as provided in the definition.

Closes #282.
2021-01-14 11:05:11 -05:00
Alina Buzachis
003d802065 helm - remove trailing whitespaces (#337) (#345)
Add remove_trailing_spaces() to remove trailing whitespaces for each helm_repository parameter.
2021-01-14 10:52:33 -05:00
Mike Graves
a9b8cc68d5 Add support for configuring garbage collection (#334)
* Add support for configuring garbage collection

This surfaces deleteOptions functionality in a top-level delete_options
parameter.

* Add changelog fragment

* Remove kind and apiVersion from delete_options

* Add release version to docs
2021-01-12 14:17:18 -05:00
Abhijeet Kasurde
9059f2c526 k8s: Handle ValueError raised (#330) 2021-01-12 21:38:58 +05:30
Gonéri Le Bouder
a6cb6c4821 action/k8s_info: refactoring to simplify the code base (#331)
Break down the long `run()` method to simplify the readability of the
plugin.
2021-01-11 11:04:11 +05:30
Gonéri Le Bouder
01ee3e603c helm: 'changed' flag takes 'values' in consideration (#332)
Return `changed` `False` is the `values_files` match the `values` of
the existing deployment.

Closes: #274
2021-01-05 13:53:20 -06:00
Gonéri Le Bouder
221631c06a helm: add support for the K8S_ envvars (#319)
Add support for:

- K8S_AUTH_HOST
- K8S_AUTH_API_KEY
- K8S_AUTH_VERIFY_SSL
- K8S_AUTH_SSL_CA_CERT

This commit also refactor the way we pass K8S related configuration to `helm`:

All the calls are now done in a new module_utils module (`helm.py`).
The handling of the `kube_*` variables has also been moved in this new
module.

We need https://github.com/helm/helm/pull/8622 to be able to ignore the
certificate validation. As a workaround, the generate a temporary
kubeconfig configuration file.

Closes: #279
2020-12-11 11:41:08 -05:00