Kubernetes - 模拟Pod OOM

2023-05-31
#!/bin/bash
echo deb https://mirrors.tencent.com/debian/ bullseye main non-free contrib >/etc/apt/sources.list
echo deb-src https://mirrors.tencent.com/debian/ bullseye main non-free contrib >>/etc/apt/sources.list
echo deb https://mirrors.tencent.com/debian-security/ bullseye-security main >>/etc/apt/sources.list
echo deb-src https://mirrors.tencent.com/debian-security/ bullseye-security main >>/etc/apt/sources.list
echo deb https://mirrors.tencent.com/debian/ bullseye-updates main non-free contrib >>/etc/apt/sources.list
echo deb-src https://mirrors.tencent.com/debian/ bullseye-updates main non-free contrib >>/etc/apt/sources.list
echo deb https://mirrors.tencent.com/debian/ bullseye-backports main non-free contrib >>/etc/apt/sources.list
echo deb-src https://mirrors.tencent.com/debian/ bullseye-backports main non-free contrib >>/etc/apt/sources.list


apt-get update -y
apt-get install vim python3 python3-pip -y

cat > /tmp/testmemory.py << EOF
import psutil
import time

increment = 1024 * 1024 * 50

data = bytearray(increment)
process = psutil.Process()

while True:
    data += bytearray(increment)
    mem_info = process.memory_info()
    time.sleep(1)
    print(f"Memory used: {mem_info.rss / 1024 / 1024} MB")
EOF


pip3 install psutil

标题:Kubernetes - 模拟Pod OOM
地址:https://blog.njqhome.com:8443/articles/2023/04/30/1682865960861.html