本页展示了如何给容器分配非透明整型资源。
Kubernetes v1.13
feature-state-alpha.txt
You need to have a Kubernetes cluster, and the kubectl command-line tool must be configured to communicate with your cluster. If you do not already have a cluster, you can create one by using Minikube, or you can use one of these Kubernetes playgrounds:
To check the version, enter kubectl version
.
在做这个练习之前,请在给节点配置非透明整型资源文档中进行练习, 该文档介绍了在一个节点上配置dongle资源。
为了请求一个非透明整型资源,需要在容器配置文件中包含resources:requests
字段。
非透明整型资源类型前缀是pod.alpha.kubernetes.io/opaque-int-resource-
。
下面是含有一个容器的Pod的配置文件:
oir-pod.yaml docs/tasks/configure-pod-container
|
---|
|
在配置文件中,可以看到容器请求了3个dongles资源。
创建Pod:
kubectl create -f https://k8s.io/docs/tasks/configure-pod-container/oir-pod.yaml
验证Pod是否正在运行:
kubectl get pod oir-demo
查询Pod的状态:
kubectl describe pod oir-demo
输出显示了dongle请求:
Requests:
pod.alpha.kubernetes.io/opaque-int-resource-dongle: 3
下面是含有一个容器的Pod的配置文件。该容器请求了两个dongles资源。
oir-pod-2.yaml docs/tasks/configure-pod-container
|
---|
|
Kubernetes无法再满足两个dongles的请求,因为第一个Pod已经使用了四个可用dongles中的三个。
尝试创建Pod:
kubectl create -f https://k8s.io/docs/tasks/configure-pod-container/oir-pod-2.yaml
查询Pod的状态
kubectl describe pod oir-demo-2
输出显示该Pod无法被调度,因为没有节点有两个可用的dongles资源:
Conditions:
Type Status
PodScheduled False
...
Events:
...
... Warning FailedScheduling pod (oir-demo-2) failed to fit in any node
fit failure summary on nodes : Insufficient pod.alpha.kubernetes.io/opaque-int-resource-dongle (1)
查看Pod的状态:
kubectl get pod oir-demo-2
输出显示Pod已创建,但是没有被调度并运行在节点上。 它的状态为Pending:
NAME READY STATUS RESTARTS AGE
oir-demo-2 0/1 Pending 0 6m
删除本练习中创建的Pod:
kubectl delete pod oir-demo
此页是否对您有帮助?
Thanks for the feedback. If you have a specific, answerable question about how to use Kubernetes, ask it on Stack Overflow. Open an issue in the GitHub repo if you want to report a problem or suggest an improvement.