如何查看k8s(kubernetes), scheduler组件日志,了解评分过程

1.打开/etc/kubernetes/manifests/kube-scheduler.yaml,设置日志等级为10

apiVersion: v1
kind: Pod
metadata:
  creationTimestamp: null
  labels:
    component: kube-scheduler
    tier: control-plane
  name: kube-scheduler
  namespace: kube-system
spec:
  containers:
  - command:
    - kube-scheduler
    - --authentication-kubeconfig=/etc/kubernetes/scheduler.conf
    - --authorization-kubeconfig=/etc/kubernetes/scheduler.conf
    - --bind-address=127.0.0.1
    - --kubeconfig=/etc/kubernetes/scheduler.conf
    - --leader-elect=true
    - --v=10											//日志等级设置为10
    image: registry.aliyuncs.com/google_containers/kube-scheduler:v1.24.0

2.使用命令部署如下deployment,进行测试

kubectl apply -f aff_pod.yaml

apiVersion: apps/v1
kind: Deployment
metadata:
  name: aff-pod
spec:
  selector:
    matchLabels:
      app: aff-pod
  replicas: 15
  template:
    metadata:
      labels:
        app: aff-pod
    spec:
      topologySpreadConstraints:
        - maxSkew: 1
          topologyKey: zone
          whenUnsatisfiable: ScheduleAnyway
          labelSelector:
            matchLabels:
              app: aff-pod
      containers:
      - name: with-node-affinity
        image: jackingqueen/testweb:0.0.1

3.查看scheduler日志,就能看到pod打分过程

kubectl logs kube-scheduler-k8s-master -n kube-system -f --tail=30 |grep score

部分日志如下:

