Dapr进阶-03-查看Dapr日志

1. 查看控制面日志

1.1. 查看控制面pod

kubectl get pod -n dapr-system
NAME                                    READY   STATUS    RESTARTS   AGE
dapr-dashboard-5b7dd7b657-2zkkh         1/1     Running   0          3h41m
dapr-operator-5654bb56b5-296wz          1/1     Running   0          3h41m
dapr-placement-server-0                 1/1     Running   0          3h41m
dapr-sentry-787dd7d995-kfxc9            1/1     Running   0          3h41m
dapr-sidecar-injector-c9498dbfb-q8lql   1/1     Running   0          3h41m

1.2. 查看dashboard日志

kubectl logs -l app=dapr-dashboard -n dapr-system
Dapr Dashboard running on http://localhost:8080

1.3. 查看operator日志 

kubectl logs -l app=dapr-operator -n dapr-system
{"instance":"dapr-operator-5654bb56b5-296wz","level":"info","msg":"getting tls certificates","scope":"dapr.operator","time":"2022-02-19T03:40:24.651194191Z","type":"log","ver":"1.6.0"}
{"instance":"dapr-operator-5654bb56b5-296wz","level":"info","msg":"starting watch for certs on filesystem: /var/run/dapr/credentials","scope":"dapr.operator","time":"2022-02-19T03:40:24.65123001Z","type":"log","ver":"1.6.0"}
I0219 03:40:24.649795       1 leaderelection.go:243] attempting to acquire leader lease dapr-system/webhooks.dapr.io...
{"instance":"dapr-operator-5654bb56b5-296wz","level":"info","msg":"Successfully patched webhook in CRD \"subscriptions.dapr.io\"","scope":"dapr.operator","time":"2022-02-19T03:40:24.665018551Z","type":"log","ver":"1.6.0"}
{"instance":"dapr-operator-5654bb56b5-296wz","level":"info","msg":"certificates detected","scope":"dapr.operator","time":"2022-02-19T03:40:26.542818142Z","type":"log","ver":"1.6.0"}
{"instance":"dapr-operator-5654bb56b5-296wz","level":"info","msg":"tls certificates loaded successfully","scope":"dapr.operator","time":"2022-02-19T03:40:26.542934089Z","type":"log","ver":"1.6.0"}
{"instance":"dapr-operator-5654bb56b5-296wz","level":"info","msg":"starting gRPC server","scope":"dapr.operator.api","time":"2022-02-19T03:40:26.543163223Z","type":"log","ver":"1.6.0"}
{"instance":"dapr-operator-5654bb56b5-296wz","level":"info","msg":"Healthz server is listening on :8080","scope":"dapr.operator","time":"2022-02-19T03:40:26.54321365Z","type":"log","ver":"1.6.0"}
I0219 03:40:40.238847       1 leaderelection.go:253] successfully acquired lease dapr-system/operator.dapr.io
I0219 03:40:40.515280       1 leaderelection.go:253] successfully acquired lease dapr-system/webhooks.dapr.io

1.4. 查看placement日志  

kubectl logs -l app=dapr-placement-server -n dapr-system

{"instance":"dapr-placement-server-0","level":"info","msg":"metrics server started on :9090/","scope":"dapr.metrics","time":"2022-02-19T03:40:25.032029995Z","type":"log","ver":"1.6.0"}
{"instance":"dapr-placement-server-0","level":"info","msg":"Raft server is starting on 127.0.0.1:8201...","scope":"dapr.placement.raft","time":"2022-02-19T03:40:25.032202627Z","type":"log","ver":"1.6.0"}
{"instance":"dapr-placement-server-0","level":"info","msg":"mTLS enabled, getting tls certificates","scope":"dapr.placement","time":"2022-02-19T03:40:25.032217652Z","type":"log","ver":"1.6.0"}
{"instance":"dapr-placement-server-0","level":"info","msg":"starting watch for certs on filesystem: /var/run/dapr/credentials","scope":"dapr.placement","time":"2022-02-19T03:40:25.032241757Z","type":"log","ver":"1.6.0"}
{"instance":"dapr-placement-server-0","level":"info","msg":"certificates detected","scope":"dapr.placement","time":"2022-02-19T03:40:26.543695359Z","type":"log","ver":"1.6.0"}
{"instance":"dapr-placement-server-0","level":"info","msg":"tls certificates loaded successfully","scope":"dapr.placement","time":"2022-02-19T03:40:26.543776867Z","type":"log","ver":"1.6.0"}
{"instance":"dapr-placement-server-0","level":"info","msg":"placement service started on port 50005","scope":"dapr.placement","time":"2022-02-19T03:40:26.543793794Z","type":"log","ver":"1.6.0"}
{"instance":"dapr-placement-server-0","level":"info","msg":"cluster leadership acquired","scope":"dapr.placement","time":"2022-02-19T03:40:26.544124116Z","type":"log","ver":"1.6.0"}
{"instance":"dapr-placement-server-0","level":"info","msg":"Healthz server is listening on :8080","scope":"dapr.placement","time":"2022-02-19T03:40:26.544172756Z","type":"log","ver":"1.6.0"}
{"instance":"dapr-placement-server-0","level":"info","msg":"leader is established.","scope":"dapr.placement","time":"2022-02-19T03:40:26.544193223Z","type":"log","ver":"1.6.0"}

 1.5. 查看sentry日志  

