飞雪团队

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

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

[复制链接]

4822

主题

4910

帖子

1万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
16784
发表于 2022-2-12 14:35:42 | 显示全部楼层 |阅读模式
0 @# h* |' \7 o* o% I
<p>kubectl作为我们主要的操作K8S的工具,其具备非常丰富的功能,但是如果不经过打磨,使用起来还是存在诸多不便,今天我们来看看如何将我们的kubectl打磨的更加易用。</p>
1 ~( g/ ?( L+ n" M& j" F<p>&nbsp;</p>
& Q3 ~. p6 d! ]& G1 ~: }) q, C<p>一、命令自动补全</p>  F" f/ `$ I7 l1 g4 w' _& x; z
<p>kubectl中提供非常多的命令,如果每一次都要手动一个字符一个字符的敲未免太累了,那么如何配置自动补全呢?这里以ubuntu系统为例:</p>
7 [* L' B: j  P<p>1、安装auto-completion工具</p># _$ }) [% {7 Y/ }$ l
<div class="cnblogs_code">
: F! r8 i/ m& M+ @8 Q* h6 u<pre>$ <span style="color: rgba(0, 0, 255, 1)">sudo</span><span style="color: rgba(0, 0, 0, 1)"> apt update
, M5 `% ]7 N4 z1 y- UHit:</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>
: K) B/ J3 o4 d3 O. o  DHit:<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>; n- s, r2 D% j7 u' p% ]* Y* i
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># `* x' ]) @+ k7 L7 G8 Z2 ]
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>* H, ?6 R) C( R5 Q2 O9 K: }# {0 [
Hit:<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>! g8 k- {* k4 I) g
<span style="color: rgba(0, 0, 0, 1)">Reading package lists... Done- b3 K$ ~- D& b* e7 q0 P3 h
Building dependency tree7 Q- D1 \0 o- A
Reading state information... Done
3 i0 n* N" F4 H4 @1 C6 \</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.
( T, E; y0 U+ {! B! S$ </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)">completion
! p5 z/ b( }5 P; ^3 P6 WReading package lists... Done4 D" I: u  E  `' O2 m
Building dependency tree, c- @9 }0 Q( ?
Reading state information... Done& W9 d8 C& F5 Q7 W2 M$ h
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).6 a" O) ]# i! r$ {+ x
</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>
( q6 S- Y* ?# \6 h9 b</div>
$ u, n6 |+ j9 P8 Q, X& [<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>
$ S9 c$ U& y  ?<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>. n# p* C. H$ X9 |. i2 p
<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 D# [( s0 Q" J' p
<div class="cnblogs_code">
) U/ D0 k& f5 i/ Q( v<pre>source &lt;<span style="color: rgba(0, 0, 0, 1)">(kubectl completion bash)( C/ ?& x# h  U
</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>
; l( F& R# i3 k) Y( c8 |</div>
5 [$ i! l7 s+ g$ N. E) O9 ^<p><strong>Zsh</strong>:</p>
6 z; T, s+ P. p3 Z' d% i, Q<div class="cnblogs_code">
, J3 E6 C) ]+ n5 R$ N$ F7 R<pre>source &lt;<span style="color: rgba(0, 0, 0, 1)">(kubectl completion zsh)) b3 W* g' o5 e+ l5 \
</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>( V) Y7 C/ |5 W) A) o: i& [
</div>$ W2 b2 s- c" Z; q) |* [
<p>配置后就可以通过Tab键自动补全命令啦!</p>
3 s2 m- A! N1 [1 [% Z; L( h<p>&nbsp;</p>, [0 b8 X; i& i( @8 `
<p>二、配置kubectl别名</p>3 ]) R- |+ O& l6 G/ d$ r! U
<p>我们可以通过设置别名简化kubectl命令,编辑.bashrc文件,添加如下内容:</p>
, O- z  a+ K, r. q; @0 H6 A0 W( u<div class="cnblogs_code">
* k5 e  @# L" L! E  \<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)">! j5 z3 A7 K5 a6 t3 f
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)">
" j7 }+ ~$ {; W6 L, J  ialias 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)">
( r" t; K2 K! T% G" c3 X9 |* l9 Salias 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)">
$ I$ N5 o/ r1 _/ o! T/ f" _. s5 Ialias 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)">' [% e' \1 M1 |7 E
alias 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)">
! `$ U. v6 f) lalias 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>
0 g: k- ?+ _( Y4 g8 r</div>
5 M! T( q  Z# |. v<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>7 K; w0 e9 \8 t+ S
<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>
& a4 B' [' u& h! R3 V# n<div class="cnblogs_code">& q9 Y/ ~$ c: d
<pre>$ <span style="color: rgba(0, 0, 255, 1)">sudo</span><span style="color: rgba(0, 0, 0, 1)"> ka webapp_pod.yaml9 p' l% ~0 B! h6 l+ ]: |$ N* z
pod</span>/<span style="color: rgba(0, 0, 0, 1)">webapp created
. f3 ]4 w0 L6 e9 C' D( W$ </span><span style="color: rgba(0, 0, 255, 1)">sudo</span><span style="color: rgba(0, 0, 0, 1)"> kg pods' J; Q' ~6 `# _# c* ?" s; Z9 i& b# M
NAME     READY   STATUS              RESTARTS   AGE+ w1 W2 q1 ~+ K, _7 u
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)">          7s
$ B, {) }1 b: v6 S3 T6 y9 s4 w$ </span><span style="color: rgba(0, 0, 255, 1)">sudo</span><span style="color: rgba(0, 0, 0, 1)"> kd pod webapp  W/ R) s: f0 P3 K, _0 w
Name:         webapp
" u+ W2 O0 w* `: j- s3 v! ]Namespace:    default& W; y4 {4 O) P& P0 v
Priority:     </span><span style="color: rgba(128, 0, 128, 1)">0</span><span style="color: rgba(0, 0, 0, 1)">
# y! r% `/ J4 {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)">- E& C* }2 ?! S9 i5 D  Q
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)">
0 `. X; m% f  b0 JLabels:       app</span>=<span style="color: rgba(0, 0, 0, 1)">webapp
  I+ {1 a/ ?+ J$ M) CAnnotations:  </span>&lt;none&gt;<span style="color: rgba(0, 0, 0, 1)">
  H0 e4 p, N2 E+ _& JStatus:       Running! r, A3 m4 E8 y7 ]7 _
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)">  d  Z  ~5 m/ S9 k! @6 ?9 p/ i
IPs:
8 M( ^, y$ K% y& z" E  j  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)">
+ H6 t" N0 Z2 c& sContainers:
+ ?! d) U) t4 S# M# D+ T0 M0 A  webapp:
; K! i4 C" z; p7 D+ b    Container ID:   docker:</span><span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">d9ddf9dd47de12b53f2119bf75df6706bee2e7711509638ad52adc9addeda704</span>
4 v$ V/ c* T: W+ J) v. ^& U1 E    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)">: ]; u" P& @  N: |  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>
, V7 u5 ], O  l    Port:           <span style="color: rgba(128, 0, 128, 1)">5000</span>/<span style="color: rgba(0, 0, 0, 1)">TCP0 n& J; m9 z$ ?3 P: @% }$ M
    Host Port:      </span><span style="color: rgba(128, 0, 128, 1)">0</span>/<span style="color: rgba(0, 0, 0, 1)">TCP
6 [/ |+ Y6 D9 b4 |    State:          Running
: w" y  d4 Z, ]+ f7 x5 K* t      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)">6 m9 y4 y, x5 D; Z/ o
    Ready:          True3 U# Q, @" I  y
    Restart Count:  </span><span style="color: rgba(128, 0, 128, 1)">0</span><span style="color: rgba(0, 0, 0, 1)">
1 n, D; U" d6 ^* w2 x5 l8 d9 j; ?    Environment:    </span>&lt;none&gt;<span style="color: rgba(0, 0, 0, 1)">. N: z, l( X& @
    Mounts:( F4 g1 T; e" C
      </span>/tmp from webapp-<span style="color: rgba(0, 0, 0, 1)">logs (rw)* B1 J3 B, K" X
      </span>/var/run/secrets/kubernetes.io/serviceaccount from default-token-<span style="color: rgba(0, 0, 0, 1)">pcr2h (ro)! A9 n9 X2 ^' L" o" p. s7 n
  busybox:
$ r0 g+ g6 ?* D2 Q9 {: k    Container ID:  docker:</span><span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">6a6a35a628a782fc643af3dd49986bbc77c23de1ae4726bc521c77f61abbbf5d</span>
4 g; S* ^6 c  u( R<span style="color: rgba(0, 0, 0, 1)">    Image:         busybox) |0 Z/ A+ _: {% r1 I! Z
    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>+ @9 e1 `5 y' i2 E/ ^$ \& X7 [
    Port:          &lt;none&gt;<span style="color: rgba(0, 0, 0, 1)">
9 l) [! D) Y0 J" p; O# a. d5 a9 c, ]    Host Port:     </span>&lt;none&gt;<span style="color: rgba(0, 0, 0, 1)">
; m& I1 k$ {4 `4 ^& i& v    Command:' k2 E! X% u. n8 o, c4 r
      </span><span style="color: rgba(0, 0, 255, 1)">sh</span>8 m( Q+ p( j7 |6 O
      -<span style="color: rgba(0, 0, 0, 1)">c. `2 x0 S0 J+ @" m& ~  k' @) ]
      </span><span style="color: rgba(0, 0, 255, 1)">tail</span> -f /logs/<span style="color: rgba(0, 0, 0, 1)">log.out# q! e% p: G4 e  h
    State:          Running
, W1 N( l6 I5 B5 d: z4 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)">
" w" N  Y7 H+ h) n, U! H    Ready:          True+ f5 z3 i7 [5 v7 s" F
    Restart Count:  </span><span style="color: rgba(128, 0, 128, 1)">0</span><span style="color: rgba(0, 0, 0, 1)">
2 {; [& n8 {. G/ T- V* h2 u    Environment:    </span>&lt;none&gt;<span style="color: rgba(0, 0, 0, 1)">5 `: R. F4 m, ~7 Y* Z% l; q
    Mounts:0 {: Y3 {8 P3 D3 w# m
      </span>/logs from webapp-<span style="color: rgba(0, 0, 0, 1)">logs (rw)! I+ I; m8 A" E1 _
      </span>/var/run/secrets/kubernetes.io/serviceaccount from default-token-<span style="color: rgba(0, 0, 0, 1)">pcr2h (ro)
3 T* I6 D! J5 J# {+ Z: g1 sConditions:/ F0 e' n& N3 u% L) j/ M, |
  Type              Status
' F& `7 j4 Y5 P5 n* n, o8 ]  Initialized       True% u2 X1 q8 q4 d: p* T6 J7 n; ^
  Ready             True
  T: z. D- h2 J: w  ContainersReady   True
2 E6 t4 z7 y' f  PodScheduled      True
0 |& h  G2 O$ r7 h, MVolumes:& s$ d' {& N" I' [  P5 N
  webapp</span>-<span style="color: rgba(0, 0, 0, 1)">logs:
" s* D  |- [7 ?+ 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>
2 s6 b, b" K$ V" J<span style="color: rgba(0, 0, 0, 1)">    Medium:
' m0 K' E% I; l$ j: O) g) m$ [    SizeLimit:  </span>&lt;unset&gt;<span style="color: rgba(0, 0, 0, 1)">
1 h6 I& M% ?& x& G( q  default</span>-token-<span style="color: rgba(0, 0, 0, 1)">pcr2h:. \. \+ e# d9 ~
    Type:        Secret (a volume populated by a Secret)
; B. u6 G7 k( ^# N5 G( P    SecretName:  default</span>-token-<span style="color: rgba(0, 0, 0, 1)">pcr2h
* V2 @8 K# Z! G5 i    Optional:    </span><span style="color: rgba(0, 0, 255, 1)">false</span><span style="color: rgba(0, 0, 0, 1)">
) `4 @4 V8 ~. UQoS Class:       BestEffort  D2 K0 o9 v1 @- c
Node</span>-Selectors:  &lt;none&gt;<span style="color: rgba(0, 0, 0, 1)">
% N4 B$ K( H$ \. I2 g' H! R; `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)"> 300s" k' W& r. v! i* E+ M/ X
                 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)"> 300s
3 h; p% d4 u- w( E# rEvents:: ^% `$ H/ \! e/ v" B( v
  Type    Reason     Age    From               Message
" T$ F. Y* V5 K0 g- k8 c3 j  </span>----    ------     ----   ----               -------<span style="color: rgba(0, 0, 0, 1)">
" q$ U/ ]7 S- E' |  Normal  Scheduled  2m23s  default</span>-scheduler  Successfully assigned default/<span style="color: rgba(0, 0, 0, 1)">webapp to ayato. H2 v) s4 Q. C% \  W3 e& z  j2 N
  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* K( ^0 D2 R. k; B( w3 t
  Normal  Created    2m21s  kubelet            Created container webapp' m  R( H3 J6 ]; W5 _
  Normal  Started    2m21s  kubelet            Started container webapp+ l- F+ E! y* X7 Y9 h% 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)">
% N- H8 t# U6 @2 B  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: s- N' a3 E% k9 f+ J
  Normal  Created    15s    kubelet            Created container busybox# U: F& h3 [9 x4 S6 l
  Normal  Started    14s    kubelet            Started container busybox</span></pre>; c2 X% b. ~* r: B6 s6 w2 M7 F0 a% Q: p
</div>; J2 R" ]& h( b
<p>真的是飞一般的感觉!!!</p>5 `% ]2 J. _* r6 S) {5 O7 A
<p>&nbsp;</p>
; V/ C( N% g$ K* [6 _5 x<p>三、Context和Namespace切换</p>' i% |: `) z. M& ]
<p>我们在公司的容器平台上使用kubectl时,经常需要切换context和namespace,导致命令非常繁琐,那有没有简便的方式呢?—— kubectx</p>
! o9 S2 H  ~) S5 c8 m$ F" F<p>kubectx安装</p>* A. A) a! x' X  R+ Z4 L8 o
<div class="cnblogs_code">
8 T; D- @/ c# t6 T3 U<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>. T# O. n4 i3 |) F
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)">...8 k2 z& ]- C' }# e, X7 S8 l! S2 h
remote: 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)">.
! a: u( k: u4 K. P8 Xremote: 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 b9 U3 Y9 Z+ Q9 \0 B- qremote: 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)">.& l' F" X9 j5 {0 d) T
remote: 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)">
) F% v( X5 H2 VReceiving 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)">.
2 y9 w+ s% u% o* b3 W0 M8 ^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)">.$ Y$ u# }* c- i
$ </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 b9 b( P( d3 |( Z2 n. _  e7 w0 s. G
$ </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>
1 ]' O6 H$ S! i6 n+ Y/ E0 g9 Y* e</div>
  l# u9 y8 q. N8 @% N0 U2 k<p>我们来看一下效果:</p>8 ]# B  Q  C/ W. V) [# E- }4 F! T. [
<div class="cnblogs_code">
) r( x- R9 T4 p# \$ r<pre>$ <span style="color: rgba(0, 0, 255, 1)">sudo</span><span style="color: rgba(0, 0, 0, 1)"> k ctx0 X: F1 k& \1 o$ u# c
minikube! J. q  N% \+ o
$ </span><span style="color: rgba(0, 0, 255, 1)">sudo</span><span style="color: rgba(0, 0, 0, 1)"> k ctx minikube
) S( C$ F5 a2 [3 O( @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)">.
+ L# d5 J7 M/ V- w6 V% |$ </span><span style="color: rgba(0, 0, 255, 1)">sudo</span><span style="color: rgba(0, 0, 0, 1)"> k ns
: F& {8 B1 b; T4 a3 y2 [default
1 Q0 P: }2 o6 \( S! _, I. P6 ^kube</span>-node-<span style="color: rgba(0, 0, 0, 1)">lease0 S( y# T: @$ ]6 t3 R- q
kube</span>-<span style="color: rgba(0, 0, 0, 1)">public2 }  j8 A$ d. d; s
kube</span>-<span style="color: rgba(0, 0, 0, 1)">system
# R$ w. p+ ]2 a! G$ w8 ukubernetes</span>-<span style="color: rgba(0, 0, 0, 1)">dashboard1 @+ K, m6 J3 C4 o
$ </span><span style="color: rgba(0, 0, 255, 1)">sudo</span> k ns kube-<span style="color: rgba(0, 0, 0, 1)">public6 `) U  ]; h4 R6 @4 m& e7 ?2 q
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.
$ R: P: {; l' V- QActive 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)">.% z& M% k# }; b% ~6 y
$ </span><span style="color: rgba(0, 0, 255, 1)">sudo</span><span style="color: rgba(0, 0, 0, 1)"> k ns default8 s4 Y( u0 g' E/ X/ 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.
3 c: o& J4 _  Q: q$ `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>6 z& u# S. `; M* [1 Z, P9 @* y
</div>
, F+ ]/ r$ _1 B( v- ~% [<p>&nbsp;</p>
% ~2 R* I7 x9 `; c( U4 M4 g/ X5 [# F<p>四、跟踪查看多个Pod的日志</p>- s# R; F# `% C
<p>我们一般使用kubectl logs命令查看Pod日志,但是它不能通过-f参数同时跟踪查看多个Pod日志,这就不方便了,毕竟实际生产环境中每个服务都会有多个Pod,这时我们可以使用stern这个工具,它具备如下能力:</p>9 S! _2 x, ]" Z. X* a3 T% \
<ul class="list-paddingleft-2">0 F0 b, ]! G6 |6 x2 n: \% l4 ]
<li>! B5 T; W% R7 y- v0 a1 |
<p>允许使用正则表达式来选择需要查看的PodName</p>7 ^! o7 E: _* M* A% y4 \) W: I
</li>
' T9 u: R- j8 i+ k. |. J<li>
& B7 @( v2 }1 i2 H, x4 F9 V<p>为不同 Pod 的日志展示不同的颜色</p>
$ w; E3 A  }' O</li>9 ?; I1 L  n8 v: q
<li>8 @/ E. n# T9 n( `8 e& Q2 |, o
<p>跟踪日志过程中假如有符合规则的新 Pod 被创建, 那么会自动添加到输出中</p>
% m* f: k/ w& c</li>
% n7 M5 d3 v6 Z" ^$ ^</ul>7 s5 _/ q8 T8 L, o; K8 x+ ?8 s2 _
<p>首先安装stern(下载stern时可能较慢可以多试几次):</p>
4 v6 X/ n9 E8 ~4 X0 T0 \1 F  J+ ~<div class="cnblogs_code">! t. U2 I9 U$ q3 U) x! g
<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>4 L: S/ v$ u* [% g
<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>
9 Z% u: Z6 }( G5 H<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>. W& z$ ?0 e4 W" e
</div>
& a: H" M9 b, s/ B* x( q3 d<p>安装完毕后让我一起感受一下stern的魅力吧,我的Pod里面有两个容器:webapp和busybox,如果使用kubectl logs 还得指定具体的容器,而使用stern就没有这样的限制。</p>+ K6 }" C9 O: V1 d/ F! k+ v0 }
<div class="cnblogs_code">5 _# K; [4 ~  L* M* z
<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)"> .
  H; @7 _- m0 c* V</span>+<span style="color: rgba(0, 0, 0, 1)"> webapp › busybox
( @; H  n+ A1 A, m& \</span>+<span style="color: rgba(0, 0, 0, 1)"> webapp › webapp6 ^6 V0 S0 _8 X
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)">]
) }" ?3 o  W* j$ y% T5 ^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]
, v+ ~) K% R, G" y+ o/ q9 Jwebapp 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)">]$ ]1 F5 A3 Z. L/ t, V9 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.324</span> [INFO ] [main] [org.apache.catalina.core.ContainerBase.[Tomcat].[localhost].[/<span style="color: rgba(0, 0, 0, 1)">]] Initializing Spring embedded WebApplicationContext
+ e1 Q1 @! ]4 Mwebapp 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)"> ms0 ?6 X% }# n! r0 M6 z
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)">
  M7 l1 \3 k0 L# `$ e* lwebapp 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)
