Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How is the k8s inventory plugin being used? #31

Open
tima opened this issue Sep 8, 2020 · 5 comments
Open

How is the k8s inventory plugin being used? #31

tima opened this issue Sep 8, 2020 · 5 comments
Labels
type/question Further information is requested
Milestone

Comments

@tima
Copy link
Collaborator

tima commented Sep 8, 2020

In ansible-collections/community.kubernetes#217, @fabianvf made some modifications to the k8s inventory plugin that we believe improve its overall operation, cuts down on the "noise" and just makes more sense. This begs the question -- how is this plugin being used? Does this refactoring make sense? What is the impact, if any, of the changes? Are there other improvements to be made to help users?

ADDENDUM: Is this plugin needed at all or is it supporting an anti-pattern (Kubernetes should be managing containers in its cluster) that it should be deprecated and removed?

@Akasurde
Copy link
Member

@tima I can imagine as following -

# kubectl -n test get pods
NAME           READY   STATUS    RESTARTS   AGE
nginx-server   1/1     Running   0          9m43s

# cat k8s.yml
plugin: community.kubernetes.k8s
connections:
  - namespaces:
    - test

# cat main.yml
---
- hosts: all
  tasks:
    - shell: hostname

# ansible-playbook -i k8s.yml main.yml --limit namspace_test_pods -vv
...
TASK [shell] *******************************************************************
task path: /Volumes/data/src/playbooks/k8s/inventory/main.yml:4
redirecting (type: connection) ansible.builtin.kubectl to community.kubernetes.kubectl
changed: [nginx-server_nginx-server] => {"changed": true, "cmd": "hostname", "delta": "0:00:00.480764", "end": "2020-09-14 10:16:47.995239", "rc": 0, "start": "2020-09-14 10:16:47.514475", "stderr": "", "stderr_lines": [], "stdout": "nginx-server", "stdout_lines": ["nginx-server"]}
...

@tima tima pinned this issue Sep 29, 2020
@alinabuzachis
Copy link
Contributor

Hello @tima, this looks like a good candidate for the Bullhorn.

@abikouo abikouo unpinned this issue Mar 8, 2021
@tima tima pinned this issue Mar 9, 2021
@gravesm gravesm transferred this issue from ansible-collections/community.kubernetes Apr 8, 2021
@gravesm gravesm added this to the 2.0.0 milestone Apr 13, 2021
@jobcespedes
Copy link

Hi,

I also wonder if this is an anti pattern or not.

I have a use case where an app config is store in a secret for an Ansible based operator. The "native" options available in Kubernetes imply pod restart when config resource is changed. However, using Ansible, I could template the config resource in Kubernetes and keep in sync the respective file in all replicas, no pod restart needed. For that, the inventory plugin will be helpful.

For me, it seems an anti pattern from Kubernetes perspective. However, isn’t Ansible potential being limited without it? Wouldn’t Ansible become a template manager for Kubernetes?

@tima
Copy link
Collaborator Author

tima commented Jul 2, 2021

Sorry I didn't see your comment sooner @jobcespedes. Wouldn't one of the _info modules or even the k8s lookup provide you the same capabilities?

@tima tima added the type/question Further information is requested label Jul 2, 2021
@jobcespedes
Copy link

They do the work, along with add_host. However, once you have more than one use case, it does not feel right to use Ansible tasks to build inventories and it does not help reusability.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/question Further information is requested
Projects
None yet
Development

No branches or pull requests

5 participants