k8s_facts just does not work

40 views
Skip to first unread message

Nick-H

unread,
Apr 14, 2021, 4:09:59 PM4/14/21
to Ansible Project
well another thing I try and just does not work as per the doc 
the example from the official doc does not even work :

ansibe 2.8 / python3.6 , openshift / kubernetes pip modules 0.11 (0.12 is broken too).

- name: Search for all running pods
  k8s_facts:
    kind: Pod
    field_selectors:
      - status.phase = running


returns: 
Failure\",\"message\":\"field label not supported: status.phase \",\"reason\":\"BadRequest\",\"code\":400}

Why is that trying to get labels when we are talking fields ? 

I am ultimately trying to get infos on Deployments , but same thing field_selectors does not work at all .

anyone been using this module and the field_selectors parameters successfully ? 
thanks



Nick-H

unread,
Apr 14, 2021, 6:01:14 PM4/14/21
to Ansible Project
well it seems to be limited by k8s api itself , not sure field_selectors is very useful then .
json_query is needed to filter out results from the whole output from facts .
Maybe for now , it s better to use kubectl in the shell module 

Abhijeet Kasurde

unread,
Apr 15, 2021, 1:47:28 AM4/15/21
to ansible...@googlegroups.com
Hi,

The example is correct. There is no space around `=` in the field selector and there is 'R' is running in your code.

- k8s_info:
kind: pod
field_selectors:
- status.phase=Running
register: r




--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/cf20b835-d7af-4c3f-88c1-1f708bdf1888n%40googlegroups.com.


--
Thanks,
Abhijeet Kasurde
Reply all
Reply to author
Forward
0 new messages