I1014 05:50:42.935028       1 schedule_one.go:643] "Plugin scored node for pod" pod="default/aff-pod-678b64d849-fjmd6" plugin="VolumeBinding" node="k8s-node2" score=0
I1014 05:50:42.935050       1 schedule_one.go:643] "Plugin scored node for pod" pod="default/aff-pod-678b64d849-fjmd6" plugin="VolumeBinding" node="k8s-master" score=0
I1014 05:50:42.935071       1 schedule_one.go:643] "Plugin scored node for pod" pod="default/aff-pod-678b64d849-fjmd6" plugin="PodTopologySpread" node="k8s-node1" score=160
I1014 05:50:42.935092       1 schedule_one.go:643] "Plugin scored node for pod" pod="default/aff-pod-678b64d849-fjmd6" plugin="PodTopologySpread" node="k8s-node2" score=160
I1014 05:50:42.935113       1 schedule_one.go:643] "Plugin scored node for pod" pod="default/aff-pod-678b64d849-fjmd6" plugin="PodTopologySpread" node="k8s-master" score=200
I1014 05:50:42.935133       1 schedule_one.go:643] "Plugin scored node for pod" pod="default/aff-pod-678b64d849-fjmd6" plugin="InterPodAffinity" node="k8s-node1" score=0
I1014 05:50:42.935153       1 schedule_one.go:643] "Plugin scored node for pod" pod="default/aff-pod-678b64d849-fjmd6" plugin="InterPodAffinity" node="k8s-node2" score=0
I1014 05:50:42.935173       1 schedule_one.go:643] "Plugin scored node for pod" pod="default/aff-pod-678b64d849-fjmd6" plugin="InterPodAffinity" node="k8s-master" score=0
I1014 05:50:42.935201       1 schedule_one.go:701] "Calculated node's final score for pod" pod="default/aff-pod-678b64d849-fjmd6" node="k8s-node1" score=686
I1014 05:50:42.935222       1 schedule_one.go:701] "Calculated node's final score for pod" pod="default/aff-pod-678b64d849-fjmd6" node="k8s-node2" score=685
I1014 05:50:42.935257       1 schedule_one.go:701] "Calculated node's final score for pod" pod="default/aff-pod-678b64d849-fjmd6" node="k8s-master"score=699
I1014 05:50:42.942232       1 resource_allocation.go:70] "Listing internal info for allocatable resources, requested resources and score" pod="default/aff-pod-678b64d849-qd9zz" node="k8s-node2" resourceAllocationScorer="LeastAllocated" allocatableResource=map[cpu:4000 memory:8116240384] requestedResource=map[cpu:1350 memory:2516582400] resourceScore=67
I1014 05:50:42.942318       1 resource_allocation.go:70] "Listing internal info for allocatable resources, requested resources and score" pod="default/aff-pod-678b64d849-qd9zz" node="k8s-node2" resourceAllocationScorer="NodeResourcesBalancedAllocation" allocatableResource=map[cpu:4000 memory:8116240384] requestedResource=map[cpu:250 memory:0] resourceScore=96
I1014 05:50:42.942042       1 resource_allocation.go:70] "Listing internal info for allocatable resources, requested resources and score" pod="default/aff-pod-678b64d849-qd9zz" node="k8s-master" resourceAllocationScorer="LeastAllocated" allocatableResource=map[cpu:4000 memory:16552931328] requestedResource=map[cpu:2900 memory:4865392640] resourceScore=48
I1014 05:50:42.942707       1 resource_allocation.go:70] "Listing internal info for allocatable resources, requested resources and score" pod="default/aff-pod-678b64d849-qd9zz" node="k8s-master" resourceAllocationScorer="NodeResourcesBalancedAllocation" allocatableResource=map[cpu:4000 memory:16552931328] requestedResource=map[cpu:1100 memory:251658240] resourceScore=87
I1014 05:50:42.942139       1 resource_allocation.go:70] "Listing internal info for allocatable resources, requested resources and score" pod="default/aff-pod-678b64d849-qd9zz" node="k8s-node1" resourceAllocationScorer="LeastAllocated" allocatableResource=map[cpu:4000 memory:8114462720] requestedResource=map[cpu:1350 memory:2401239040] resourceScore=68
I1014 05:50:42.942804       1 resource_allocation.go:70] "Listing internal info for allocatable resources, requested resources and score" pod="default/aff-pod-678b64d849-qd9zz" node="k8s-node1" resourceAllocationScorer="NodeResourcesBalancedAllocation" allocatableResource=map[cpu:4000 memory:8114462720] requestedResource=map[cpu:350 memory:94371840] resourceScore=96
I1014 05:50:42.942983       1 schedule_one.go:643] "Plugin scored node for pod" pod="default/aff-pod-678b64d849-qd9zz" plugin="ImageLocality" node="k8s-master" score=62
I1014 05:50:42.943023       1 schedule_one.go:643] "Plugin scored node for pod" pod="default/aff-pod-678b64d849-qd9zz" plugin="ImageLocality" node="k8s-node1" score=62
I1014 05:50:42.943048       1 schedule_one.go:643] "Plugin scored node for pod" pod="default/aff-pod-678b64d849-qd9zz" plugin="ImageLocality" node="k8s-node2" score=62
I1014 05:50:42.943073       1 schedule_one.go:643] "Plugin scored node for pod" pod="default/aff-pod-678b64d849-qd9zz" plugin="TaintToleration" node="k8s-master" score=300
I1014 05:50:42.947175       1 schedule_one.go:643] "Plugin scored node for pod" pod="default/aff-pod-678b64d849-qd9zz" plugin="TaintToleration" node="k8s-node1" score=300
I1014 05:50:42.947222       1 schedule_one.go:643] "Plugin scored node for pod" pod="default/aff-pod-678b64d849-qd9zz" plugin="TaintToleration" node="k8s-node2" score=300
I1014 05:50:42.947250       1 schedule_one.go:643] "Plugin scored node for pod" pod="default/aff-pod-678b64d849-qd9zz" plugin="NodeAffinity" node="k8s-master" score=0
I1014 05:50:42.947275       1 schedule_one.go:643] "Plugin scored node for pod" pod="default/aff-pod-678b64d849-qd9zz" plugin="NodeAffinity" node="k8s-node1" score=0
I1014 05:50:42.947299       1 schedule_one.go:643] "Plugin scored node for pod" pod="default/aff-pod-678b64d849-qd9zz" plugin="NodeAffinity" node="k8s-node2" score=0
I1014 05:50:42.947324       1 schedule_one.go:643] "Plugin scored node for pod" pod="default/aff-pod-678b64d849-qd9zz" plugin="NodeResourcesFit" node="k8s-master" score=48
I1014 05:50:42.947347       1 schedule_one.go:643] "Plugin scored node for pod" pod="default/aff-pod-678b64d849-qd9zz" plugin="NodeResourcesFit" node="k8s-node1" score=68
I1014 05:50:42.947370       1 schedule_one.go:643] "Plugin scored node for pod" pod="default/aff-pod-678b64d849-qd9zz" plugin="NodeResourcesFit" node="k8s-node2" score=67
I1014 05:50:42.947396       1 schedule_one.go:643] "Plugin scored node for pod" pod="default/aff-pod-678b64d849-qd9zz" plugin="VolumeBinding" node="k8s-master" score=0
I1014 05:50:42.947420       1 schedule_one.go:643] "Plugin scored node for pod" pod="default/aff-pod-678b64d849-qd9zz" plugin="VolumeBinding" node="k8s-node1" score=0
I1014 05:50:42.947443       1 schedule_one.go:643] "Plugin scored node for pod" pod="default/aff-pod-678b64d849-qd9zz" plugin="VolumeBinding" node="k8s-node2" score=0
I1014 05:50:42.947466       1 schedule_one.go:643] "Plugin scored node for pod" pod="default/aff-pod-678b64d849-qd9zz" plugin="PodTopologySpread" node="k8s-master" score=200
I1014 05:50:42.947492       1 schedule_one.go:643] "Plugin scored node for pod" pod="default/aff-pod-678b64d849-qd9zz" plugin="PodTopologySpread" node="k8s-node1" score=200
I1014 05:50:42.947515       1 schedule_one.go:643] "Plugin scored node for pod" pod="default/aff-pod-678b64d849-qd9zz" plugin="PodTopologySpread" node="k8s-node2" score=200
I1014 05:50:42.947541       1 schedule_one.go:643] "Plugin scored node for pod" pod="default/aff-pod-678b64d849-qd9zz" plugin="InterPodAffinity" node="k8s-master" score=0
I1014 05:50:42.947564       1 schedule_one.go:643] "Plugin scored node for pod" pod="default/aff-pod-678b64d849-qd9zz" plugin="InterPodAffinity" node="k8s-node1" score=0
I1014 05:50:42.947587       1 schedule_one.go:643] "Plugin scored node for pod" pod="default/aff-pod-678b64d849-qd9zz" plugin="InterPodAffinity" node="k8s-node2" score=0
I1014 05:50:42.947611       1 schedule_one.go:643] "Plugin scored node for pod" pod="default/aff-pod-678b64d849-qd9zz" plugin="NodeResourcesBalancedAllocation" node="k8s-master" score=87
I1014 05:50:42.947635       1 schedule_one.go:643] "Plugin scored node for pod" pod="default/aff-pod-678b64d849-qd9zz" plugin="NodeResourcesBalancedAllocation" node="k8s-node1" score=96
I1014 05:50:42.947658       1 schedule_one.go:643] "Plugin scored node for pod" pod="default/aff-pod-678b64d849-qd9zz" plugin="NodeResourcesBalancedAllocation" node="k8s-node2" score=96
I1014 05:50:42.947691       1 schedule_one.go:701] "Calculated node's final score for pod" pod="default/aff-pod-678b64d849-qd9zz" node="k8s-master"score=697
I1014 05:50:42.947716       1 schedule_one.go:701] "Calculated node's final score for pod" pod="default/aff-pod-678b64d849-qd9zz" node="k8s-node1" score=726
I1014 05:50:42.947740       1 schedule_one.go:701] "Calculated node's final score for pod" pod="default/aff-pod-678b64d849-qd9zz" node="k8s-node2" score=725
posted @ 2022-10-14 15:00  脑袋有点大  阅读(1679)  评论(0编辑  收藏  举报