飞雪团队

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 15799|回复: 0

Docker 与 K8S学习笔记(二十二)—— 高效使用kubectl的小技巧

[复制链接]

8834

主题

8922

帖子

2万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
28832
发表于 2022-2-12 14:35:42 | 显示全部楼层 |阅读模式
- n- [1 n5 w+ d! B/ G. Y: j2 w
<p>kubectl作为我们主要的操作K8S的工具,其具备非常丰富的功能,但是如果不经过打磨,使用起来还是存在诸多不便,今天我们来看看如何将我们的kubectl打磨的更加易用。</p>, Y3 U% R5 e; |: q  {3 x
<p>&nbsp;</p>& d6 `9 ?" V$ z6 ^: B
<p>一、命令自动补全</p>7 I; L" q8 s1 `
<p>kubectl中提供非常多的命令,如果每一次都要手动一个字符一个字符的敲未免太累了,那么如何配置自动补全呢?这里以ubuntu系统为例:</p># e* r! ^3 n2 h& @/ P
<p>1、安装auto-completion工具</p>& B* q1 {: |6 f% S
<div class="cnblogs_code">
+ ]$ Q8 G" H# K4 t) D9 n8 l<pre>$ <span style="color: rgba(0, 0, 255, 1)">sudo</span><span style="color: rgba(0, 0, 0, 1)"> apt update; c: U$ _1 y- ~4 @& n% j% \
Hit:</span><span style="color: rgba(128, 0, 128, 1)">1</span> http:<span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">archive.ubuntu.com/ubuntu bionic InRelease</span>
. m5 ^, n, b. I9 [! v5 ?Hit:<span style="color: rgba(128, 0, 128, 1)">2</span> http:<span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">security.ubuntu.com/ubuntu bionic-security InRelease</span>& m0 S- R. @9 E( c
Hit:<span style="color: rgba(128, 0, 128, 1)">3</span> http:<span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">archive.ubuntu.com/ubuntu bionic-updates InRelease</span>9 F9 F, F. I4 L+ F( ~' X+ y  z4 @
Hit:<span style="color: rgba(128, 0, 128, 1)">4</span> https:<span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">download.docker.com/linux/ubuntu bionic InRelease</span>
5 h2 w5 Z. P" rHit:<span style="color: rgba(128, 0, 128, 1)">5</span> http:<span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">archive.ubuntu.com/ubuntu bionic-backports InRelease</span>
8 e/ T" G6 C1 D+ R3 x<span style="color: rgba(0, 0, 0, 1)">Reading package lists... Done6 A, a# u+ e7 _9 e# |. `& i
Building dependency tree
: _6 ~- J- w/ V+ p7 s7 y1 qReading state information... Done* L5 x/ f  V( I2 b! ?' A5 ]( Z
</span><span style="color: rgba(128, 0, 128, 1)">144</span> packages can be upgraded. Run <span style="color: rgba(128, 0, 0, 1)">'</span><span style="color: rgba(128, 0, 0, 1)">apt list --upgradable</span><span style="color: rgba(128, 0, 0, 1)">'</span><span style="color: rgba(0, 0, 0, 1)"> to see them.
  |. }1 o. e& {  P+ j) G+ m$ v5 u$ </span><span style="color: rgba(0, 0, 255, 1)">sudo</span> apt <span style="color: rgba(0, 0, 255, 1)">install</span> bash-<span style="color: rgba(0, 0, 0, 1)">completion8 ]0 c) U: F0 B) c5 o
