-
Notifications
You must be signed in to change notification settings - Fork 0
/
openshift-gvk-comparison.yml
101 lines (93 loc) · 5.32 KB
/
openshift-gvk-comparison.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
- hosts: localhost
gather_facts: false
tasks:
- name: Fail if SRC_KUBECONFIG or DST_KUBECONFIG is not set
ansible.builtin.fail:
msg: "Please export SRC_KUBECONFIG and DST_KUBECONFIG for your clusters"
when: >
lookup('ansible.builtin.env', 'SRC_KUBECONFIG') == "" or
lookup('ansible.builtin.env', 'DST_KUBECONFIG') == ""
- name: Retrieve SRC GVKs
kubernetes.core.k8s_cluster_info:
kubeconfig: "{{ lookup('ansible.builtin.env', 'SRC_KUBECONFIG') }}"
validate_certs: false
register: src_api_status
- name: Load SRC GVKs
ansible.builtin.set_fact:
src_gvks: "{{ src_gvks | default([]) + [ _task.task.kind.name | string + '.' + _task.task.api_version | string] }}"
loop: >-
{{
src_api_status.apis.keys()
| zip(src_api_status.apis.values() | map('dict2items'))
| subelements([1])
}}
loop_control:
label: "{{ item.0.0 }} — {{ item.1.key }}"
vars:
_task:
task:
kind: "{{ item.1.value }}"
group: "{{ item.1.key }}"
api_version: "{{ item.0.0 }}"
- name: Retrieve DST GVKs
kubernetes.core.k8s_cluster_info:
kubeconfig: "{{ lookup('ansible.builtin.env', 'DST_KUBECONFIG') }}"
validate_certs: false
register: dst_api_status
- name: Load DST GVKs
ansible.builtin.set_fact:
dst_gvks: "{{ dst_gvks | default([]) + [ _task.task.kind.name | string + '.' + _task.task.api_version | string] }}"
loop: >-
{{
dst_api_status.apis.keys()
| zip(dst_api_status.apis.values() | map('dict2items'))
| subelements([1])
}}
loop_control:
label: "{{ item.0.0 }} — {{ item.1.key }}"
vars:
_task:
task:
kind: "{{ item.1.value }}"
group: "{{ item.1.key }}"
api_version: "{{ item.0.0 }}"
- name: Locate GVKs absent on DST
ansible.builtin.set_fact:
unhandled_gvks: "{{ unhandled_gvks | default([]) + [item] }}"
with_items: "{{ src_gvks }}"
when:
- item not in dst_gvks
- item != "deployments.extensions/v1beta1" # Cohabitating resource
- item != "daemonsets.extensions/v1beta1" # Cohabitating resource
- item != "replicasets.extensions/v1beta1" # Cohabitating resource
- item != "networkpolicies.extensions/v1beta1" # Cohabitating resource
- item != "events.events.k8s.io/v1beta1" # Cohabitating resource
- item != "deployments.apps/v1beta2" # Velero can restore version in common: deployments.apps/v1
- item != "daemonsets.apps/v1beta2" # Velero can restore version in common: daemonsets.apps/v1
- item != "apiservices.apiregistration.k8s.io/v1beta1" # Velero can restore version in common: apiservices.apiregistration.k8s.io/v1
- item != "controllerrevisions.apps/v1beta2" # Velero can restore version in common: controllerrevisions.apps/v1
- item != "controllerrevisions.apps/v1beta1" # Velero can restore version in common: controllerrevisions.apps/v1
- item != "replicasets.apps/v1beta2" # Velero can restore version in common: replicasets.apps/v1
- item != "statefulsets.apps/v1beta2" # Velero can restore version in common: statefulsets.apps/v1
- item != "statefulsets.apps/v1beta1" # Velero can restore version in common: statefulsets.apps/v1
- item != "deployments.apps/v1beta1" # Velero can restore version in common: deployments.apps/v1
- item != "tokenreviews.authentication.k8s.io/v1beta1" # Velero can restore version in common: tokenreviews.authentication.k8s.io/v1
- item != "localsubjectaccessreviews.authorization.k8s.io/v1beta1" # Velero can restore version in common: localsubjectaccessreviews.authorization.k8s.io/v1
- item != "selfsubjectaccessreviews.authorization.k8s.io/v1beta1" # Velero can restore version in common: selfsubjectaccessreviews.authorization.k8s.io/v1
- item != "selfsubjectrulesreviews.authorization.k8s.io/v1beta1" # Velero can restore version in common: selfsubjectrulesreviews.authorization.k8s.io/v1
- item != "subjectaccessreviews.authorization.k8s.io/v1beta1" # Velero can restore version in common: subjectaccessreviews.authorization.k8s.io/v1
- item != "clusterrolebindings.rbac.authorization.k8s.io/v1beta1" # Velero can restore version in common: clusterrolebindings.rbac.authorization.k8s.io/v1
- item != "clusterroles.rbac.authorization.k8s.io/v1beta1" # Velero can restore version in common: clusterroles.rbac.authorization.k8s.io/v1
- item != "rolebindings.rbac.authorization.k8s.io/v1beta1" # Velero can restore version in common: rolebindings.rbac.authorization.k8s.io/v1
- item != "roles.rbac.authorization.k8s.io/v1beta1" # Velero can restore version in common: roles.rbac.authorization.k8s.io/v1
- item != "storageclasses.storage.k8s.io/v1beta1" # Velero can restore version in common: storageclasses.storage.k8s.io/v1
- item != "cronjobs.batch/v1beta1" # Compat conversion https://github.com/migtools/mig-controller/pull/1328
- name: Source Cluster GVKs
ansible.builtin.debug:
var: src_gvks
- name: Destination Cluster GVKs
ansible.builtin.debug:
var: dst_gvks
- name: Unhandled GVKs
ansible.builtin.debug:
var: unhandled_gvks