kubectl logs -l app=dapr-sentry -n dapr-system
{"instance":"dapr-sentry-787dd7d995-kfxc9","level":"info","msg":"Healthz server is listening on :8080","scope":"dapr.sentry","time":"2022-02-19T03:40:24.754579249Z","type":"log","ver":"1.6.0"}
{"instance":"dapr-sentry-787dd7d995-kfxc9","level":"warning","msg":"issuer credentials changed. reloading","scope":"dapr.sentry","time":"2022-02-19T03:40:26.542959438Z","type":"log","ver":"1.6.0"}
{"instance":"dapr-sentry-787dd7d995-kfxc9","level":"info","msg":"certificate authority loaded","scope":"dapr.sentry","time":"2022-02-19T03:40:26.543041398Z","type":"log","ver":"1.6.0"}
{"instance":"dapr-sentry-787dd7d995-kfxc9","level":"warning","msg":"issuer credentials changed. reloading","scope":"dapr.sentry","time":"2022-02-19T03:40:27.543136292Z","type":"log","ver":"1.6.0"}
{"instance":"dapr-sentry-787dd7d995-kfxc9","level":"info","msg":"trust root bundle loaded. issuer cert expiry: 2023-02-19 03:40:24 +0000 UTC","scope":"dapr.sentry","time":"2022-02-19T03:40:27.55143922Z","type":"log","ver":"1.6.0"}
{"instance":"dapr-sentry-787dd7d995-kfxc9","level":"info","msg":"validator created","scope":"dapr.sentry","time":"2022-02-19T03:40:27.55217503Z","type":"log","ver":"1.6.0"}
{"instance":"dapr-sentry-787dd7d995-kfxc9","level":"info","msg":"sentry certificate authority is running, protecting ya'll","scope":"dapr.sentry","time":"2022-02-19T03:40:27.552211046Z","type":"log","ver":"1.6.0"}
{"instance":"dapr-sentry-787dd7d995-kfxc9","level":"warning","msg":"issuer credentials changed. reloading","scope":"dapr.sentry","time":"2022-02-19T03:40:28.543219987Z","type":"log","ver":"1.6.0"}
{"instance":"dapr-sentry-787dd7d995-kfxc9","level":"warning","msg":"issuer credentials changed. reloading","scope":"dapr.sentry","time":"2022-02-19T03:40:29.543350066Z","type":"log","ver":"1.6.0"}
{"instance":"dapr-sentry-787dd7d995-kfxc9","level":"warning","msg":"issuer credentials changed. reloading","scope":"dapr.sentry","time":"2022-02-19T03:40:30.543436621Z","type":"log","ver":"1.6.0"}

  1.6. 查看injector日志

