kubectl打开调试日志模式

打开调试日志

在实际使用中,通常通过 kubectl 来访问 apiserver,也可以通过 Kubernetes 各个语言的 client 库来访问 apiserver。在使用 kubectl 时,打开调试日志也可以看到每个 API 调用的格式,比如

[root@localhost ~]# kubectl --v=8 get pods 
I1126 19:10:44.878279  108242 loader.go:359] Config loaded from file /root/.kube/config
I1126 19:10:44.878942  108242 loader.go:359] Config loaded from file /root/.kube/config
I1126 19:10:44.882024  108242 round_trippers.go:383] GET https://10.0.60.51:6443/apis/metrics.k8s.io/v1beta1?timeout=32s
I1126 19:10:44.882038  108242 round_trippers.go:390] Request Headers:
I1126 19:10:44.882069  108242 round_trippers.go:393]     Accept: application/json, */*
I1126 19:10:44.882076  108242 round_trippers.go:393]     User-Agent: kubectl/v1.12.1 (linux/amd64) kubernetes/4ed3216
I1126 19:10:44.891669  108242 round_trippers.go:408] Response Status: 503 Service Unavailable in 9 milliseconds
I1126 19:10:44.891683  108242 round_trippers.go:411] Response Headers:
I1126 19:10:44.891689  108242 round_trippers.go:414]     Date: Mon, 26 Nov 2018 11:10:44 GMT
I1126 19:10:44.891695  108242 round_trippers.go:414]     Content-Type: text/plain; charset=utf-8
I1126 19:10:44.891701  108242 round_trippers.go:414]     X-Content-Type-Options: nosniff
I1126 19:10:44.891707  108242 round_trippers.go:414]     Content-Length: 20
I1126 19:10:44.893661  108242 request.go:942] Response Body: service unavailable
I1126 19:10:44.895465  108242 request.go:1144] body was not decodable (unable to check for Status): couldn't get version/kind; json parse error: json: cannot unmarshal string into Go value of type struct { APIVersion string "json:\"apiVersion,omitempty\""; Kind string "json:\"kind,omitempty\"" }
I1126 19:10:44.895484  108242 cached_discovery.go:77] skipped caching discovery info due to the server is currently unable to handle the request
I1126 19:10:44.896047  108242 loader.go:359] Config loaded from file /root/.kube/config
I1126 19:10:44.896454  108242 round_trippers.go:383] GET https://10.0.60.51:6443/apis/metrics.k8s.io/v1beta1?timeout=32s
I1126 19:10:44.896464  108242 round_trippers.go:390] Request Headers:
I1126 19:10:44.896470  108242 round_trippers.go:393]     Accept: application/json, */*
I1126 19:10:44.896477  108242 round_trippers.go:393]     User-Agent: kubectl/v1.12.1 (linux/amd64) kubernetes/4ed3216
I1126 19:10:44.898065  108242 round_trippers.go:408] Response Status: 503 Service Unavailable in 1 milliseconds
I1126 19:10:44.898077  108242 round_trippers.go:411] Response Headers:
I1126 19:10:44.898084  108242 round_trippers.go:414]     Content-Type: text/plain; charset=utf-8
I1126 19:10:44.898090  108242 round_trippers.go:414]     X-Content-Type-Options: nosniff
I1126 19:10:44.898096  108242 round_trippers.go:414]     Content-Length: 20
I1126 19:10:44.898101  108242 round_trippers.go:414]     Date: Mon, 26 Nov 2018 11:10:44 GMT
I1126 19:10:44.900199  108242 request.go:942] Response Body: service unavailable
I1126 19:10:44.901131  108242 request.go:1144] body was not decodable (unable to check for Status): couldn't get version/kind; json parse error: json: cannot unmarshal string into Go value of type struct { APIVersion string "json:\"apiVersion,omitempty\""; Kind string "json:\"kind,omitempty\"" }
I1126 19:10:44.901147  108242 cached_discovery.go:77] skipped caching discovery info due to the server is currently unable to handle the request
I1126 19:10:44.901174  108242 shortcut.go:89] Error loading discovery information: unable to retrieve the complete list of server APIs: metrics.k8s.io/v1beta1: the server is currently unable to handle the request
I1126 19:10:44.902749  108242 round_trippers.go:383] GET https://10.0.60.51:6443/apis/metrics.k8s.io/v1beta1?timeout=32s
I1126 19:10:44.902759  108242 round_trippers.go:390] Request Headers:
I1126 19:10:44.902765  108242 round_trippers.go:393]     Accept: application/json, */*
I1126 19:10:44.902772  108242 round_trippers.go:393]     User-Agent: kubectl/v1.12.1 (linux/amd64) kubernetes/4ed3216
I1126 19:10:44.903598  108242 round_trippers.go:408] Response Status: 503 Service Unavailable in 0 milliseconds
I1126 19:10:44.903610  108242 round_trippers.go:411] Response Headers:
I1126 19:10:44.903617  108242 round_trippers.go:414]     Content-Type: text/plain; charset=utf-8
I1126 19:10:44.903624  108242 round_trippers.go:414]     X-Content-Type-Options: nosniff
I1126 19:10:44.903629  108242 round_trippers.go:414]     Content-Length: 20
I1126 19:10:44.903635  108242 round_trippers.go:414]     Date: Mon, 26 Nov 2018 11:10:44 GMT
I1126 19:10:44.904512  108242 request.go:942] Response Body: service unavailable
I1126 19:10:44.905238  108242 request.go:1144] body was not decodable (unable to check for Status): couldn't get version/kind; json parse error: json: cannot unmarshal string into Go value of type struct { APIVersion string "json:\"apiVersion,omitempty\""; Kind string "json:\"kind,omitempty\"" }
I1126 19:10:44.905252  108242 cached_discovery.go:77] skipped caching discovery info due to the server is currently unable to handle the request
I1126 19:10:44.906620  108242 loader.go:359] Config loaded from file /root/.kube/config
I1126 19:10:44.906861  108242 round_trippers.go:383] GET https://10.0.60.51:6443/api/v1/namespaces/default/pods?limit=500
I1126 19:10:44.906870  108242 round_trippers.go:390] Request Headers:
I1126 19:10:44.906877  108242 round_trippers.go:393]     Accept: application/json;as=Table;v=v1beta1;g=meta.k8s.io, application/json
I1126 19:10:44.906884  108242 round_trippers.go:393]     User-Agent: kubectl/v1.12.1 (linux/amd64) kubernetes/4ed3216
I1126 19:10:44.909416  108242 round_trippers.go:408] Response Status: 200 OK in 2 milliseconds
I1126 19:10:44.909431  108242 round_trippers.go:411] Response Headers:
I1126 19:10:44.909438  108242 round_trippers.go:414]     Content-Type: application/json
I1126 19:10:44.909445  108242 round_trippers.go:414]     Date: Mon, 26 Nov 2018 11:10:44 GMT
I1126 19:10:44.909650  108242 request.go:942] Response Body: {"kind":"Table","apiVersion":"meta.k8s.io/v1beta1","metadata":{"selfLink":"/api/v1/namespaces/default/pods","resourceVersion":"773119"},"columnDefinitions":[{"name":"Name","type":"string","format":"name","description":"Name must be unique within a namespace. Is required when creating resources, although some resources may allow a client to request the generation of an appropriate name automatically. Name is primarily intended for creation idempotence and configuration definition. Cannot be updated. More info: http://kubernetes.io/docs/user-guide/identifiers#names","priority":0},{"name":"Ready","type":"string","format":"","description":"The aggregate readiness state of this pod for accepting traffic.","priority":0},{"name":"Status","type":"string","format":"","description":"The aggregate status of the containers in this pod.","priority":0},{"name":"Restarts","type":"integer","format":"","description":"The number of times the containers in this pod have been restarted.","priority":0},{"name":"Age","type":"strin [truncated 17935 chars]
I1126 19:10:44.911428  108242 get.go:558] no kind is registered for the type v1beta1.Table in scheme "k8s.io/kubernetes/pkg/api/legacyscheme/scheme.go:29"
NAME                                       READY   STATUS             RESTARTS   AGE
app-c8c54f79-2bfh9                         1/1     Running            15         11d
app-c8c54f79-9cg8q                         1/1     Running            15         11d
app-c8c54f79-9d494                         1/1     Running            15         11d
app-c8c54f79-9qcbj                         1/1     Running            15         11d
app-c8c54f79-9wdgk                         1/1     Running            15         11d
app-c8c54f79-bdcrl                         1/1     Running            15         11d
app-c8c54f79-bq4fh                         1/1     Running            15         11d
app-c8c54f79-cmtn4                         1/1     Running            15         11d
app-c8c54f79-qd7z8                         1/1     Running            15         11d
app-c8c54f79-wz9gq                         1/1     Running            15         11d
filled-oyster-heapster-796448dd9d-whfk6    2/2     Running            2          7d2h
healthcheck                                0/1     CrashLoopBackOff   1432       11d
httpd-5c44c97cb5-h5z7l                     1/1     Running            1          12d
httpd-5c44c97cb5-rdlr8                     1/1     Running            1          12d
httpd-5c44c97cb5-vhz9z                     1/1     Running            1          12d
liveness                                   1/1     Running            1997       11d
mypod                                      1/1     Running            14         11d
nginx-deployment-5fd98dbf5f-th4jb          1/1     Running            1          13d
nginx-deployment-5fd98dbf5f-zhmjz          1/1     Running            1          13d
orderly-ostrich-mychart-86957b459c-9cdfh   1/1     Running            1          10d
producer-consumer                          2/2     Running            30         11d
prometheus-operator-88fcf6d95-cjrcf        0/1     CrashLoopBackOff   58         7d1h
readiness                                  0/1     Completed          0          11d
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 213,992评论 6 493
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 91,212评论 3 388
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 159,535评论 0 349
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 57,197评论 1 287
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 66,310评论 6 386
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 50,383评论 1 292
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 39,409评论 3 412
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 38,191评论 0 269
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 44,621评论 1 306
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 36,910评论 2 328
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 39,084评论 1 342
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 34,763评论 4 337
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 40,403评论 3 322
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 31,083评论 0 21
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 32,318评论 1 267
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 46,946评论 2 365
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 43,967评论 2 351

推荐阅读更多精彩内容