k8s pod 中想要运行可以使pod内存自增的脚本
1 2 3 4 5 6 7 8
| #!/bin/bash mkdir -p /tmp/skyfans/memory mount -t tmpfs -o size=10240M tmpfs /tmp/skyfans/memory dd if=/dev/zero of=/tmp/skyfans/memory/block sleep 60 rm /tmp/skyfans/memory/block umount /tmp/skyfans/memory rmdir /tmp/skyfans/memory
|
结果在mount 挂载的时候报错
1
| mount: permission denied (are you root?)
|
简单修改pod权限即可
1 2 3 4 5
| spec: containers: - securityContext: capabilities: add: ["SYS_ADMIN"]
|
参考文档:
https://blog.csdn.net/xzm5708796/article/details/90143416
https://cloud.tencent.com/developer/ask/sof/876479