kubectl logs -l app=dapr-sidecar-injector -n dapr-system
{"instance":"node-slave","level":"info","msg":"Sidecar injector is listening on :4000, patching Dapr-enabled pods","scope":"dapr.injector","time":"2022-02-19T03:40:23.681036027Z","type":"log","ver":"1.6.0"}
{"instance":"node-slave","level":"info","msg":"AdmissionReview for Kind=/v1, Kind=Pod, Namespace=dapr-demo Name= () UID=0a42eb04-1906-400b-8439-28cfeb23d420 patchOperation=CREATE UserInfo={system:serviceaccount:kube-system:replicaset-controller fe3cd86c-80ed-407f-b9a5-83ab709863b9 [system:serviceaccounts system:serviceaccounts:kube-system system:authenticated] map[]}","scope":"dapr.injector","time":"2022-02-19T05:37:05.591106282Z","type":"log","ver":"1.6.0"}
{"instance":"node-slave","level":"info","msg":"AdmissionReview for Kind=/v1, Kind=Pod, Namespace=dapr-demo Name= () UID=55c8225b-ea68-42c2-baa5-e4cba3be3937 patchOperation=CREATE UserInfo={system:serviceaccount:kube-system:replicaset-controller fe3cd86c-80ed-407f-b9a5-83ab709863b9 [system:serviceaccounts system:serviceaccounts:kube-system system:authenticated] map[]}","scope":"dapr.injector","time":"2022-02-19T05:37:05.591419373Z","type":"log","ver":"1.6.0"}
{"instance":"node-slave","level":"info","msg":"ready to write response ...","scope":"dapr.injector","time":"2022-02-19T05:37:05.604812267Z","type":"log","ver":"1.6.0"}
{"instance":"node-slave","level":"info","msg":"ready to write response ...","scope":"dapr.injector","time":"2022-02-19T05:37:05.604844148Z","type":"log","ver":"1.6.0"}
{"instance":"node-slave","level":"info","msg":"Sidecar injector succeeded injection for app 'service01'","scope":"dapr.injector","time":"2022-02-19T05:37:05.60532952Z","type":"log","ver":"1.6.0"}
{"instance":"node-slave","level":"info","msg":"Sidecar injector succeeded injection for app 'service02'","scope":"dapr.injector","time":"2022-02-19T05:37:05.606280729Z","type":"log","ver":"1.6.0"}
{"instance":"node-slave","level":"info","msg":"AdmissionReview for Kind=/v1, Kind=Pod, Namespace=dapr-demo Name= () UID=354a2436-3702-4af3-83c0-73383a16ce4b patchOperation=CREATE UserInfo={system:serviceaccount:kube-system:replicaset-controller fe3cd86c-80ed-407f-b9a5-83ab709863b9 [system:serviceaccounts system:serviceaccounts:kube-system system:authenticated] map[]}","scope":"dapr.injector","time":"2022-02-19T05:37:05.617482582Z","type":"log","ver":"1.6.0"}
{"instance":"node-slave","level":"info","msg":"ready to write response ...","scope":"dapr.injector","time":"2022-02-19T05:37:05.6371212Z","type":"log","ver":"1.6.0"}
{"instance":"node-slave","level":"info","msg":"Sidecar injector succeeded injection for app 'service01'","scope":"dapr.injector","time":"2022-02-19T05:37:05.637204881Z","type":"log","ver":"1.6.0"}

2. 查看service pod日志

2.1. 查看service pod

kubectl get pods -n dapr-demo
NAME                         READY   STATUS             RESTARTS         AGE
service01-7cc7c54c65-g4jzw   1/2     CrashLoopBackOff   26 (2m22s ago)   111m
service01-7cc7c54c65-gsf8c   1/2     CrashLoopBackOff   26 (85s ago)     111m
service02-6d849d9f97-mk286   1/2     CrashLoopBackOff   26 (2m14s ago)   111m

2.2. 描述pod的整体信息

kubectl describe pod service01-7cc7c54c65-g4jzw -n dapr-demo
Name:         service01-7cc7c54c65-g4jzw
Namespace:    dapr-demo
Priority:     0
Node:         node-slave/192.168.0.204
Start Time:   Sat, 19 Feb 2022 13:37:05 +0800
Labels:       app=service01
              pod-template-hash=7cc7c54c65
Annotations:  dapr.io/app-id: service01
              dapr.io/app-port: 80
              dapr.io/enable-debug: true
              dapr.io/enabled: true
              dapr.io/log-as-json: true
              dapr.io/sidecar-liveness-probe-delay-seconds: 10
              dapr.io/sidecar-readiness-probe-delay-seconds: 10
Status:       Running
IP:           10.44.0.5
IPs:
  IP:           10.44.0.5
