In replicating the openshift client functionality we forgot to bring
over a fix for multiple resources with the same group version and kind.
This is specifically a problem for openshift templates.
* Account for updated pods when waiting on DaemonSet
The exising logic that's used to determine when a DaemonSet is ready
fails to account for the fact that a RollingUpdate first kills the pod
and then creates a new one. Simply checking if the
desiredNumberScheduled equals the numberReady will succeed in cases
when the old pod takes time to shut down, and would report that the new
Deployment is ready despite the fact that the old pod has not been
replaced, yet.
* Add changelog fragment
* Replace openshift client with kubernetes client
This commit primarily just removes mentions of openshift from the docs
and updates the requirements. Most of the work to replace the client has
been done through the following commits:
edc48ee577c214376cac48c51700182b6a989cf9
* Add changelog fragment
* Update changelogs/fragments/96-replace-openshift-client.yaml
Co-authored-by: Abhijeet Kasurde <akasurde@redhat.com>
* Update plugins/modules/k8s.py
Co-authored-by: Abhijeet Kasurde <akasurde@redhat.com>
* Update plugins/modules/k8s_info.py
Co-authored-by: Abhijeet Kasurde <akasurde@redhat.com>
* Update plugins/modules/k8s_service.py
Co-authored-by: Abhijeet Kasurde <akasurde@redhat.com>
* Bump minimum kubernetes version to 12.0.0
Co-authored-by: Abhijeet Kasurde <akasurde@redhat.com>
* Replicate base resource for lists functionality
This replicates specific functionality from the openshift client to more
reliably retrieve the base resource from a resource list.
* Add changelog fragment
- enable the AnsibleTurboModule: Use AnsibleTurboModule when the `cloud.common` collection is available.
- Add dependency install step to molecule: Molecule won't install dependencies from galaxy.yml. We need to explicitly list them in a requirements.yml file and then enable the dependency step for molecule test.
* Fix client regression from turbo mode refactor
The turbo mode refactoring introduced a regression where the kubernetes
client can fail to find the kubeconfig. This happens because
get_api_client is called twice and the second time it is called without
the module being passed as an argument. Without this, the configuration
will use defaults. This will be a problem if the user has specified a
location for the kubeconfig that's different from default, for example.
* Add tests
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>
* 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
* 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>
* 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>