0

我登录到kubectl安装了用于连接 Kubernetes 集群的 Linux 堡垒主机。

当我运行任何 kubectl 命令时,在堡垒主机上,如下所示:

kubectl get pods

我收到以下错误:

fatal error: runtime: out of memory

runtime stack:
runtime.throw(0x192cb47, 0x16)
        /usr/local/go/src/runtime/panic.go:617 +0x72 fp=0x7fff534ae560 sp=0x7fff534ae530 pc=0x42d482
runtime.sysMap(0xc000000000, 0x4000000, 0x2d178b8)
        /usr/local/go/src/runtime/mem_linux.go:170 +0xc7 fp=0x7fff534ae5a0 sp=0x7fff534ae560 pc=0x417d07
runtime.(*mheap).sysAlloc(0x2cfef80, 0x2000, 0x2cfef90, 0x1)
        /usr/local/go/src/runtime/malloc.go:633 +0x1cd fp=0x7fff534ae648 sp=0x7fff534ae5a0 pc=0x40ae0d
runtime.(*mheap).grow(0x2cfef80, 0x1, 0x0)
        /usr/local/go/src/runtime/mheap.go:1222 +0x42 fp=0x7fff534ae6a0 sp=0x7fff534ae648 pc=0x425022
runtime.(*mheap).allocSpanLocked(0x2cfef80, 0x1, 0x2d178c8, 0x0)
        /usr/local/go/src/runtime/mheap.go:1150 +0x37f fp=0x7fff534ae6d8 sp=0x7fff534ae6a0 pc=0x424f0f
runtime.(*mheap).alloc_m(0x2cfef80, 0x1, 0x2a, 0x0)
        /usr/local/go/src/runtime/mheap.go:977 +0xc2 fp=0x7fff534ae728 sp=0x7fff534ae6d8 pc=0x424562
runtime.(*mheap).alloc.func1()
        /usr/local/go/src/runtime/mheap.go:1048 +0x4c fp=0x7fff534ae760 sp=0x7fff534ae728 pc=0x456a4c
runtime.(*mheap).alloc(0x2cfef80, 0x1, 0x1002a, 0x0)
        /usr/local/go/src/runtime/mheap.go:1047 +0x8a fp=0x7fff534ae7b0 sp=0x7fff534ae760 pc=0x42483a
runtime.(*mcentral).grow(0x2cffd80, 0x0)
        /usr/local/go/src/runtime/mcentral.go:256 +0x95 fp=0x7fff534ae7f8 sp=0x7fff534ae7b0 pc=0x417785
runtime.(*mcentral).cacheSpan(0x2cffd80, 0x7fd1a382d000)
        /usr/local/go/src/runtime/mcentral.go:106 +0x2ff fp=0x7fff534ae858 sp=0x7fff534ae7f8 pc=0x41728f
runtime.(*mcache).refill(0x7fd1a382d008, 0x2a)
        /usr/local/go/src/runtime/mcache.go:135 +0x86 fp=0x7fff534ae878 sp=0x7fff534ae858 pc=0x416d26
runtime.(*mcache).nextFree(0x7fd1a382d008, 0x2cf6e2a, 0x7fd1a382d008, 0x7fd1a382d000, 0x8)
        /usr/local/go/src/runtime/malloc.go:786 +0x88 fp=0x7fff534ae8b0 sp=0x7fff534ae878 pc=0x40b648
runtime.mallocgc(0x180, 0x190fb40, 0x1, 0x2d17920)
        /usr/local/go/src/runtime/malloc.go:939 +0x76e fp=0x7fff534ae950 sp=0x7fff534ae8b0 pc=0x40bf5e
runtime.newobject(0x190fb40, 0x4000)
        /usr/local/go/src/runtime/malloc.go:1068 +0x38 fp=0x7fff534ae980 sp=0x7fff534ae950 pc=0x40c368
runtime.malg(0x74ac0e00008000, 0x2d015f0)
        /usr/local/go/src/runtime/proc.go:3220 +0x31 fp=0x7fff534ae9c0 sp=0x7fff534ae980 pc=0x436871
runtime.mpreinit(...)
        /usr/local/go/src/runtime/os_linux.go:311
runtime.mcommoninit(0x2cf9240)
        /usr/local/go/src/runtime/proc.go:618 +0xc2 fp=0x7fff534ae9f8 sp=0x7fff534ae9c0 pc=0x430222
runtime.schedinit()
        /usr/local/go/src/runtime/proc.go:540 +0x74 fp=0x7fff534aea50 sp=0x7fff534ae9f8 pc=0x42feb4
runtime.rt0_go(0x7fff534aea88, 0x3, 0x7fff534aea88, 0x0, 0x0, 0x3, 0x7fff534aee07, 0x7fff534aee0f, 0x7fff534aee13, 0x0, ...)
        /usr/local/go/src/runtime/asm_amd64.s:195 +0x11a fp=0x7fff534aea58 sp=0x7fff534aea50 pc=0x458c4a
4

1 回答 1

1

我能够解决这个问题,这是由于堡垒主机上的内存 (RAM) 不足

这是我修复它的方法

首先我运行下面的命令来检查内存利用率:

free -m

这给了我以下输出,确认内存(RAM)不足:

              total        used        free      shared  buff/cache   available
Mem:           3.8G        3.7G         93M        988K         34M         27M
Swap:            0B          0B          0B

您可以临时运行以下命令以释放少量内存 (RAM) 空间:

free && sync && echo 3 > /proc/sys/vm/drop_caches && free

我接下来要做的是升级堡垒主机的 EC2 实例类型,因为它是 AWS EC2 实例,使用此处所述的步骤从t2.medium (4GB)t2.large (8GB) -更改实例类型。基本上,您所要做的就是:

  • 选择实例状态>停止实例
  • 选择操作>实例设置>更改实例类型
  • 选择具有更高容量的新实例类型并选择应用
  • 选择实例状态>启动实例

等待几分钟,一切都应该生效。请注意,升级后堡垒主机的公共 IP 地址可能会发生变化。

参考Kubeflow 部署错误“致命错误:运行时:内存不足”#3803

就这样。

于 2022-02-01T09:39:13.880 回答