Controlled By:  ReplicaSet/service01-7cc7c54c65
Containers:
  service01:
    Container ID:   docker://e875b665df3b0ce52e07635ac587ae1406ff9e208d197083b5ad921eb3edde46
    Image:          docker.io/k8schina/service01:v1
    Image ID:       docker-pullable://k8schina/service01@sha256:8ead4a7aa2eac005badfbac0c615b2be930aada2a17994e7891b720c62da2abb
    Port:           80/TCP
    Host Port:      0/TCP
    State:          Running
      Started:      Sat, 19 Feb 2022 13:37:25 +0800
    Ready:          True
    Restart Count:  0
    Environment:
      DAPR_HTTP_PORT:  3500
      DAPR_GRPC_PORT:  50001
    Mounts:
      /var/run/secrets/kubernetes.io/serviceaccount from kube-api-access-s2f8g (ro)
  daprd:
    Container ID:  docker://4cf1fac4f809945132bcb28f00b62bd974c1036c32f56b56781fa3cd958f8dd1
    Image:         docker.io/daprio/daprd:1.6.0
    Image ID:      docker-pullable://daprio/daprd@sha256:db7ce4723d61566a2e6be24bd7d136e317023cf11ee78b9c6f55c00ec0c6223f
    Ports:         3500/TCP, 50001/TCP, 50002/TCP, 9090/TCP, 40000/TCP
    Host Ports:    0/TCP, 0/TCP, 0/TCP, 0/TCP, 0/TCP
    Command:
      /dlv
    Args:
      --listen=:40000
      --accept-multiclient
      --headless=true
      --log
      --api-version=2
      exec
      /daprd
      --
      --mode
      kubernetes
      --dapr-http-port
      3500
      --dapr-grpc-port
      50001
      --dapr-internal-grpc-port
      50002
      --dapr-listen-addresses
      [::1],127.0.0.1
      --dapr-public-port
      3501
      --app-port
      80
      --app-id
      service01
      --control-plane-address
      dapr-api.dapr-system.svc.cluster.local:80
      --app-protocol
      http
      --placement-host-address
      dapr-placement-server.dapr-system.svc.cluster.local:50005
      --config

      --log-level
      info
      --app-max-concurrency
      -1
      --sentry-address
      dapr-sentry.dapr-system.svc.cluster.local:80
      --enable-metrics=true
      --metrics-port
      9090
      --dapr-http-max-request-size
      -1
      --dapr-http-read-buffer-size
      -1
      --dapr-graceful-shutdown-seconds
      -1
      --log-as-json
      --enable-mtls
    State:          Waiting
      Reason:       CrashLoopBackOff
    Last State:     Terminated
      Reason:       ContainerCannotRun
      Message:      OCI runtime create failed: container_linux.go:380: starting container process caused: exec: "/dlv": stat /dlv: no such file or directory: unknown
      Exit Code:    127
      Started:      Sat, 19 Feb 2022 16:01:45 +0800
      Finished:     Sat, 19 Feb 2022 16:01:45 +0800
    Ready:          False
    Restart Count:  33
    Liveness:       http-get http://:3501/v1.0/healthz delay=10s timeout=3s period=6s #success=1 #failure=3
    Readiness:      http-get http://:3501/v1.0/healthz delay=10s timeout=3s period=6s #success=1 #failure=3
    Environment:
      NAMESPACE:              dapr-demo
      DAPR_TRUST_ANCHORS:     -----BEGIN CERTIFICATE-----
                              MIIB2zCCAYKgAwIBAgIRAMWpJtBC5uk9Folb7dBap/0wCgYIKoZIzj0EAwIwMTEX
                              MBUGA1UEChMOZGFwci5pby9zZW50cnkxFjAUBgNVBAMTDWNsdXN0ZXIubG9jYWww
                              HhcNMjIwMjE5MDMyNTI0WhcNMjMwMjE5MDM0MDI0WjAxMRcwFQYDVQQKEw5kYXBy
                              LmlvL3NlbnRyeTEWMBQGA1UEAxMNY2x1c3Rlci5sb2NhbDBZMBMGByqGSM49AgEG
                              CCqGSM49AwEHA0IABFe0HFo8WfhDK3UzH84uh3ra9veCh4YBUH3eLD7XaaDR/gnG
                              K28DDP+P6YMVzhV0/sWe2/Ztr2ggQmWensD09K2jezB5MA4GA1UdDwEB/wQEAwIC
                              BDAdBgNVHSUEFjAUBggrBgEFBQcDAQYIKwYBBQUHAwIwDwYDVR0TAQH/BAUwAwEB
                              /zAdBgNVHQ4EFgQUCMQ2YWm8hnbar1tunG0+zkyehn0wGAYDVR0RBBEwD4INY2x1
                              c3Rlci5sb2NhbDAKBggqhkjOPQQDAgNHADBEAiB+v/xvuHpKwkyTvdLDjFLEStRP
                              GcqVXqp5WbMlFs2JTwIgVR3ehcuItyV872tFUYFCISbiARGxbJzgPs9OQnvHjPM=
                              -----END CERTIFICATE-----

      DAPR_CERT_CHAIN:        -----BEGIN CERTIFICATE-----
                              MIIBxjCCAWugAwIBAgIRAIXuoUC5KTyCXjVOdmbhI1UwCgYIKoZIzj0EAwIwMTEX
                              MBUGA1UEChMOZGFwci5pby9zZW50cnkxFjAUBgNVBAMTDWNsdXN0ZXIubG9jYWww
                              HhcNMjIwMjE5MDMyNTI0WhcNMjMwMjE5MDM0MDI0WjAYMRYwFAYDVQQDEw1jbHVz
                              dGVyLmxvY2FsMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEeGahgXjsvOXPIkAW
                              opUtFHvvBUNFWkmDyxdllNVJKvH6X0JYmW7y88VeVIeHIr0qHefaQxSw0xBJgaK0
                              EdQG7qN9MHswDgYDVR0PAQH/BAQDAgEGMA8GA1UdEwEB/wQFMAMBAf8wHQYDVR0O
                              BBYEFIAvF908laB8Y4eSZCq+3lBWHIJNMB8GA1UdIwQYMBaAFAjENmFpvIZ22q9b
                              bpxtPs5MnoZ9MBgGA1UdEQQRMA+CDWNsdXN0ZXIubG9jYWwwCgYIKoZIzj0EAwID
                              SQAwRgIhANvDUJA1fE3Vu0NlrDVIua2Zq/ooaDbiFqnYHYSRJ298AiEA8KTqLv2R
                              f39t2rMQc1UEQEMMGY8GAhX6k0a169kbz8Y=
                              -----END CERTIFICATE-----

      DAPR_CERT_KEY:          -----BEGIN EC PRIVATE KEY-----
                              MHcCAQEEIIYFyiu9kkn89a5lfBBgmiPIH7UGDet1FxlmLqdKZnhPoAoGCCqGSM49
                              AwEHoUQDQgAEeGahgXjsvOXPIkAWopUtFHvvBUNFWkmDyxdllNVJKvH6X0JYmW7y
                              88VeVIeHIr0qHefaQxSw0xBJgaK0EdQG7g==
                              -----END EC PRIVATE KEY-----

      SENTRY_LOCAL_IDENTITY:  dapr-demo:default
    Mounts:
      /var/run/secrets/kubernetes.io/serviceaccount from kube-api-access-s2f8g (ro)