2 @) A: [4 ?6 g7 g4 m& c1 C' ywebapp 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)">]  U; J+ Y; c0 ]1 c6 ?8 m1 x) ?0 x
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)">/ K2 S5 _5 E1 H1 c; `: d" s
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.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)">)! {  Y/ i/ g1 ^. A% _
webapp webapp
( \( x9 [2 [6 s* s6 ~/ Ywebapp webapp   .   ____          _            __ _ _
3 I( k$ ~) p9 m5 wwebapp webapp  </span>/\\ / ___<span style="color: rgba(128, 0, 0, 1)">'</span><span style="color: rgba(128, 0, 0, 1)">_ __ _ _(_)_ __  __ _ \ \ \ \</span>1 W: e% b+ C; C0 K6 n: a2 K
webapp 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>; d" ]" _! k. a$ T: E. V% u
webapp webapp  \\/  ___)| |_)| | | | | || (_| |<span style="color: rgba(0, 0, 0, 1)">  ) ) ) )- H1 P! X4 ], I# M& f0 F
webapp webapp   </span><span style="color: rgba(128, 0, 0, 1)">'</span><span style="color: rgba(128, 0, 0, 1)">  |____| .__|_| |_|_| |_\__, | / / / /</span>
  V5 l% R% I$ t6 Owebapp webapp  =========|_|==============|___/=/_/_/_/<span style="color: rgba(0, 0, 0, 1)">
