如何解决 Kubernetes 部署警告?
How to resolve Kubernetes Deployment warning?
$ kubectl version --short
Client Version: v1.20.2
Server Version: v1.19.6-eks-49a6c0
我有以下部署清单
apiVersion: apps/v1
kind: Deployment
metadata:
name: stats-service
namespace: my-system
labels:
app: stats-service
spec:
selector:
matchLabels:
app: stats-service
template:
metadata:
labels:
app: stats-service
spec:
containers:
- name: stats-service
image: 0123456789.dkr.ecr.us-east-1.amazonaws.com/stats-service:3.12.1
resources:
requests:
memory: "1024m"
cpu: "512m"
limits:
memory: "2048m"
cpu: "1024m"
ports:
- name: http
containerPort: 5000
protocol: TCP
startupProbe:
httpGet:
path: /manage/health
port: 5000
failureThreshold: 30
periodSeconds: 10
livenessProbe:
httpGet:
path: /manage/health
port: 5000
failureThreshold: 3
periodSeconds: 10
readinessProbe:
httpGet:
path: /manage/health
port: 5000
failureThreshold: 6
periodSeconds: 10
env:
- name: SPRING_PROFILES_ACTIVE
value: test
- name: JAVA_OPTS
value: "my_java_opts"
当我应用它时,我收到以下警告,并且 Pod 从未创建。这是什么意思,如何解决?就我而言,我是 运行 和 EKS Fargate(仅)集群。谢谢!
$ kubectl describe pod stats-service-797784dfd5-tvh84
...
Warning FailedCreatePodSandBox 12s kubelet Failed to create pod sandbox: rpc error: code = Unknown desc = failed to create containerd task: OCI runtime create failed: container_linux.go:349: starting container process caused "process_linux.go:319: getting the final child's pid from pipe caused \"read init-p: connection reset by peer\"": unknown
备注:
- 似乎警告与
spec.template.spec.containers.resources.limits
块有关。如果我删除它,就会创建 Pod。
- 我在网上看到的很多解决方案都说要重置Docker,这显然不适用于我。
您对资源使用了错误的符号。根据 Meaning of memory:
Limits and requests for memory are measured in bytes. You can express
memory as a plain integer or as a fixed-point number using one of
these suffixes: E, P, T, G, M, K. You can also use the power-of-two
equivalents: Ei, Pi, Ti, Gi, Mi, Ki.
如果你愿意,
- 要求:
- 1GB 内存
- 0.5 vCPU/Core
- 限制:
- 2GB 内存
- 1 vCPU/Core
这应该有效:
resources:
requests:
memory: "1G"
cpu: "0.5"
limits:
memory: "2G"
cpu: "1"
以下是等效的,但使用不同的符号:
resources:
requests:
memory: "1024M"
cpu: "500m"
limits:
memory: "2048M"
cpu: "1000m"
请注意,上面的示例使用 M
作为内存,而不是 m
。
$ kubectl version --short
Client Version: v1.20.2
Server Version: v1.19.6-eks-49a6c0
我有以下部署清单
apiVersion: apps/v1
kind: Deployment
metadata:
name: stats-service
namespace: my-system
labels:
app: stats-service
spec:
selector:
matchLabels:
app: stats-service
template:
metadata:
labels:
app: stats-service
spec:
containers:
- name: stats-service
image: 0123456789.dkr.ecr.us-east-1.amazonaws.com/stats-service:3.12.1
resources:
requests:
memory: "1024m"
cpu: "512m"
limits:
memory: "2048m"
cpu: "1024m"
ports:
- name: http
containerPort: 5000
protocol: TCP
startupProbe:
httpGet:
path: /manage/health
port: 5000
failureThreshold: 30
periodSeconds: 10
livenessProbe:
httpGet:
path: /manage/health
port: 5000
failureThreshold: 3
periodSeconds: 10
readinessProbe:
httpGet:
path: /manage/health
port: 5000
failureThreshold: 6
periodSeconds: 10
env:
- name: SPRING_PROFILES_ACTIVE
value: test
- name: JAVA_OPTS
value: "my_java_opts"
当我应用它时,我收到以下警告,并且 Pod 从未创建。这是什么意思,如何解决?就我而言,我是 运行 和 EKS Fargate(仅)集群。谢谢!
$ kubectl describe pod stats-service-797784dfd5-tvh84
...
Warning FailedCreatePodSandBox 12s kubelet Failed to create pod sandbox: rpc error: code = Unknown desc = failed to create containerd task: OCI runtime create failed: container_linux.go:349: starting container process caused "process_linux.go:319: getting the final child's pid from pipe caused \"read init-p: connection reset by peer\"": unknown
备注:
- 似乎警告与
spec.template.spec.containers.resources.limits
块有关。如果我删除它,就会创建 Pod。 - 我在网上看到的很多解决方案都说要重置Docker,这显然不适用于我。
您对资源使用了错误的符号。根据 Meaning of memory:
Limits and requests for memory are measured in bytes. You can express memory as a plain integer or as a fixed-point number using one of these suffixes: E, P, T, G, M, K. You can also use the power-of-two equivalents: Ei, Pi, Ti, Gi, Mi, Ki.
如果你愿意,
- 要求:
- 1GB 内存
- 0.5 vCPU/Core
- 限制:
- 2GB 内存
- 1 vCPU/Core
这应该有效:
resources:
requests:
memory: "1G"
cpu: "0.5"
limits:
memory: "2G"
cpu: "1"
以下是等效的,但使用不同的符号:
resources:
requests:
memory: "1024M"
cpu: "500m"
limits:
memory: "2048M"
cpu: "1000m"
请注意,上面的示例使用 M
作为内存,而不是 m
。