[kubernetes] logging and troubleshooting

# 로깅과 트러블슈팅 (logging and troubleshooting)

1. shell을 통한 Linux troubleshooting
2. 기본 monitoring 활성화
3. Set up cluster-wide logging
4. 외부 제품들 이용 (Fluentd, prometheus)
5. 내부 Metrics Server and API


# 트러블슈팅을 위한 기본 단계

1. 가장 먼저 Error 라인을 확인

2. Pod 상태Pod 로그 확인
   - kubectl get pod
   - kubectl describe (하단에 이유를 리턴해 주는 경우도 있기 때문에)
   - kubectl logs pod

3. Pod DNSnetwork 확인
   - core dns 동작 이상여부, 네트워크 체크
   - 만약 calico를 예를 들면 calico 관련 pod 들이 정상 동작하는지, 각 노드들에 calico pod가 정상 동작 하는지등 점검

4. resource가 충분한지 체크등 Node log 확인
   - describe로 봤을때 resource 가 충분하지 않을 수도 있어 체크 필요

 

5. RBAC, SELinux or AppArmor security settings
   - role assign 여부 체크, 본인 활성화 여부, rule set 정책 확인

 

6. API calls to and from controllers to kube-apiserver

 

7. Enable auditing (모든 api 명령들을 auditing 할수 있음.)

8. Inter-node network issues, DNS and firewall

 

9. Master server controllers.
   - master 시스템 pod 들이 정상적인지 체크, 해당 시스템 로그로 체크 필요
   - Control Pods in pending or error state
   - Errors in log files
   - Enough resources


# Cluster Start 

1. systemd 를 통해 kubelet.sevice
   - Uses /etc/systmed/system/kubelet.service.d/10-kubeadm.conf
   - Uses /var/lib/kubelet/config.yaml config file
   - staticPodPath set to /etc/kubernetes/manifests/

 

2. staticPodPath의 *.yaml에 대한 static Pod 생성
   - 이곳에 설정파일, yaml 파일들이 있어 cluster 올라올때 자동으로 생성됨.
   - yaml 파일을 추가하면 바로 올라가고, yaml 파일을 빼면 바로 내려감
   - static Podapi-server, controller, scheduler, etcd가 있으며 kubelet이 pod 생성시 인증없이 올림.
   - static Pod는 master 라는 이름이 들어감

 

3. kube-controller-manager control loops use etcd data to start rest


# Monitoring

1. Enable the add-ons
2. Metrics Server and API
3. Prometheus


# Logging Tools

1. No cluster-wide logging in Kubernetes
2. Often aggregated and digested by outside tools like ElasticSearch
3. Fluentd
4. kibana


# Trobleshooting Resources

 

1. Official documentation
2. Major vendor pages
3. Github pages
4. Kubernetes Slack channel


https://kubernetes.io/docs/tasks/debug-application-cluster/troubleshooting/
https://kubernetes.io/docs/tasks/debug-application-cluster/debug-application
https://kubernetes.io/docs/tasks/debug-application-cluster/deubg-cluster
https://kubernetes.io/docs/tasks/debug-application-cluster/debug-pod-replecation-controller
https://kubernetes.io/docs/tasks/debug-application-cluster/debug-service
https://github.com/kubernetes/kubernetes/issue
https://kubernets.slack.com