⎈ k8s knowledge compiler

Assign Extended Resources to a Container [page]deterministic

tasks

This page shows how to assign extended resources to a Container.

##

Before you do this exercise, do the exercise in [Advertise Extended Resources for a Node](/docs/tasks/administer-cluster/extended-resource-node/). That will configure one of your Nodes to advertise a dongle resource.

## Assign an extended resource to a Pod

To request an extended resource, include the `resources.requests.<resource_name>` field in the container manifest. `*.kubernetes.io/`. Valid extended resource names have the form `example.com/foo` where `example.com` is replaced with your organization's domain and `foo` is a descriptive resource name.

Here is the configuration file for a Pod that has one Container:

In the configuration file, you can see that the Container requests 3 dongles.

Create a Pod:

```shell kubectl apply -f https://k8s.io/examples/pods/resource/extended-resource-pod.yaml ```

Verify that the Pod is running:

```shell kubectl get pod extended-resource-demo ```

Describe the Pod:

```shell kubectl describe pod extended-resource-demo ```

The output shows dongle requests:

```yaml Limits: example.com/dongle: 3 Requests: example.com/dongle: 3 ```

## Attempt to create a second Pod

Here is the configuration file for a Pod that has one Container. The Container requests two dongles.

Kubernetes will not be able to satisfy the request for two dongles, because the first Pod used three of the four available dongles.

Attempt to create a Pod:

```shell kubectl apply -f https://k8s.io/examples/pods/resource/extended-resource-pod-2.yaml ```

Describe the Pod

```shell kubectl describe pod extended-resource-demo-2 ```

The output shows that the Pod cannot be scheduled, because there is no Node that has 2 dongles available:

``` Conditions: Type Status PodScheduled False ... Events: ... ... Warning FailedScheduling pod (extended-resource-demo-2) failed to fit in any node fit failure summary on nodes : Insufficient example.com/dongle (1) ```

View the Pod status:

```shell kubectl get pod extended-resource-demo-2 ```

The output shows that the Pod was created, but not scheduled to run on a Node. It has a status of Pending:

```yaml NAME READY STATUS RESTARTS AGE extended-resource-demo-2 0/1 Pending 0 6m ```

## Clean up

Delete the Pods that you created for this exercise:

```shell kubectl delete pod extended-resource-demo kubectl delete pod extended-resource-demo-2 ```

##

### For application developers

* [Assign Memory Resources to Containers and Pods](/docs/tasks/configure-pod-container/assign-memory-resource/) * [Assign CPU Resources to Containers and Pods](/docs/tasks/configure-pod-container/assign-cpu-resource/)

### For cluster administrators

* [Advertise Extended Resources for a Node](/docs/tasks/administer-cluster/extended-resource-node/)

Sources

tasks/configure-pod-container/extended-resource.md · docAssign Extended Resources to a Container

Related (8)

part_of {{% heading "prerequisites" %}}describes conf=1
part_of Assign an extended resource to a Poddescribes conf=1
part_of Attempt to create a second Poddescribes conf=1
part_of Clean updescribes conf=1
part_of {{% heading "whatsnext" %}}describes conf=1
part_of For application developersdescribes conf=1
part_of For cluster administratorsdescribes conf=1
api_for Containerdocuments API object conf=1

← all Docs