: c0 c; Z. J7 ?. {6 w. Owebapp webapp  :: Spring Boot ::                (v2.</span><span style="color: rgba(128, 0, 128, 1)">4.2</span><span style="color: rgba(0, 0, 0, 1)">)
/ M7 W8 j1 x' ^4 O/ p/ p- w, R& B1 F1 }5 nwebapp webapp7 x4 _8 B* [6 r6 W: v1 I8 }) [
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)$ Q& Q* M$ Z: X( Q
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.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, ?" _* [& _1 E4 f
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)- ?$ y* ^2 v, I' k# u, A
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)">]
( _' w3 c  ]! ewebapp 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]% L5 E2 ]$ W6 H1 S7 X( s7 c3 P
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)">]
$ W4 O1 t. J2 F% W3 ^0 Pwebapp 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
/ M4 ?4 J0 D5 z& N5 a$ |4 B; qwebapp 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
  N6 n$ A; D0 X- 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.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)">
5 P# R4 Y0 L2 c* ^% I, H# jwebapp 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)# k0 k9 h6 C5 i6 V; K% K) 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)">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)">]
8 c& ^1 u* a. h& M, u- r, zwebapp 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)">
/ O7 A. _; Z  twebapp 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>
# y' V# p( o7 I: t8 E- B</div>
& [9 _9 @' v6 z2 }( k) E4 M( S<p>&nbsp;</p>( t$ ~; K* R0 f. ^  w! B
回复

使用道具 举报

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

本版积分规则

手机版|飞雪团队

GMT+8, 2024-9-20 00:23 , Processed in 0.070219 second(s), 22 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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