[英]Kubernetes: One or more containers do not have resource limits - warning in VS Code Kubernetes tools
創建 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"
如您所知,該警告來自 VS Code 擴展ms-kubernetes-tools.vscode-kubernetes-tools
。 如果您希望 linter 禁用警告
One or more containers do not have resource limits - this could starve other processes
然后編輯 VS Code setting.json
看起來像這樣:
{
"vs-kubernetes": {
"disable-linters": ["resource-limits"],
...
},
...
}
我正在處理我的 YAML 對象文件,以前我將每個對象都放在一個單獨的文件中,最近我注意到對於“部署”對象文件,我有以下 linting 警告:
One or more containers do not have resource limits - this could starve other processes
在解決這個問題之前,我決定稍微重構我的對象定義,並在一個文件中定義多個對象(如果它們相關的話)。 因此,現在我擁有與以前相同的部署以及卷聲明和服務,所有內容都在同一個文件中。
但后來我注意到,部署的 linting 警告不會出現,但如果我從文件中刪除服務和卷聲明,而不管部署,它就會出現。
所以我認為 linting 代碼沒有考慮每個文件有許多對象定義的可能性。
謝謝!
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.