forked from kubernetes-sigs/kubespray
-
Notifications
You must be signed in to change notification settings - Fork 0
/
collect-info.yaml
128 lines (118 loc) · 4.96 KB
/
collect-info.yaml
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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
---
- hosts: all
become: true
gather_facts: no
vars:
docker_bin_dir: /usr/bin
bin_dir: /usr/local/bin
system_namespace: kube-system
ansible_ssh_pipelining: true
etcd_cert_dir: /etc/ssl/etcd/ssl
commands:
- name: timedate_info
cmd: timedatectl status
- name: kernel_info
cmd: uname -r
- name: docker_info
cmd: "{{ docker_bin_dir }}/docker info"
- name: ip_info
cmd: ip -4 -o a
- name: route_info
cmd: ip ro
- name: proc_info
cmd: ps auxf | grep -v ]$
- name: systemctl_failed_info
cmd: systemctl --state=failed --no-pager
- name: k8s_info
cmd: kubectl get all --all-namespaces -o wide
- name: errors_info
cmd: journalctl -p err --no-pager
- name: etcd_info
cmd: etcdctl --peers={{ etcd_access_addresses | default("http://127.0.0.1:2379") }} cluster-health
- name: calico_info
cmd: "{{bin_dir}}/calicoctl node status"
- name: calico_workload_info
cmd: "{{bin_dir}}/calicoctl get workloadEndpoint -o wide"
- name: calico_pool_info
cmd: "{{bin_dir}}/calicoctl get ippool -o wide"
- name: weave_info
cmd: weave report
- name: weave_logs
cmd: "{{ docker_bin_dir }}/docker logs weave"
- name: kube_describe_all
cmd: kubectl describe all --all-namespaces
- name: kube_describe_nodes
cmd: kubectl describe nodes
- name: kubelet_logs
cmd: journalctl -u kubelet --no-pager
- name: kubedns_logs
cmd: "for i in `kubectl get pods --all-namespaces -l k8s-app=kubedns -o jsonpath={.items..metadata.name}`;
do kubectl logs ${i} --namespace {{system_namespace}} kubedns; done"
- name: apiserver_logs
cmd: "for i in `kubectl get pods --all-namespaces -l k8s-app=kube-apiserver -o jsonpath={.items..metadata.name}`;
do kubectl logs ${i} --namespace {{system_namespace}}; done"
- name: controller_logs
cmd: "for i in `kubectl get pods --all-namespaces -l k8s-app=kube-controller -o jsonpath={.items..metadata.name}`;
do kubectl logs ${i} --namespace {{system_namespace}}; done"
- name: scheduler_logs
cmd: "for i in `kubectl get pods --all-namespaces -l k8s-app=kube-scheduler -o jsonpath={.items..metadata.name}`;
do kubectl logs ${i} --namespace {{system_namespace}}; done"
- name: proxy_logs
cmd: "for i in `kubectl get pods --all-namespaces -l k8s-app=kube-proxy -o jsonpath={.items..metadata.name}`;
do kubectl logs ${i} --namespace {{system_namespace}}; done"
- name: nginx_logs
cmd: "for i in `kubectl get pods --all-namespaces -l k8s-app=kube-nginx -o jsonpath={.items..metadata.name}`;
do kubectl logs ${i} --namespace {{system_namespace}}; done"
- name: flannel_logs
cmd: "for i in `kubectl get pods --all-namespaces -l app=flannel -o jsonpath={.items..metadata.name}`;
do kubectl logs ${i} --namespace {{system_namespace}} flannel-container; done"
- name: canal_logs
cmd: "for i in `kubectl get pods --all-namespaces -l k8s-app=canal-node -o jsonpath={.items..metadata.name}`;
do kubectl logs ${i} --namespace {{system_namespace}} flannel; done"
- name: calico_policy_logs
cmd: "for i in `kubectl get pods --all-namespaces -l k8s-app=calico-policy -o jsonpath={.items..metadata.name}`;
do kubectl logs ${i} --namespace {{system_namespace}} calico-policy-controller; done"
logs:
- /var/log/syslog
- /var/log/daemon.log
- /var/log/kern.log
- /var/log/dpkg.log
- /var/log/apt/history.log
- /var/log/yum.log
- /var/log/calico/bird/current
- /var/log/calico/bird6/current
- /var/log/calico/felix/current
- /var/log/calico/confd/current
environment:
ETCDCTL_CERT_FILE: "{{ etcd_cert_dir }}/node-{{ inventory_hostname }}.pem"
ETCDCTL_KEY_FILE: "{{ etcd_cert_dir }}/node-{{ inventory_hostname }}-key.pem"
tasks:
- set_fact:
etcd_access_addresses: |-
{% for item in groups['etcd'] -%}
https://{{ item }}:2379{% if not loop.last %},{% endif %}
{%- endfor %}
when: "'etcd' in groups"
- name: Storing commands output
shell: "{{ item.cmd }} 2>&1 | tee {{ item.name }}"
failed_when: false
with_items: "{{commands}}"
no_log: True
- name: Fetch results
fetch: src={{ item.name }} dest=/tmp/collect-info/commands
with_items: "{{commands}}"
failed_when: false
- name: Fetch logs
fetch: src={{ item }} dest=/tmp/collect-info/logs
with_items: "{{logs}}"
- name: Pack results and logs
archive:
path: "/tmp/collect-info"
dest: "{{ dir|default('.') }}/logs.tar.gz"
remove: true
delegate_to: localhost
become: false
run_once: true
- name: Clean up collected command outputs
file: path={{ item.name }} state=absent
with_items: "{{commands}}"