Conditions:
  Type              Status
  Initialized       True
  Ready             False
  ContainersReady   False
  PodScheduled      True
Volumes:
  kube-api-access-s2f8g:
    Type:                    Projected (a volume that contains injected data from multiple sources)
    TokenExpirationSeconds:  3607
    ConfigMapName:           kube-root-ca.crt
    ConfigMapOptional:       <nil>
    DownwardAPI:             true
QoS Class:                   BestEffort
Node-Selectors:              <none>
Tolerations:                 node.kubernetes.io/not-ready:NoExecute op=Exists for 300s
                             node.kubernetes.io/unreachable:NoExecute op=Exists for 300s
Events:
  Type     Reason   Age                     From     Message
  ----     ------   ----                    ----     -------
  Warning  BackOff  2m23s (x712 over 147m)  kubelet  Back-off restarting failed container

2.3. 查看pod中所有container的日志

kubectl logs service01-7cc7c54c65-g4jzw --all-containers=true -n dapr-demo
{"EventId":14,"LogLevel":"Information","Category":"Microsoft.Hosting.Lifetime","Message":"Now listening on: http://[::]:80","State":{"Message":"Now listening on: http://[::]:80","address":"http://[::]:80","{OriginalFormat}":"Now listening on: {address}"}}
{"EventId":0,"LogLevel":"Information","Category":"Microsoft.Hosting.Lifetime","Message":"Application started. Press Ctrl\u002BC to shut down.","State":{"Message":"Application started. Press Ctrl\u002BC to shut down.","{OriginalFormat}":"Application started. Press Ctrl\u002BC to shut down."}}
{"EventId":0,"LogLevel":"Information","Category":"Microsoft.Hosting.Lifetime","Message":"Hosting environment: Production","State":{"Message":"Hosting environment: Production","envName":"Production","{OriginalFormat}":"Hosting environment: {envName}"}}
{"EventId":0,"LogLevel":"Information","Category":"Microsoft.Hosting.Lifetime","Message":"Content root path: /app/","State":{"Message":"Content root path: /app/","contentRoot":"/app/","{OriginalFormat}":"Content root path: {contentRoot}"}}

2.4. 查看pod中dapr container的日志

kubectl logs service01-7cc7c54c65-g4jzw -c daprd -n dapr-demo

2.5. 查看pod中dapr container最近几行日志

  • --tail=-1 查看所有行日志
kubectl logs --tail=10 service01-7cc7c54c65-g4jzw -c daprd -n dapr-demo

2.6. 持续查看pod中dapr container的日志

kubectl logs -f service01-7cc7c54c65-g4jzw -c daprd -n dapr-demo

2.7. 按label查看日志

kubectl logs --selector=app=service01 --all-containers -n dapr-demo

3. 查看系统日志

3.1. 使用 tail 工具

