kubernetes - 一个或多个容器没有资源限制 - VS Code Kubernetes 工具中的警告
问题描述
创建 pod-definition.yml 文件后。
apiVersion: v1
kind: Pod
metadata:
name: myapp-pod
labels:
app: myapp
type: server
spec:
containers:
- name: nginx-container
image: nginx
linter 给出了这个警告。
One or more containers do not have resource limits - this could starve other processes
解决方案
为每个容器声明内存和cpu的资源请求和限制是一种很好的做法。这有助于将容器调度到具有可用于您的 Pod 的资源的节点,并且还可以使您的 Pod 不使用其他 Pod 需要的资源 - 因此“这可能会使其他进程饿死”消息。
例如,为您的示例添加资源请求和限制
apiVersion: v1
kind: Pod
metadata:
name: myapp-pod
labels:
app: myapp
type: server
spec:
containers:
- name: nginx-container
image: nginx
resources:
limits:
memory: 512Mi
cpu: "1"
requests:
memory: 256Mi
cpu: "0.2"
推荐阅读
- python - 类的类型提示
- excel - 代码仅在少数条目上执行并且缺少通过规则的条目?
- c# - 提取 C# 类中声明的枚举类型
- java - Hibernate 在数据库表中为双向关联创建多个外键
- excel - 如何为 word 中存在的多个图像插入多个标题和超链接?例如图片下方的“Figure:1”及其超链接
- javascript - 如何使子菜单始终位于标题下?
- python - 使用熊猫与最近的分钟合并
- html - 以角度将文本文件内容刷新为div
- java - 覆盖抽象类的@bean方法以防止bean注入
- amazon-web-services - 创建代码构建项目时出现代码构建错误'无权执行:ecr:DescribeRepositories on resource:*'