Kubernetes 查看容器进程使用内存情况

Kubernetes About 1,772 words

Node 节点查看

如果有权限访问Node节点,可以在Node节点上执行docker top {containerId}。但只能查看运行的进程。

Kubernetes使用的容器类型不同,命令不同,如:Podmancontainerd等。

docker top my-java-service-id

有命令容器

对于有toppsfree等命令的容器,使用这些命令就可以查看。

无命令容器

但更多容器是没有topps等命令的容器,可以在/proc/{pid}对应的status文件查看。

cat /proc/1/status

输出

VmRSS即为占用内存。

bash-4.4$ cat /proc/1/status
Name:   java
Umask:  0022
State:  S (sleeping)
Tgid:   1
Ngid:   0
Pid:    1
PPid:   0
TracerPid:      0
Uid:    1000    1000    1000    1000
Gid:    0       0       0       0
FDSize: 64
Groups:  
NStgid: 1
NSpid:  1
NSpgid: 1
NSsid:  1
VmPeak: 27270832 kB
VmSize: 20189568 kB
VmLck:         0 kB
VmPin:         0 kB
VmHWM:   1270016 kB
VmRSS:   1269976 kB
RssAnon:         1242740 kB
RssFile:           27236 kB
RssShmem:              0 kB
VmData:  1290308 kB
VmStk:       132 kB
VmExe:         4 kB
VmLib:     23876 kB
VmPTE:      2948 kB
VmSwap:        0 kB
HugetlbPages:          0 kB
CoreDumping:    0
THP_enabled:    1
Threads:        30
SigQ:   0/252975
SigPnd: 0000000000000000
ShdPnd: 0000000000000000
SigBlk: 0000000000000000
SigIgn: 0000000000000000
SigCgt: 2000000181005ccf
CapInh: 00000000a80425fb
CapPrm: 0000000000000000
CapEff: 0000000000000000
CapBnd: 00000000a80425fb
CapAmb: 0000000000000000
NoNewPrivs:     0
Seccomp:        0
Seccomp_filters:        0
Speculation_Store_Bypass:       vulnerable
Cpus_allowed:   ff
Cpus_allowed_list:      0-7
Mems_allowed:   00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000001
Mems_allowed_list:      0
voluntary_ctxt_switches:        52
nonvoluntary_ctxt_switches:     4
Views: 1,201 · Posted: 2023-07-05

————        END        ————

Give me a Star, Thanks:)

https://github.com/fendoudebb/LiteNote

扫描下方二维码关注公众号和小程序↓↓↓

扫描下方二维码关注公众号和小程序↓↓↓


Today On History
Browsing Refresh