Skip to content

Instantly share code, notes, and snippets.

@cwilkers
Created February 14, 2019 16:34
Show Gist options
  • Save cwilkers/9f41b5b588c8ad6e3fe8d964dcc14874 to your computer and use it in GitHub Desktop.
Save cwilkers/9f41b5b588c8ad6e3fe8d964dcc14874 to your computer and use it in GitHub Desktop.
Return all custom types created by a CRD with a certain group name (*.federation.k8s.io)
---
- name: Backup federation control plane on master cluster
hosts: federation
tasks:
- name: Read CRDs
command:
argv:
- oc
- --context={{federation_context}}
- get
- customresourcedefinitions
- -o
- json
register: all_crds
- set_fact:
federated_types: "{{ federated_types | default ([]) + [ item ]}}"
vars:
query: "items[?contains(spec.group, 'federation.k8s.io')].metadata.name"
loop: "{{ all_crds.stdout | from_json | json_query(query) }}"
- debug:
var: federated_types
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment