* 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
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.
* 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
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
The `wait_condition.status` key is a string.
- Use actually string in the documentation
- Use core's `boolean()` method to convert the value internally to
boolean
* Make an AnsibleMixin parent class for every module
* Replace KubernetesAnsibleModule class with dummy class
* Modified k8s_log
* k8s_exec refactor
* k8s_info refactor
* k8s_service refactor
* k8s_scale refactor
* Fix integration tests
* Add a warning about the deprecation of KubernetesAnsibleModule
* Add a dummy class for backward compatibility
Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
When the diff contains changes only to the fields `metadata.generation`
or `metadata.resourceVersion`, do not mark the task as changed. Instead,
emit a warning highlighting that the API itself may not be
idempotent, but that there was no meaningful difference between the
desired and actual state of the resource.
kind can be provided by number of ways. It is diffcult to
find all cases. So, handle exceptions raised by underlying
APIs and provide good error message to user.
Fixes: ansible/ansible#63652
Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
check_mode with wait updates the result based on the existing resource
which won't change with check_mode, so returns incorrect results.
Only run the wait checks in non check_mode (this also avoids the issue
of waiting for resource creation that will never happen in check mode)
Any kubernetes manifest file ending with '---' will
generate an error when applied using 'k8s' module.
Although this may not be 'legal' YAML, this is quite frequent,
specially on helm's generated manifest files.
migrated from https://github.com/ansible/ansible/pull/59160
Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
Provide message to user about invalid or empty kubeconfig
by handling exception raised by kubernetes Python API
Fixes: #90
Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
Use information from strategic merges to improve
the quality of diffs, particularly for list items
(order no longer important, and adding/removing an
item from a list just shows that item in the diff,
not the whole list)
Move wait logic out of raw and into common and use that
logic in scale
Fix a few broken wait condition cases highlighted by scaling
up and down
Move scale-related tests into dedicated test task file
Additional service related tests
Ensure that Deployments and Daemonsets properly await
all replicas to be available. Correctly handles the
subtle edge case when a service account no longer exists.
Note that this will dramatically slow Daemonset updates
When the ansible k8s module is refreshing the tokens from the local kube
config, it should save those token to the kube config file.
If this is not done, this might break the next kube client call as the
token in the local kube config file is not valid anymore and refreshing
can fail.
This commit is adding an env var K8S_AUTH_PERSIST_CONFIG that can be
used to set this flag to true (default is false, same as current
behavior).