c12s-kubespray/scripts/collect-info.yaml
Bogdan Dobrelya cf7c60029b Label k8s apps, adjust collect/upload info steps
- Drop debugs from collect-info playbook
- Drop sudo from collect-info step and add target dir var (required for travis jobs)
- Label all k8s apps, including static manifests
- Add logs for K8s apps to be collected as well
- Fix upload to GCS as a public-read tarball

Signed-off-by: Bogdan Dobrelya <bdobrelia@mirantis.com>
2016-11-10 16:05:50 +01:00

103 lines
3.9 KiB
YAML

---
- hosts: all
become: false
gather_facts: no
vars:
commands:
- name: timedate_info
cmd: timedatectl status
- name: kernel_info
cmd: uname -r
- name: docker_info
cmd: 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 --utc --no-pager
- name: etcd_info
cmd: etcdctl --debug cluster-health
- name: weave_info
cmd: weave report | jq "."
- name: weave_logs
cmd: docker logs weave > weave.log
- name: kubedns_logs
cmd: sh -c "for i in `kubectl get pods --all-namespaces -l k8s-app=kubedns -o name`;
do kubectl logs $i --namespace kube-system kubedns > kubedns.log; done"
- name: apiserver_logs
cmd: sh -c "for i in `kubectl get pods --all-namespaces -l k8s-app=kube-apiserver -o name`;
do kubectl logs $i --namespace kube-system > kube-apiserver.log; done"
- name: controller_logs
cmd: sh -c "for i in `kubectl get pods --all-namespaces -l k8s-app=kube-controller -o name`;
do kubectl logs $i --namespace kube-system > kube-controller.log; done"
- name: scheduler_logs
cmd: sh -c "for i in `kubectl get pods --all-namespaces -l k8s-app=kube-scheduler -o name`;
do kubectl logs $i --namespace kube-system > kube-scheduler.log; done"
- name: proxy_logs
cmd: sh -c "for i in `kubectl get pods --all-namespaces -l k8s-app=kube-proxy -o name`;
do kubectl logs $i --namespace kube-system > kube-proxy.log; done"
- name: nginx_logs
cmd: sh -c "for i in `kubectl get pods --all-namespaces -l k8s-app=kube-nginx -o name`;
do kubectl logs $i --namespace kube-system > kube-nginx.log; done"
- name: flannel_logs
cmd: sh -c "for i in `kubectl get pods --all-namespaces -l app=flannel -o name`;
do kubectl logs $i --namespace kube-system flannel-container > flannel.log; done"
- name: canal_logs
cmd: sh -c "for i in `kubectl get pods --all-namespaces -l k8s-app=canal-node -o name`;
do kubectl logs $i --namespace kube-system flannel > flannel.log; done"
- name: calico_policy_logs
cmd: sh -c "for i in `kubectl get pods --all-namespaces -l k8s-app=calico-policy -o name`;
do kubectl logs $i --namespace kube-system calico-policy-controller > calico-policy-controller.log; 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
- weave.log
- kubedns.log
- kube-apiserver.log
- kube-controller.log
- kube-scheduler.log
- kube-proxy.log
- kube-nginx.log
- flannel.log
- calico-policy-controller.log
tasks:
- name: Storing commands output
shell: "{{ item.cmd }} 2>&1 | tee {{ item.name }}"
register: output
ignore_errors: true
with_items: "{{commands}}"
no_log: True
- name: Fetch results
fetch: src={{ item.name }} dest=/tmp/collect-info/commands
with_items: "{{commands}}"
- name: Fetch logs
fetch: src={{ item }} dest=/tmp/collect-info/logs
with_items: "{{logs}}"
- name: Pack results and logs
local_action: shell GZIP=-9 tar --remove-files -cvzf {{dir|default(".")}}/logs.tar.gz -C /tmp collect-info
run_once: true
- name: Clean up collected command outputs
file: path={{ item.name }} state=absent
with_items: "{{commands}}"