tail /var/log/messages -f
Feb 19 16:32:58 localhost kubelet[1077]: E0219 16:32:58.466307    1077 pod_workers.go:918] "Error syncing pod, skipping" err="failed to \"StartContainer\" for \"daprd\" with CrashLoopBackOff: \"back-off 5m0s restarting failed container=daprd pod=service01-7cc7c54c65-gsf8c_dapr-demo(efa871c5-0f1d-41e1-b66f-95fff64c9d37)\"" pod="dapr-demo/service01-7cc7c54c65-gsf8c" podUID=efa871c5-0f1d-41e1-b66f-95fff

3.2. 使用 journalctl 工具

3.2.1. 查看最近的所有日志的前10行

journalctl -r -n 10
-- Logs begin at Tue 2021-12-28 23:05:04 CST, end at Sat 2022-02-19 16:41:01 CST. --
Feb 19 16:40:09 node-master systemd[1]: sysstat-collect.service: Succeeded.
Feb 19 16:40:09 node-master systemd[1]: Starting system activity accounting tool...
Feb 19 16:36:04 node-master systemd-logind[802]: Removed session 4.
Feb 19 16:36:04 node-master systemd-logind[802]: Session 4 logged out. Waiting for processes to exit.
Feb 19 16:36:04 node-master systemd[1]: session-4.scope: Succeeded.
Feb 19 16:36:04 node-master sshd[39571]: pam_unix(sshd:session): session closed for user root
Feb 19 16:36:01 node-master systemd-logind[802]: Removed session 1.
Feb 19 16:36:01 node-master systemd[1]: session-1.scope: Succeeded.
Feb 19 16:36:01 node-master systemd-logind[802]: Session 1 logged out. Waiting for processes to exit.
Feb 19 16:36:01 node-master sshd[3605]: pam_unix(sshd:session): session closed for user root

3.2.2. 查看指定应用的日志

journalctl -ru kubelet
journalctl -ru kube-scheduler
journalctl -ru kube-apiserver

3.2.3. 结合使用

journalctl -ru kubelet | grep cni | tail -n 5
 network plugin is not ready: cni config uninitialized"
Feb 17 17:18:56 node-master kubelet[42457]: I0217 17:18:56.564503   42457 cni.go:240] "Unable to update cni config" err="no networks found in /etc/cni/net.d"
Feb 17 17:18:56 node-master kubelet[42457]: I0217 17:18:56.564436   42457 docker_service.go:258] "Docker cri networking managed by the network plugin" networkPluginName="cni"
Feb 17 17:18:56 node-master kubelet[42457]: I0217 17:18:56.564377   42457 cni.go:240] "Unable to update cni config" err="no networks found in /etc/cni/net.d"
Feb 17 17:18:56 node-master kubelet[42457]: I0217 17:18:56.560754   42457 cni.go:240] "Unable to update cni config" err="no networks found in /etc/cni/net.d"

4. 用docker查看日志

4.1. 查看docker container

docker ps | grep k8schina/service02
690594264b75   k8schina/service02                                  "dotnet Service02.dll"   3 hours ago    Up 3 hours              k8s_service02_service02-6d849d9f97-mk286_dapr-demo_f3274fb9-9ce3-4a58-9872-bfccf4f473b6_0

4.2. 查看指定container日志