Reading package lists... Done3 q/ G7 \8 I& i7 L5 W( }1 ]2 i
Building dependency tree
6 f0 F( J- l6 A  n+ {Reading state information... Done. t$ X% _3 `) N8 x
bash</span>-completion is already the newest version (<span style="color: rgba(128, 0, 128, 1)">1</span>:<span style="color: rgba(128, 0, 128, 1)">2.8</span>-<span style="color: rgba(0, 0, 0, 1)">1ubuntu1).
. H0 m9 q6 D. s' h% w' N+ R# ]</span><span style="color: rgba(128, 0, 128, 1)">0</span> upgraded, <span style="color: rgba(128, 0, 128, 1)">0</span> newly installed, <span style="color: rgba(128, 0, 128, 1)">0</span> to remove and <span style="color: rgba(128, 0, 128, 1)">144</span> not upgraded.</pre>5 R0 x9 O4 I# {) G% ]9 q7 H
</div>8 Z3 H  g6 L6 T; m, y+ A
<p>PS:如果是centos系统,则使用<span class="js_darkmode__0" data-darkmode-color-16446330660319="rgb(0, 104, 255)" data-darkmode-original-color-16446330660319="#fff|rgb(0, 82, 255)" data-style="color: rgb(0, 82, 255);"><strong data-darkmode-color-16446330660319="rgb(0, 104, 255)" data-darkmode-original-color-16446330660319="#fff|rgb(0, 82, 255)">yum&nbsp;install&nbsp;bash-completion -y</strong>命令安装</span></p>8 A# j3 r5 T; J- B6 Y$ e& h+ o* G* F
<p>2、<span class="js_darkmode__1" data-darkmode-color-16446330660319="rgb(163, 163, 163)" data-darkmode-original-color-16446330660319="#fff|rgb(0, 0, 0)" data-style="color: rgb(0, 0, 0);">配置自动补全<br></span></p># n1 P+ o0 l7 B7 w8 a$ Z) j2 r- i! i
<p><span class="js_darkmode__2" data-darkmode-color-16446330660319="rgb(163, 163, 163)" data-darkmode-original-color-16446330660319="#fff|rgb(0, 0, 0)" data-style="color: rgb(0, 0, 0);"><strong data-darkmode-color-16446330660319="rgb(163, 163, 163)" data-darkmode-original-color-16446330660319="#fff|rgb(0, 0, 0)">Bash</strong>:</span></p>4 a% ]* [& m( U; k( v* x7 N, g
<div class="cnblogs_code">
  `6 i8 h' D+ p, I6 n<pre>source &lt;<span style="color: rgba(0, 0, 0, 1)">(kubectl completion bash)2 Y/ u8 g3 G1 g  g( Y! d. k7 t
</span><span style="color: rgba(0, 0, 255, 1)">echo</span> <span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">source &lt;(kubectl completion bash)</span><span style="color: rgba(128, 0, 0, 1)">"</span> &gt;&gt; ~/.bashrc</pre>
# y! j& X- G- u8 V( z* G5 o</div>2 m# z2 f! G& K: q
<p><strong>Zsh</strong>:</p>
4 B4 R# U/ q$ d% y1 Q0 w<div class="cnblogs_code">
1 f7 y* e, {5 t; Z  Y( ]<pre>source &lt;<span style="color: rgba(0, 0, 0, 1)">(kubectl completion zsh)
7 V  C' u+ p% {- ^</span><span style="color: rgba(0, 0, 255, 1)">echo</span> <span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">[[ $commands[kubectl] ]] &amp;&amp; source &lt;(kubectl completion zsh)</span><span style="color: rgba(128, 0, 0, 1)">"</span> &gt;&gt; ~/.zshrc</pre>; D9 x4 j( e! i. o& A7 x' Q( K2 Y
</div>) I5 G2 @! k$ s9 {7 q0 q7 j
<p>配置后就可以通过Tab键自动补全命令啦!</p>
2 f) R) L5 |0 B8 ]7 Y9 g8 C3 ^<p>&nbsp;</p>% [* l1 p6 b, i2 I  t/ c" _: T
<p>二、配置kubectl别名</p>& z$ ?, Y9 f5 L  t9 b
<p>我们可以通过设置别名简化kubectl命令,编辑.bashrc文件,添加如下内容:</p>
. F) n" `( n' B/ n# n<div class="cnblogs_code">6 g7 A4 u3 u2 r. B, j
<pre>alias <span style="color: rgba(0, 0, 255, 1)">sudo</span>=<span style="color: rgba(128, 0, 0, 1)">'</span><span style="color: rgba(128, 0, 0, 1)">sudo </span><span style="color: rgba(128, 0, 0, 1)">'</span><span style="color: rgba(0, 0, 0, 1)">, n$ i% ]0 t; [6 p: Y' w
alias k</span>=<span style="color: rgba(128, 0, 0, 1)">'</span><span style="color: rgba(128, 0, 0, 1)">kubectl</span><span style="color: rgba(128, 0, 0, 1)">'</span><span style="color: rgba(0, 0, 0, 1)">
, z7 h3 M. K- ?, F6 ?( valias ka</span>=<span style="color: rgba(128, 0, 0, 1)">'</span><span style="color: rgba(128, 0, 0, 1)">kubectl apply --recursive -f</span><span style="color: rgba(128, 0, 0, 1)">'</span><span style="color: rgba(0, 0, 0, 1)">
& ^' W# @4 b+ u8 Galias kex</span>=<span style="color: rgba(128, 0, 0, 1)">'</span><span style="color: rgba(128, 0, 0, 1)">kubectl exec -i -t</span><span style="color: rgba(128, 0, 0, 1)">'</span><span style="color: rgba(0, 0, 0, 1)">) Z8 ~* ]' [9 G- I/ u, F" z. h
alias klo</span>=<span style="color: rgba(128, 0, 0, 1)">'</span><span style="color: rgba(128, 0, 0, 1)">kubectl logs -f</span><span style="color: rgba(128, 0, 0, 1)">'</span><span style="color: rgba(0, 0, 0, 1)">
0 v3 L2 T% I. j" j+ H' y7 }, A1 c* Walias kg</span>=<span style="color: rgba(128, 0, 0, 1)">'</span><span style="color: rgba(128, 0, 0, 1)">kubectl get</span><span style="color: rgba(128, 0, 0, 1)">'</span><span style="color: rgba(0, 0, 0, 1)">
# S' \7 G. P# a/ c" w' c1 Balias kd</span>=<span style="color: rgba(128, 0, 0, 1)">'</span><span style="color: rgba(128, 0, 0, 1)">kubectl describe</span><span style="color: rgba(128, 0, 0, 1)">'</span></pre>) d+ n* ~' |, _4 W) V
</div>
( A9 @9 g0 O% ^4 G; C8 E" G7 Z<p><span class="js_darkmode__4" data-darkmode-color-16446330660319="rgb(0, 104, 255)" data-darkmode-original-color-16446330660319="#fff|rgb(0, 82, 255)" data-style="color: rgb(0, 82, 255);"><strong data-darkmode-color-16446330660319="rgb(0, 104, 255)" data-darkmode-original-color-16446330660319="#fff|rgb(0, 82, 255)">PS:alias sudo是为了解决sudo下别名不可用问题</strong><br></span></p>
1 Q0 E* u9 G9 {0 c3 G<p><span class="js_darkmode__5" data-darkmode-color-16446330660319="rgb(163, 163, 163)" data-darkmode-original-color-16446330660319="#fff|rgb(0, 0, 0)" data-style="color: rgb(0, 0, 0);">保存后记得执行 source ~/.bashrc哈,接着我们体验下:</span></p>
9 p/ Q5 i& ^/ Q# i/ a<div class="cnblogs_code">
0 A* ~+ Z3 D3 P7 d4 b<pre>$ <span style="color: rgba(0, 0, 255, 1)">sudo</span><span style="color: rgba(0, 0, 0, 1)"> ka webapp_pod.yaml
4 F" k. B8 T. h; t# f& O8 qpod</span>/<span style="color: rgba(0, 0, 0, 1)">webapp created
; c% f- Y5 T3 S  j$ </span><span style="color: rgba(0, 0, 255, 1)">sudo</span><span style="color: rgba(0, 0, 0, 1)"> kg pods  b" {% h$ `+ M  j+ i! o1 M
NAME     READY   STATUS              RESTARTS   AGE
$ S0 s# p4 B  x8 F$ \webapp   </span><span style="color: rgba(128, 0, 128, 1)">0</span>/<span style="color: rgba(128, 0, 128, 1)">2</span>     ContainerCreating   <span style="color: rgba(128, 0, 128, 1)">0</span><span style="color: rgba(0, 0, 0, 1)">          7s5 _1 F9 x- e+ }/ g; m2 Y
$ </span><span style="color: rgba(0, 0, 255, 1)">sudo</span><span style="color: rgba(0, 0, 0, 1)"> kd pod webapp$ M7 c2 u* y: Z% V7 [8 ]6 ?
Name:         webapp! b  q/ F4 K5 }6 _; u) \& o* y( \: }. d
Namespace:    default. x4 V# Y! `8 w. x8 C
Priority:     </span><span style="color: rgba(128, 0, 128, 1)">0</span><span style="color: rgba(0, 0, 0, 1)">  O; H! Z" Q; c5 J, A
Node:         ayato</span>/<span style="color: rgba(128, 0, 128, 1)">172.16</span>.<span style="color: rgba(128, 0, 128, 1)">194.135</span><span style="color: rgba(0, 0, 0, 1)">+ @. y# m/ G- j9 G+ O
Start Time:   Wed, </span><span style="color: rgba(128, 0, 128, 1)">09</span> Feb <span style="color: rgba(128, 0, 128, 1)">2022</span> <span style="color: rgba(128, 0, 128, 1)">14</span>:<span style="color: rgba(128, 0, 128, 1)">04</span>:<span style="color: rgba(128, 0, 128, 1)">44</span> +<span style="color: rgba(128, 0, 128, 1)">0000</span><span style="color: rgba(0, 0, 0, 1)">7 `" f! h, h8 q" D, v" Y' [5 b$ A
Labels:       app</span>=<span style="color: rgba(0, 0, 0, 1)">webapp
( o& O' v+ q: kAnnotations:  </span>&lt;none&gt;<span style="color: rgba(0, 0, 0, 1)">
5 C9 c: ?0 B. \( z$ ]8 d, fStatus:       Running
4 @- f+ L0 d3 E, f. q% m: t  EIP:           </span><span style="color: rgba(128, 0, 128, 1)">172.17</span>.<span style="color: rgba(128, 0, 128, 1)">0.6</span><span style="color: rgba(0, 0, 0, 1)">5 ~; V) M+ e5 e$ ?5 s; B4 d% @* x
IPs:: T5 b5 @, [7 G! y1 l; b8 h6 t6 k
  IP:  </span><span style="color: rgba(128, 0, 128, 1)">172.17</span>.<span style="color: rgba(128, 0, 128, 1)">0.6</span><span style="color: rgba(0, 0, 0, 1)">7 e, i6 {$ W, j% p
Containers:  T0 u# Y$ _2 c: ]# l7 t# w9 i
  webapp:
; c& q2 n1 \7 |0 V# P    Container ID:   docker:</span><span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">d9ddf9dd47de12b53f2119bf75df6706bee2e7711509638ad52adc9addeda704</span>
4 Y- X; w! D- S; R+ w) r0 T9 ^7 H    Image:          <span style="color: rgba(128, 0, 128, 1)">172.16</span>.<span style="color: rgba(128, 0, 128, 1)">194.135</span>:<span style="color: rgba(128, 0, 128, 1)">5000</span>/webapp:<span style="color: rgba(128, 0, 128, 1)">1.0</span><span style="color: rgba(0, 0, 0, 1)">( ^0 a9 M( d4 W/ |9 q" \
    Image ID:       docker</span>-pullable:<span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">172.16.194.135:5000/webapp@sha256:df3a447a013ada0642dec67bb31976f42f1a0699a68873d0452f514fa24e5c77</span>
" X5 D0 x7 t2 `    Port:           <span style="color: rgba(128, 0, 128, 1)">5000</span>/<span style="color: rgba(0, 0, 0, 1)">TCP; N% }5 f' K  l8 g5 c2 {8 R. D9 Z
    Host Port:      </span><span style="color: rgba(128, 0, 128, 1)">0</span>/<span style="color: rgba(0, 0, 0, 1)">TCP& `9 G  R+ j" e( t5 P6 D: n9 R
    State:          Running
/ {  G' W8 D  H0 w      Started:      Wed, </span><span style="color: rgba(128, 0, 128, 1)">09</span> Feb <span style="color: rgba(128, 0, 128, 1)">2022</span> <span style="color: rgba(128, 0, 128, 1)">14</span>:<span style="color: rgba(128, 0, 128, 1)">04</span>:<span style="color: rgba(128, 0, 128, 1)">46</span> +<span style="color: rgba(128, 0, 128, 1)">0000</span><span style="color: rgba(0, 0, 0, 1)">
) N6 q( b" b" R5 {: R2 n, m9 ^    Ready:          True; }  _/ t( e7 Q; N, x
    Restart Count:  </span><span style="color: rgba(128, 0, 128, 1)">0</span><span style="color: rgba(0, 0, 0, 1)">
6 c( [& t/ w  ]% k    Environment:    </span>&lt;none&gt;<span style="color: rgba(0, 0, 0, 1)">6 F: I. k* j8 L2 e! }
    Mounts:6 m8 ]0 K$ P1 k- _+ E8 o; h
      </span>/tmp from webapp-<span style="color: rgba(0, 0, 0, 1)">logs (rw)
3 E2 U& z/ j4 k3 V* O8 V      </span>/var/run/secrets/kubernetes.io/serviceaccount from default-token-<span style="color: rgba(0, 0, 0, 1)">pcr2h (ro)3 n) e- R( `6 ]' f
  busybox:
7 P; l4 y) m/ C, l, R# K    Container ID:  docker:</span><span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">6a6a35a628a782fc643af3dd49986bbc77c23de1ae4726bc521c77f61abbbf5d</span>- \: `( Z. o+ u0 ~# c
<span style="color: rgba(0, 0, 0, 1)">    Image:         busybox
0 L: w0 u7 L9 w4 D$ L    Image ID:      docker</span>-pullable:<span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">busybox@sha256:afcc7f1ac1b49db317a7196c902e61c6c3c4607d63599ee1a82d702d249a0ccb</span># n+ p1 K  D6 e8 Y/ X% L
    Port:          &lt;none&gt;<span style="color: rgba(0, 0, 0, 1)">
) L, T: }4 U2 o    Host Port:     </span>&lt;none&gt;<span style="color: rgba(0, 0, 0, 1)"># K5 W: R; |* |0 t  ^# W
    Command:. Z! J2 L6 W/ u& Z0 ~2 h
      </span><span style="color: rgba(0, 0, 255, 1)">sh</span>2 g0 Z! B$ k- J( b" Z
      -<span style="color: rgba(0, 0, 0, 1)">c
! {6 s9 k# Z2 H% ]9 B& \      </span><span style="color: rgba(0, 0, 255, 1)">tail</span> -f /logs/<span style="color: rgba(0, 0, 0, 1)">log.out2 w  @2 ?3 n" J: P/ z: E
    State:          Running1 h" y# i7 c1 Q. N3 V0 y0 a+ `9 V
      Started:      Wed, </span><span style="color: rgba(128, 0, 128, 1)">09</span> Feb <span style="color: rgba(128, 0, 128, 1)">2022</span> <span style="color: rgba(128, 0, 128, 1)">14</span>:<span style="color: rgba(128, 0, 128, 1)">06</span>:<span style="color: rgba(128, 0, 128, 1)">53</span> +<span style="color: rgba(128, 0, 128, 1)">0000</span><span style="color: rgba(0, 0, 0, 1)">
- y4 t) p" G( H0 h2 B* s    Ready:          True
7 \" }3 C' [( a7 i* F  ]- T: U; Q    Restart Count:  </span><span style="color: rgba(128, 0, 128, 1)">0</span><span style="color: rgba(0, 0, 0, 1)">- F$ G  e, W% A, |
    Environment:    </span>&lt;none&gt;<span style="color: rgba(0, 0, 0, 1)">
& M0 ?  g" M: E! q0 _    Mounts:: w0 `& s$ e/ K+ {9 S
      </span>/logs from webapp-<span style="color: rgba(0, 0, 0, 1)">logs (rw)  ]! T6 B$ `8 a+ {: c, i& Z# ?
      </span>/var/run/secrets/kubernetes.io/serviceaccount from default-token-<span style="color: rgba(0, 0, 0, 1)">pcr2h (ro)
$ f4 ~, r: G! t% t& P  A/ {Conditions:9 {/ z6 z# h, L' t! p# s# N
  Type              Status
* t4 I; l7 J! a% p% j  Initialized       True% v$ E& _+ O- y
  Ready             True( P6 C1 j+ F8 X. v; A
  ContainersReady   True# I9 Z$ n. G+ Y! D7 i7 H% O& u4 r
  PodScheduled      True/ g: Y0 ~/ P$ h
Volumes:
4 O  W4 C- O$ [; h2 C  webapp</span>-<span style="color: rgba(0, 0, 0, 1)">logs:
& B8 |. Z( n: K6 Z8 b- R    Type:       EmptyDir (a temporary directory that shares a pod</span><span style="color: rgba(128, 0, 0, 1)">'</span><span style="color: rgba(128, 0, 0, 1)">s lifetime)</span>
1 q& x* {  J8 v+ `% ?<span style="color: rgba(0, 0, 0, 1)">    Medium:
9 G7 w5 `& W: E3 j, H1 Z    SizeLimit:  </span>&lt;unset&gt;<span style="color: rgba(0, 0, 0, 1)">
! U) m: z% c+ I% }3 p$ u  default</span>-token-<span style="color: rgba(0, 0, 0, 1)">pcr2h:
1 v; @! P" |( M    Type:        Secret (a volume populated by a Secret)  |/ f  P- ~) I6 I2 k
    SecretName:  default</span>-token-<span style="color: rgba(0, 0, 0, 1)">pcr2h& r8 u! D  h. S# {& w
    Optional:    </span><span style="color: rgba(0, 0, 255, 1)">false</span><span style="color: rgba(0, 0, 0, 1)">
( L  e- L5 X7 s3 a4 ZQoS Class:       BestEffort
' G* J& O1 T$ {Node</span>-Selectors:  &lt;none&gt;<span style="color: rgba(0, 0, 0, 1)">. @. z) X4 U! p: ^3 u1 Q  ^5 |8 {+ S7 f
Tolerations:     node.kubernetes.io</span>/not-ready:NoExecute op=Exists <span style="color: rgba(0, 0, 255, 1)">for</span><span style="color: rgba(0, 0, 0, 1)"> 300s1 Q  Y" H6 p( @3 q; J( A
                 node.kubernetes.io</span>/unreachable:NoExecute op=Exists <span style="color: rgba(0, 0, 255, 1)">for</span><span style="color: rgba(0, 0, 0, 1)"> 300s7 p* M7 K) F6 R
Events:
/ R6 e# x/ E' |+ |  w  Type    Reason     Age    From               Message
+ r. R! {1 F0 ^0 d  </span>----    ------     ----   ----               -------<span style="color: rgba(0, 0, 0, 1)">+ y  N( _! y# I. k0 X' @
  Normal  Scheduled  2m23s  default</span>-scheduler  Successfully assigned default/<span style="color: rgba(0, 0, 0, 1)">webapp to ayato+ D: ~4 C. f8 q
  Normal  Pulled     2m22s  kubelet            Container image </span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">172.16.194.135:5000/webapp:1.0</span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(0, 0, 0, 1)"> already present on machine( r% B1 ~/ H6 j
  Normal  Created    2m21s  kubelet            Created container webapp. P+ V4 N2 u: {5 K# n2 J
  Normal  Started    2m21s  kubelet            Started container webapp
6 Z& t% |/ ?% U! z  Normal  Pulling    2m21s  kubelet            Pulling image </span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">busybox</span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(0, 0, 0, 1)">% Y$ ?9 B" O2 b$ t1 Z' w
  Normal  Pulled     15s    kubelet            Successfully pulled image </span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">busybox</span><span style="color: rgba(128, 0, 0, 1)">"</span> <span style="color: rgba(0, 0, 255, 1)">in</span> <span style="color: rgba(128, 0, 128, 1)">14</span><span style="color: rgba(0, 0, 0, 1)">.633078305s
( v, z# r% J9 l) P' U5 k  Normal  Created    15s    kubelet            Created container busybox$ |8 i9 W& k' v
  Normal  Started    14s    kubelet            Started container busybox</span></pre>
) G1 f9 v/ K( ^</div>
$ S& V0 L/ X: A8 T% k<p>真的是飞一般的感觉!!!</p>4 {( r5 m6 i% J8 _% D& O
<p>&nbsp;</p>
8 [% E; e$ S' S2 M" z+ O  e. j0 T4 u<p>三、Context和Namespace切换</p>& q$ A1 D+ m* S+ E5 M: L6 c, b
<p>我们在公司的容器平台上使用kubectl时,经常需要切换context和namespace,导致命令非常繁琐,那有没有简便的方式呢?—— kubectx</p>0 ?8 l/ Z8 Q2 q2 [. h
<p>kubectx安装</p>; q2 ?5 S# [( c# Y$ Y
<div class="cnblogs_code">
* l, u7 D% F6 d4 K$ Q* [<pre>$ <span style="color: rgba(0, 0, 255, 1)">sudo</span> git clone https:<span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">github.com/ahmetb/kubectx /opt/kubectx</span>$ a7 S7 _2 `1 P* Q9 v
Cloning into <span style="color: rgba(128, 0, 0, 1)">'</span><span style="color: rgba(128, 0, 0, 1)">/opt/kubectx</span><span style="color: rgba(128, 0, 0, 1)">'</span><span style="color: rgba(0, 0, 0, 1)">...
  K7 f8 L. U% U" o- q1 i9 xremote: Enumerating objects: </span><span style="color: rgba(128, 0, 128, 1)">1457</span>, <span style="color: rgba(0, 0, 255, 1)">done</span><span style="color: rgba(0, 0, 0, 1)">.