docker logs 690594264b75
{"EventId":14,"LogLevel":"Information","Category":"Microsoft.Hosting.Lifetime","Message":"Now listening on: http://[::]:80","State":{"Message":"Now listening on: http://[::]:80","address":"http://[::]:80","{OriginalFormat}":"Now listening on: {address}"}}
{"EventId":0,"LogLevel":"Information","Category":"Microsoft.Hosting.Lifetime","Message":"Application started. Press Ctrl\u002BC to shut down.","State":{"Message":"Application started. Press Ctrl\u002BC to shut down.","{OriginalFormat}":"Application started. Press Ctrl\u002BC to shut down."}}
{"EventId":0,"LogLevel":"Information","Category":"Microsoft.Hosting.Lifetime","Message":"Hosting environment: Production","State":{"Message":"Hosting environment: Production","envName":"Production","{OriginalFormat}":"Hosting environment: {envName}"}}
{"EventId":0,"LogLevel":"Information","Category":"Microsoft.Hosting.Lifetime","Message":"Content root path: /app/","State":{"Message":"Content root path: /app/","contentRoot":"/app/","{OriginalFormat}":"Content root path: {contentRoot}"}}
{"EventId":13,"LogLevel":"Error","Category":"Microsoft.AspNetCore.Server.Kestrel","Message":"Connection id \u00220HMFJDGT5UAFQ\u0022, Request id \u00220HMFJDGT5UAFQ:00000002\u0022: An unhandled exception was thrown by the application.","Exception":"Dapr.Client.InvocationException: An exception occurred while invoking method: \u0027api/hello\u0027 on app-id: \u0027service01\u0027  ---\u003E System.Net.Http.HttpRequestException: Connection refused (127.0.0.1:3500)  ---\u003E System.Net.Sockets.SocketException (111): Connection refused    at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.ThrowException(SocketError error, CancellationToken cancellationToken)    at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.System.Threading.Tasks.Sources.IValueTaskSource.GetResult(Int16 token)    at System.Net.Sockets.Socket.\u003CConnectAsync\u003Eg__WaitForConnectWithCancellation|277_0(AwaitableSocketAsyncEventArgs saea, ValueTask connectTask, CancellationToken cancellationToken)    at System.Net.Http.HttpConnectionPool.ConnectToTcpHostAsync(String host, Int32 port, HttpRequestMessage initialRequest, Boolean async, CancellationToken cancellationToken)    --- End of inner exception stack trace ---    at System.Net.Http.HttpConnectionPool.ConnectToTcpHostAsync(String host, Int32 port, HttpRequestMessage initialRequest, Boolean async, CancellationToken cancellationToken)    at System.Net.Http.HttpConnectionPool.ConnectAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken)    at System.Net.Http.HttpConnectionPool.CreateHttp11ConnectionAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken)    at System.Net.Http.HttpConnectionPool.AddHttp11ConnectionAsync(HttpRequestMessage request)    at System.Threading.Tasks.TaskCompletionSourceWithCancellation\u00601.WaitWithCancellationAsync(CancellationToken cancellationToken)    at System.Net.Http.HttpConnectionPool.GetHttp11ConnectionAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken)    at System.Net.Http.HttpConnectionPool.SendWithVersionDetectionAndRetryAsync(HttpRequestMessage request, Boolean async, Boolean doRequestAuth, CancellationToken cancellationToken)    at System.Net.Http.DiagnosticsHandler.SendAsyncCore(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken)    at System.Net.Http.RedirectHandler.SendAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken)    at System.Net.Http.HttpClient.\u003CSendAsync\u003Eg__Core|83_0(HttpRequestMessage request, HttpCompletionOption completionOption, CancellationTokenSource cts, Boolean disposeCts, CancellationTokenSource pendingRequestsCts, CancellationToken originalCancellationToken)    at Dapr.Client.DaprClientGrpc.InvokeMethodWithResponseAsync(HttpRequestMessage request, CancellationToken cancellationToken)    --- End of inner exception stack trace ---    at Dapr.Client.DaprClientGrpc.InvokeMethodWithResponseAsync(HttpRequestMessage request, CancellationToken cancellationToken)    at Dapr.Client.DaprClientGrpc.InvokeMethodAsync[TResponse](HttpRequestMessage request, CancellationToken cancellationToken)    at Service02.Controllers.HelloController.Hello() in /src/Service02/Controller/HelloController.cs:line 20    at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.TaskOfIActionResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)    at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.\u003CInvokeActionMethodAsync\u003Eg__Awaited|12_0(ControllerActionInvoker invoker, ValueTask\u00601 actionResultValueTask)    at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.\u003CInvokeNextActionFilterAsync\u003Eg__Awaited|10_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)    at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context)    at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State\u0026 next, Scope\u0026 scope, Object\u0026 state, Boolean\u0026 isCompleted)    at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.\u003CInvokeInnerFilterAsync\u003Eg__Awaited|13_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)    at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.\u003CInvokeFilterPipelineAsync\u003Eg__Awaited|20_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)    at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.\u003CInvokeAsync\u003Eg__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope)    at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.\u003CInvokeAsync\u003Eg__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope)    at Microsoft.AspNetCore.Routing.EndpointMiddleware.\u003CInvoke\u003Eg__AwaitRequestTask|6_0(Endpoint endpoint, Task requestTask, ILogger logger)    at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)    at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpProtocol.ProcessRequests[TContext](IHttpApplication\u00601 application)","State":{"Message":"Connection id \u00220HMFJDGT5UAFQ\u0022, Request id \u00220HMFJDGT5UAFQ:00000002\u0022: An unhandled exception was thrown by the application.","ConnectionId":"0HMFJDGT5UAFQ","TraceIdentifier":"0HMFJDGT5UAFQ:00000002","{OriginalFormat}":"Connection id \u0022{ConnectionId}\u0022, Request id \u0022{TraceIdentifier}\u0022: An unhandled exception was thrown by the application."}}
{"EventId":13,"LogLevel":"Error","Category":"Microsoft.AspNetCore.Server.Kestrel","Message":"Connection id \u00220HMFJDGT5UAFR\u0022, Request id \u00220HMFJDGT5UAFR:00000002\u0022: An unhandled exception was thrown by the application.","Exception":"Dapr.Client.InvocationException: An exception occurred while invoking method: \u0027api/hello\u0027 on app-id: \u0027service01\u0027  ---\u003E System.Net.Http.HttpRequestException: Connection refused (127.0.0.1:3500)  ---\u003E System.Net.Sockets.SocketException (111): Connection refused    at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.ThrowException(SocketError error, CancellationToken cancellationToken)    at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.System.Threading.Tasks.Sources.IValueTaskSource.GetResult(Int16 token)    at System.Net.Sockets.Socket.\u003CConnectAsync\u003Eg__WaitForConnectWithCancellation|277_0(AwaitableSocketAsyncEventArgs saea, ValueTask connectTask, CancellationToken cancellationToken)    at System.Net.Http.HttpConnectionPool.ConnectToTcpHostAsync(String host, Int32 port, HttpRequestMessage initialRequest, Boolean async, CancellationToken cancellationToken)    --- End of inner exception stack trace ---    at System.Net.Http.HttpConnectionPool.ConnectToTcpHostAsync(String host, Int32 port, HttpRequestMessage initialRequest, Boolean async, CancellationToken cancellationToken)    at System.Net.Http.HttpConnectionPool.ConnectAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken)    at System.Net.Http.HttpConnectionPool.CreateHttp11ConnectionAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken)    at System.Net.Http.HttpConnectionPool.AddHttp11ConnectionAsync(HttpRequestMessage request)    at System.Threading.Tasks.TaskCompletionSourceWithCancellation\u00601.WaitWithCancellationAsync(CancellationToken cancellationToken)    at System.Net.Http.HttpConnectionPool.GetHttp11ConnectionAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken)    at System.Net.Http.HttpConnectionPool.SendWithVersionDetectionAndRetryAsync(HttpRequestMessage request, Boolean async, Boolean doRequestAuth, CancellationToken cancellationToken)    at System.Net.Http.DiagnosticsHandler.SendAsyncCore(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken)    at System.Net.Http.RedirectHandler.SendAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken)    at System.Net.Http.HttpClient.\u003CSendAsync\u003Eg__Core|83_0(HttpRequestMessage request, HttpCompletionOption completionOption, CancellationTokenSource cts, Boolean disposeCts, CancellationTokenSource pendingRequestsCts, CancellationToken originalCancellationToken)    at Dapr.Client.DaprClientGrpc.InvokeMethodWithResponseAsync(HttpRequestMessage request, CancellationToken cancellationToken)    --- End of inner exception stack trace ---    at Dapr.Client.DaprClientGrpc.InvokeMethodWithResponseAsync(HttpRequestMessage request, CancellationToken cancellationToken)    at Dapr.Client.DaprClientGrpc.InvokeMethodAsync[TResponse](HttpRequestMessage request, CancellationToken cancellationToken)    at Service02.Controllers.HelloController.Hello() in /src/Service02/Controller/HelloController.cs:line 20    at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.TaskOfIActionResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)    at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.\u003CInvokeActionMethodAsync\u003Eg__Awaited|12_0(ControllerActionInvoker invoker, ValueTask\u00601 actionResultValueTask)    at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.\u003CInvokeNextActionFilterAsync\u003Eg__Awaited|10_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)    at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context)    at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State\u0026 next, Scope\u0026 scope, Object\u0026 state, Boolean\u0026 isCompleted)    at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.\u003CInvokeInnerFilterAsync\u003Eg__Awaited|13_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)    at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.\u003CInvokeFilterPipelineAsync\u003Eg__Awaited|20_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)    at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.\u003CInvokeAsync\u003Eg__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope)    at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.\u003CInvokeAsync\u003Eg__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope)    at Microsoft.AspNetCore.Routing.EndpointMiddleware.\u003CInvoke\u003Eg__AwaitRequestTask|6_0(Endpoint endpoint, Task requestTask, ILogger logger)    at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)    at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpProtocol.ProcessRequests[TContext](IHttpApplication\u00601 application)","State":{"Message":"Connection id \u00220HMFJDGT5UAFR\u0022, Request id \u00220HMFJDGT5UAFR:00000002\u0022: An unhandled exception was thrown by the application.","ConnectionId":"0HMFJDGT5UAFR","TraceIdentifier":"0HMFJDGT5UAFR:00000002","{OriginalFormat}":"Connection id \u0022{ConnectionId}\u0022, Request id \u0022{TraceIdentifier}\u0022: An unhandled exception was thrown by the application."}}

上一篇:break continue


下一篇:promise的学习