0 b% Z- N; J6 b; r, P) |! g! Tremote: Counting objects: </span><span style="color: rgba(128, 0, 128, 1)">100</span>% (<span style="color: rgba(128, 0, 128, 1)">172</span>/<span style="color: rgba(128, 0, 128, 1)">172</span>), <span style="color: rgba(0, 0, 255, 1)">done</span><span style="color: rgba(0, 0, 0, 1)">.4 Q8 s/ N2 z+ J
remote: Compressing objects: </span><span style="color: rgba(128, 0, 128, 1)">100</span>% (<span style="color: rgba(128, 0, 128, 1)">115</span>/<span style="color: rgba(128, 0, 128, 1)">115</span>), <span style="color: rgba(0, 0, 255, 1)">done</span><span style="color: rgba(0, 0, 0, 1)">.
+ r* ~$ ^5 [, O* t- n. g0 n0 Q2 ?* sremote: Total </span><span style="color: rgba(128, 0, 128, 1)">1457</span> (delta <span style="color: rgba(128, 0, 128, 1)">85</span>), reused <span style="color: rgba(128, 0, 128, 1)">97</span> (delta <span style="color: rgba(128, 0, 128, 1)">51</span>), pack-reused <span style="color: rgba(128, 0, 128, 1)">1285</span><span style="color: rgba(0, 0, 0, 1)">
! c6 y* u8 s8 V: e" DReceiving objects: </span><span style="color: rgba(128, 0, 128, 1)">100</span>% (<span style="color: rgba(128, 0, 128, 1)">1457</span>/<span style="color: rgba(128, 0, 128, 1)">1457</span>), <span style="color: rgba(128, 0, 128, 1)">905.30</span> KiB | <span style="color: rgba(128, 0, 128, 1)">69.00</span> KiB/s, <span style="color: rgba(0, 0, 255, 1)">done</span><span style="color: rgba(0, 0, 0, 1)">.) _- Y" Y/ ?2 j
Resolving deltas: </span><span style="color: rgba(128, 0, 128, 1)">100</span>% (<span style="color: rgba(128, 0, 128, 1)">817</span>/<span style="color: rgba(128, 0, 128, 1)">817</span>), <span style="color: rgba(0, 0, 255, 1)">done</span><span style="color: rgba(0, 0, 0, 1)">.
2 U( l/ o" m- n3 Z( r+ M5 E9 y7 {$ </span><span style="color: rgba(0, 0, 255, 1)">sudo</span> <span style="color: rgba(0, 0, 255, 1)">ln</span> -s /opt/kubectx/kubens /usr/local/bin/kubectl-<span style="color: rgba(0, 0, 0, 1)">ns3 Q% e) o! v' R, `6 _# Z1 O% L
$ </span><span style="color: rgba(0, 0, 255, 1)">sudo</span> <span style="color: rgba(0, 0, 255, 1)">ln</span> -s /opt/kubectx/kubectx /usr/local/bin/kubectl-ctx</pre>
( T- D/ E0 c) \- d  J! P8 I# X</div>
. e3 |. c- I) o: x, i<p>我们来看一下效果:</p>; F% ^2 i: h6 h0 t; L
<div class="cnblogs_code">
+ h3 S3 @, `5 \4 X<pre>$ <span style="color: rgba(0, 0, 255, 1)">sudo</span><span style="color: rgba(0, 0, 0, 1)"> k ctx
4 P, Z  E1 {3 p. Pminikube
+ f7 ]6 d/ Y/ U9 ~$ </span><span style="color: rgba(0, 0, 255, 1)">sudo</span><span style="color: rgba(0, 0, 0, 1)"> k ctx minikube( u3 \- q- A* Q! s9 {8 g+ Q9 C
Switched to context </span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">minikube</span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(0, 0, 0, 1)">." O5 t% C. L; Z/ z
$ </span><span style="color: rgba(0, 0, 255, 1)">sudo</span><span style="color: rgba(0, 0, 0, 1)"> k ns
: @1 N; n5 e! ]7 p1 U! g6 udefault4 L4 z* p* E9 d$ @: k' Y0 M
kube</span>-node-<span style="color: rgba(0, 0, 0, 1)">lease3 k8 e! ]6 H% N8 G/ q4 R
kube</span>-<span style="color: rgba(0, 0, 0, 1)">public
4 `% A" K( b* D/ O0 }kube</span>-<span style="color: rgba(0, 0, 0, 1)">system
/ \3 R7 J, v, V( s0 m- A0 d) G. |kubernetes</span>-<span style="color: rgba(0, 0, 0, 1)">dashboard
. k; l3 j3 I' \% u, q; M3 {" t$ </span><span style="color: rgba(0, 0, 255, 1)">sudo</span> k ns kube-<span style="color: rgba(0, 0, 0, 1)">public
2 |& b6 i0 V2 J, bContext </span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">minikube</span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(0, 0, 0, 1)"> modified.
' M# d7 ^: H8 M$ S# FActive namespace is </span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">kube-public</span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(0, 0, 0, 1)">.- k% B' x, r$ `7 W' @
$ </span><span style="color: rgba(0, 0, 255, 1)">sudo</span><span style="color: rgba(0, 0, 0, 1)"> k ns default' U4 x+ U" d' b& M' @( \
Context </span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">minikube</span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(0, 0, 0, 1)"> modified.8 `/ @4 q2 D) w" g" K
Active namespace is </span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">default</span><span style="color: rgba(128, 0, 0, 1)">"</span>.</pre>
8 k# M9 T* t& x  k% J  X</div>5 T2 C# [# o% G/ a- r' N: a
<p>&nbsp;</p>3 X3 ^: [7 v6 s$ C3 S$ _- j7 U
<p>四、跟踪查看多个Pod的日志</p>
& t+ ]1 {9 Y( K- U1 N<p>我们一般使用kubectl logs命令查看Pod日志,但是它不能通过-f参数同时跟踪查看多个Pod日志,这就不方便了,毕竟实际生产环境中每个服务都会有多个Pod,这时我们可以使用stern这个工具,它具备如下能力:</p>1 \6 N: a+ e$ C/ B% |  A. L8 k
<ul class="list-paddingleft-2">8 m& N. M# v9 d$ ^$ P# O' Y; ]
<li>
4 [# f8 h# H/ A! f# l5 D<p>允许使用正则表达式来选择需要查看的PodName</p>
. `) J& h* b7 E4 f: b4 F6 g</li>
* u7 Z( l6 ^$ H! V<li># M7 k( B/ c5 [5 \1 |3 b# v& d
<p>为不同 Pod 的日志展示不同的颜色</p>
" W7 x5 s8 _' n</li>, [/ J7 X+ M; c+ b$ H
<li>4 p3 N& c5 Y9 h* ]; h
<p>跟踪日志过程中假如有符合规则的新 Pod 被创建, 那么会自动添加到输出中</p>4 F2 a! g# ~, e, O7 N
</li>
1 E; N2 t- U3 L</ul>
  \3 s+ H2 o4 i" Z" ~<p>首先安装stern(下载stern时可能较慢可以多试几次):</p>( m6 W8 w- g6 Y  E' Y  n6 Q% H
<div class="cnblogs_code">7 }8 n, I1 z$ d
<pre><span style="color: rgba(0, 0, 255, 1)">wget</span> https:<span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">github.com/wercker/stern/releases/download/1.11.0/stern_linux_amd64</span>6 j8 c$ Q5 j9 I- p$ N5 a4 U4 l! H
<span style="color: rgba(0, 0, 255, 1)">sudo</span> <span style="color: rgba(0, 0, 255, 1)">mv</span> stern_linux_amd64 /usr/local/bin/kubectl-<span style="color: rgba(0, 0, 255, 1)">tail</span>
" V% h" V2 c! R' T9 X' J4 t<span style="color: rgba(0, 0, 255, 1)">sudo</span> chomd +x /usr/local/bin/kubectl-<span style="color: rgba(0, 0, 255, 1)">tail</span></pre>
- [7 I  Z/ z2 c; n# R. ^# _- P& A+ p</div>
5 A+ z- N8 p, a1 i+ ~/ }<p>安装完毕后让我一起感受一下stern的魅力吧,我的Pod里面有两个容器:webapp和busybox,如果使用kubectl logs 还得指定具体的容器,而使用stern就没有这样的限制。</p>
+ o9 x0 n5 c) H<div class="cnblogs_code">. @" s& p( l3 F9 w. k  a  F& V
<pre>$ <span style="color: rgba(0, 0, 255, 1)">sudo</span> k <span style="color: rgba(0, 0, 255, 1)">tail</span><span style="color: rgba(0, 0, 0, 1)"> .& P6 J/ w( v- G" ]0 [! e4 ?- S
</span>+<span style="color: rgba(0, 0, 0, 1)"> webapp › busybox
/ I6 n( i- C+ K1 ?* w. H</span>+<span style="color: rgba(0, 0, 0, 1)"> webapp › webapp
. B- E0 |1 g# `: W5 I! ?webapp busybox </span><span style="color: rgba(128, 0, 128, 1)">14</span>:<span style="color: rgba(128, 0, 128, 1)">04</span>:<span style="color: rgba(128, 0, 128, 1)">53.197</span> [INFO ] [main] [org.apache.coyote.http11.Http11NioProtocol] Initializing ProtocolHandler [<span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">http-nio-4567</span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(0, 0, 0, 1)">]- K( o5 d9 N5 I) b
webapp busybox </span><span style="color: rgba(128, 0, 128, 1)">14</span>:<span style="color: rgba(128, 0, 128, 1)">04</span>:<span style="color: rgba(128, 0, 128, 1)">53.200</span><span style="color: rgba(0, 0, 0, 1)"> [INFO ] [main] [org.apache.catalina.core.StandardService] Starting service [Tomcat]
# R* V0 m0 K6 Xwebapp busybox </span><span style="color: rgba(128, 0, 128, 1)">14</span>:<span style="color: rgba(128, 0, 128, 1)">04</span>:<span style="color: rgba(128, 0, 128, 1)">53.201</span> [INFO ] [main] [org.apache.catalina.core.StandardEngine] Starting Servlet engine: [Apache Tomcat/<span style="color: rgba(128, 0, 128, 1)">9.0</span>.<span style="color: rgba(128, 0, 128, 1)">41</span><span style="color: rgba(0, 0, 0, 1)">]
. k$ b6 P( @7 K5 f9 ?, N: Rwebapp busybox </span><span style="color: rgba(128, 0, 128, 1)">14</span>:<span style="color: rgba(128, 0, 128, 1)">04</span>:<span style="color: rgba(128, 0, 128, 1)">53.324</span> [INFO ] [main] [org.apache.catalina.core.ContainerBase.[Tomcat].[localhost].[/<span style="color: rgba(0, 0, 0, 1)">]] Initializing Spring embedded WebApplicationContext' h7 [- b; s7 f: t3 E+ l! L2 J
webapp busybox </span><span style="color: rgba(128, 0, 128, 1)">14</span>:<span style="color: rgba(128, 0, 128, 1)">04</span>:<span style="color: rgba(128, 0, 128, 1)">53.325</span> [INFO ] [main] [org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext] Root WebApplicationContext: initialization completed <span style="color: rgba(0, 0, 255, 1)">in</span> <span style="color: rgba(128, 0, 128, 1)">2952</span><span style="color: rgba(0, 0, 0, 1)"> ms1 t; k8 ]4 r/ Q: e
webapp busybox </span><span style="color: rgba(128, 0, 128, 1)">14</span>:<span style="color: rgba(128, 0, 128, 1)">04</span>:<span style="color: rgba(128, 0, 128, 1)">53.801</span> [INFO ] [main] [org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor] Initializing ExecutorService <span style="color: rgba(128, 0, 0, 1)">'</span><span style="color: rgba(128, 0, 0, 1)">applicationTaskExecutor</span><span style="color: rgba(128, 0, 0, 1)">'</span><span style="color: rgba(0, 0, 0, 1)">0 m9 w4 l  w8 h/ l
webapp busybox </span><span style="color: rgba(128, 0, 128, 1)">14</span>:<span style="color: rgba(128, 0, 128, 1)">04</span>:<span style="color: rgba(128, 0, 128, 1)">54.264</span> [WARN ] [main] [org.springframework.boot.autoconfigure.thymeleaf.ThymeleafAutoConfiguration$DefaultTemplateResolverConfiguration] Cannot <span style="color: rgba(0, 0, 255, 1)">find</span> template location: classpath:/templates/<span style="color: rgba(0, 0, 0, 1)"> (please add some templates or check your Thymeleaf configuration)* G9 R8 |% y, S4 O0 A: _
webapp busybox </span><span style="color: rgba(128, 0, 128, 1)">14</span>:<span style="color: rgba(128, 0, 128, 1)">04</span>:<span style="color: rgba(128, 0, 128, 1)">54.377</span> [INFO ] [main] [org.apache.coyote.http11.Http11NioProtocol] Starting ProtocolHandler [<span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">http-nio-4567</span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(0, 0, 0, 1)">]( K  ?& M9 ?( ]
webapp busybox </span><span style="color: rgba(128, 0, 128, 1)">14</span>:<span style="color: rgba(128, 0, 128, 1)">04</span>:<span style="color: rgba(128, 0, 128, 1)">54.481</span> [INFO ] [main] [org.springframework.boot.web.embedded.tomcat.TomcatWebServer] Tomcat started on port(s): <span style="color: rgba(128, 0, 128, 1)">4567</span> (http) with context path <span style="color: rgba(128, 0, 0, 1)">''</span><span style="color: rgba(0, 0, 0, 1)">
$ M+ b4 L0 u6 |* _( \. f0 |) wwebapp busybox </span><span style="color: rgba(128, 0, 128, 1)">14</span>:<span style="color: rgba(128, 0, 128, 1)">04</span>:<span style="color: rgba(128, 0, 128, 1)">54.509</span> [INFO ] [main] [org.demo.webapp.todolist.TodoListApplication] Started TodoListApplication <span style="color: rgba(0, 0, 255, 1)">in</span> <span style="color: rgba(128, 0, 128, 1)">6.235</span> seconds (JVM running <span style="color: rgba(0, 0, 255, 1)">for</span> <span style="color: rgba(128, 0, 128, 1)">8.074</span><span style="color: rgba(0, 0, 0, 1)">)
; r" E. i) \; Kwebapp webapp/ d* u+ v. z# ?4 I, w5 r* C" [+ c
webapp webapp   .   ____          _            __ _ _
9 y+ C4 O: c3 M1 H4 Ywebapp webapp  </span>/\\ / ___<span style="color: rgba(128, 0, 0, 1)">'</span><span style="color: rgba(128, 0, 0, 1)">_ __ _ _(_)_ __  __ _ \ \ \ \</span>
3 [7 s7 C9 p' S; e: vwebapp webapp ( ( )\___ | <span style="color: rgba(128, 0, 0, 1)">'</span><span style="color: rgba(128, 0, 0, 1)">_ | </span><span style="color: rgba(128, 0, 0, 1)">'</span>_| | <span style="color: rgba(128, 0, 0, 1)">'</span><span style="color: rgba(128, 0, 0, 1)">_ \/ _` | \ \ \ \</span>
- ~" c' {, w" R0 s. Wwebapp webapp  \\/  ___)| |_)| | | | | || (_| |<span style="color: rgba(0, 0, 0, 1)">  ) ) ) )# T! L3 v2 Q5 V: b. g$ {! q4 f8 S
webapp webapp   </span><span style="color: rgba(128, 0, 0, 1)">'</span><span style="color: rgba(128, 0, 0, 1)">  |____| .__|_| |_|_| |_\__, | / / / /</span>
- X, F! C* E8 x+ Fwebapp webapp  =========|_|==============|___/=/_/_/_/<span style="color: rgba(0, 0, 0, 1)">
$ t. W0 g6 I8 W' V4 p) Kwebapp webapp  :: Spring Boot ::                (v2.</span><span style="color: rgba(128, 0, 128, 1)">4.2</span><span style="color: rgba(0, 0, 0, 1)">)
/ X: k& D$ ]  }( |# ?webapp webapp
$ k; a  _  A6 ~& A1 `webapp webapp </span><span style="color: rgba(128, 0, 128, 1)">14</span>:<span style="color: rgba(128, 0, 128, 1)">04</span>:<span style="color: rgba(128, 0, 128, 1)">50.124</span> [INFO ] [main] [org.demo.webapp.todolist.TodoListApplication] Starting TodoListApplication v1.<span style="color: rgba(128, 0, 128, 1)">0</span>-SNAPSHOT using Java <span style="color: rgba(128, 0, 128, 1)">1.8</span>.0_111 on webapp with PID <span style="color: rgba(128, 0, 128, 1)">1</span> (/opt/soft/webapp.jar started by root <span style="color: rgba(0, 0, 255, 1)">in</span> /opt/<span style="color: rgba(0, 0, 0, 1)">soft)
" h+ t, T7 n) A4 Nwebapp webapp </span><span style="color: rgba(128, 0, 128, 1)">14</span>:<span style="color: rgba(128, 0, 128, 1)">04</span>:<span style="color: rgba(128, 0, 128, 1)">50.165</span><span style="color: rgba(0, 0, 0, 1)"> [INFO ] [main] [org.demo.webapp.todolist.TodoListApplication] No active profile set, falling back to default profiles: default; ~) h& L* `1 q2 W6 w, Y7 C+ k# u0 g
webapp webapp </span><span style="color: rgba(128, 0, 128, 1)">14</span>:<span style="color: rgba(128, 0, 128, 1)">04</span>:<span style="color: rgba(128, 0, 128, 1)">53.158</span> [INFO ] [main] [org.springframework.boot.web.embedded.tomcat.TomcatWebServer] Tomcat initialized with port(s): <span style="color: rgba(128, 0, 128, 1)">4567</span><span style="color: rgba(0, 0, 0, 1)"> (http)* V; R" q- f# B. X* t% l& K
webapp webapp </span><span style="color: rgba(128, 0, 128, 1)">14</span>:<span style="color: rgba(128, 0, 128, 1)">04</span>:<span style="color: rgba(128, 0, 128, 1)">53.197</span> [INFO ] [main] [org.apache.coyote.http11.Http11NioProtocol] Initializing ProtocolHandler [<span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">http-nio-4567</span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(0, 0, 0, 1)">]
' F! v0 R, W9 U: Q/ z7 k; E; hwebapp webapp </span><span style="color: rgba(128, 0, 128, 1)">14</span>:<span style="color: rgba(128, 0, 128, 1)">04</span>:<span style="color: rgba(128, 0, 128, 1)">53.200</span><span style="color: rgba(0, 0, 0, 1)"> [INFO ] [main] [org.apache.catalina.core.StandardService] Starting service [Tomcat]2 c, w, Q: |2 j( `! \1 N
webapp webapp </span><span style="color: rgba(128, 0, 128, 1)">14</span>:<span style="color: rgba(128, 0, 128, 1)">04</span>:<span style="color: rgba(128, 0, 128, 1)">53.201</span> [INFO ] [main] [org.apache.catalina.core.StandardEngine] Starting Servlet engine: [Apache Tomcat/<span style="color: rgba(128, 0, 128, 1)">9.0</span>.<span style="color: rgba(128, 0, 128, 1)">41</span><span style="color: rgba(0, 0, 0, 1)">]; P, P6 s' W. g( u+ @( U
webapp webapp </span><span style="color: rgba(128, 0, 128, 1)">14</span>:<span style="color: rgba(128, 0, 128, 1)">04</span>:<span style="color: rgba(128, 0, 128, 1)">53.324</span> [INFO ] [main] [org.apache.catalina.core.ContainerBase.[Tomcat].[localhost].[/<span style="color: rgba(0, 0, 0, 1)">]] Initializing Spring embedded WebApplicationContext
2 I" }+ f* C7 {2 wwebapp webapp </span><span style="color: rgba(128, 0, 128, 1)">14</span>:<span style="color: rgba(128, 0, 128, 1)">04</span>:<span style="color: rgba(128, 0, 128, 1)">53.325</span> [INFO ] [main] [org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext] Root WebApplicationContext: initialization completed <span style="color: rgba(0, 0, 255, 1)">in</span> <span style="color: rgba(128, 0, 128, 1)">2952</span><span style="color: rgba(0, 0, 0, 1)"> ms
; K' y9 a+ S, G4 lwebapp webapp </span><span style="color: rgba(128, 0, 128, 1)">14</span>:<span style="color: rgba(128, 0, 128, 1)">04</span>:<span style="color: rgba(128, 0, 128, 1)">53.801</span> [INFO ] [main] [org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor] Initializing ExecutorService <span style="color: rgba(128, 0, 0, 1)">'</span><span style="color: rgba(128, 0, 0, 1)">applicationTaskExecutor</span><span style="color: rgba(128, 0, 0, 1)">'</span><span style="color: rgba(0, 0, 0, 1)">
; W4 _& |* G7 ~& O1 G; ~& Owebapp webapp </span><span style="color: rgba(128, 0, 128, 1)">14</span>:<span style="color: rgba(128, 0, 128, 1)">04</span>:<span style="color: rgba(128, 0, 128, 1)">54.264</span> [WARN ] [main] [org.springframework.boot.autoconfigure.thymeleaf.ThymeleafAutoConfiguration$DefaultTemplateResolverConfiguration] Cannot <span style="color: rgba(0, 0, 255, 1)">find</span> template location: classpath:/templates/<span style="color: rgba(0, 0, 0, 1)"> (please add some templates or check your Thymeleaf configuration); t$ l7 q2 B- ]! g( e
webapp webapp </span><span style="color: rgba(128, 0, 128, 1)">14</span>:<span style="color: rgba(128, 0, 128, 1)">04</span>:<span style="color: rgba(128, 0, 128, 1)">54.377</span> [INFO ] [main] [org.apache.coyote.http11.Http11NioProtocol] Starting ProtocolHandler [<span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">http-nio-4567</span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(0, 0, 0, 1)">]+ k7 O' b; K7 B/ T) Y
webapp webapp </span><span style="color: rgba(128, 0, 128, 1)">14</span>:<span style="color: rgba(128, 0, 128, 1)">04</span>:<span style="color: rgba(128, 0, 128, 1)">54.481</span> [INFO ] [main] [org.springframework.boot.web.embedded.tomcat.TomcatWebServer] Tomcat started on port(s): <span style="color: rgba(128, 0, 128, 1)">4567</span> (http) with context path <span style="color: rgba(128, 0, 0, 1)">''</span><span style="color: rgba(0, 0, 0, 1)">
% j+ m( m  Y' m* v/ V$ k  Bwebapp webapp </span><span style="color: rgba(128, 0, 128, 1)">14</span>:<span style="color: rgba(128, 0, 128, 1)">04</span>:<span style="color: rgba(128, 0, 128, 1)">54.509</span> [INFO ] [main] [org.demo.webapp.todolist.TodoListApplication] Started TodoListApplication <span style="color: rgba(0, 0, 255, 1)">in</span> <span style="color: rgba(128, 0, 128, 1)">6.235</span> seconds (JVM running <span style="color: rgba(0, 0, 255, 1)">for</span> <span style="color: rgba(128, 0, 128, 1)">8.074</span>)</pre>
# i) F5 g# X2 n7 j) u+ Y" A9 s</div>+ ?0 Q# C6 Z4 I8 q$ ]! G" F
<p>&nbsp;</p>
, c; d: R+ n  z
回复

使用道具 举报

懒得打字嘛,点击右侧快捷回复 【右侧内容,后台自定义】
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|飞雪团队

GMT+8, 2026-6-3 08:50 , Processed in 0.070096 second(s), 21 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表