diff --git a/_data/samples.yml b/_data/samples.yml index 52ac8d572a..3a9f0bcf28 100644 --- a/_data/samples.yml +++ b/_data/samples.yml @@ -12,6 +12,8 @@ toc: path: https://github.com/kubernetes/kubernetes/tree/release-1.3/examples/rbd/ - title: CephFS path: https://github.com/kubernetes/kubernetes/tree/release-1.3/examples/cephfs/ + - title: CockroachDB + path: https://github.com/kubernetes/kubernetes/tree/release-1.4/examples/cockroachdb/ - title: GlusterFS path: https://github.com/kubernetes/kubernetes/tree/release-1.3/examples/glusterfs/ - title: Hazelcast diff --git a/_data/tasks.yml b/_data/tasks.yml index 90c1f3b8b2..38e1a89c68 100644 --- a/_data/tasks.yml +++ b/_data/tasks.yml @@ -8,6 +8,8 @@ toc: path: /docs/tasks/configure-pod-container/define-environment-variable-container/ - title: Defining a Command and Arguments for a Container path: /docs/tasks/configure-pod-container/define-command-argument-container/ + - title: Assigning CPU and RAM Resources to a Container + path: /docs/tasks/configure-pod-container/assign-cpu-ram-container/ - title: Accessing Applications in a Cluster section: - title: Using Port Forwarding to Access Applications in a Cluster diff --git a/docs/getting-started-guides/kubeadm.md b/docs/getting-started-guides/kubeadm.md index 5848fbdc5f..69a1f1ccab 100644 --- a/docs/getting-started-guides/kubeadm.md +++ b/docs/getting-started-guides/kubeadm.md @@ -34,7 +34,7 @@ orchestration system (e.g. Puppet) that you have to integrate with. If you are not constrained, other tools build on kubeadm to give you complete clusters: * On GCE, [Google Container Engine](https://cloud.google.com/container-engine/) gives you turn-key Kubernetes -* On AWS, [kops](kops) makes installation and cluster management easy (and supports high availability) +* On AWS, [kops](https://github.com/kubernetes/kops) makes installation and cluster management easy (and supports high availability) ## Prerequisites diff --git a/docs/tasks/configure-pod-container/assign-cpu-ram-container.md b/docs/tasks/configure-pod-container/assign-cpu-ram-container.md new file mode 100644 index 0000000000..5b05afedb8 --- /dev/null +++ b/docs/tasks/configure-pod-container/assign-cpu-ram-container.md @@ -0,0 +1,104 @@ +--- +--- + +{% capture overview %} + +This page shows how assign CPU and RAM resources to containers running +in a Kubernetes Pod. + +{% endcapture %} + + +{% capture prerequisites %} + +{% include task-tutorial-prereqs.md %} + +{% endcapture %} + + +{% capture steps %} + +### Assigning CPU and RAM resources to a container + +When you create a Pod, you can request CPU and RAM resources for the containers +that run in the Pod. You can also set limits for CPU and RAM resources. To +request CPU and RAM resources, include the `resources:requests` field in the +configuration file. To set limits on CPU and RAM resources, include the +`resources:limits` field. + +Kubernetes schedules a Pod to run on a Node only if the Node has enough CPU and +RAM available to satisfy the total CPU and RAM requested by all of the +containers in the Pod. Also, as a container runs on a Node, Kubernetes doesn't +allow the CPU and RAM consumed by the container to exceed the limits you specify +for the container. If a container exceeds its RAM limit, it is terminated. If a +container exceeds its CPU limit, it becomes a candidate for having its CPU use +throttled. + +In this exercise, you create a Pod that runs one container. The configuration +file for the Pod requests 250 milicpu and 64 mebibytes of RAM. It also sets +upper limits of 1 cpu and 128 mebibytes of RAM. Here is the configuration file +for the `Pod`: + +{% include code.html language="yaml" file="cpu-ram.yaml" ghlink="/docs/tasks/configure-pod-container/cpu-ram.yaml" %} + +1. Create a Pod based on the YAML configuration file: + + export REPO=https://raw.githubusercontent.com/kubernetes/kubernetes.github.io/master + kubectl create -f $REPO/docs/tasks/configure-pod-container/cpu-ram.yaml + +1. Display information about the pod: + + kubectl describe pod cpu-ram-demo + + The output is similar to this: + + Name: cpu-ram-demo + ... + Containers: + cpu-ram-demo-container: + ... + Limits: + cpu: 1 + memory: 128Mi + Requests: + cpu: 250m + memory: 64Mi + +### Understanding CPU and RAM units + +The CPU resource is measured in *cpu*s. Fractional values are allowed. You can +use the suffix *m* to mean mili. For example 100m cpu is 100 milicpu, and is +the same as 0.1 cpu. + +The RAM resource is measured in bytes. You can express RAM as a plain integer +or a fixed-point integer with one of these suffixes: E, P, T, G, M, K, Ei, Pi, +Ti, Gi, Mi, Ki. For example, the following represent approximately the same value: + + 128974848, 129e6, 129M , 123Mi + +### If you don't specify limits or requests + +If you don't specify a RAM limit, Kubernetes places no upper bound on the +amount of RAM a Container can use. A Container could use all the RAM +available on the Node where the Container is running. Similarly, if you don't +specify a CPU limit, Kubernetes places no upper bound on CPU resources, and a +Container could use all of the CPU resources available on the Node. + +For information about why you would want to specify limits, see +[Setting Pod CPU and Memory Limits](/docs/admin/limitrange/). + +For information about what happens if you don't specify CPU and RAM requests, see +[Resource Requests and Limits of Pod and Container](/docs/user-guide/compute-resources/). + +{% endcapture %} + +{% capture whatsnext %} + +* Learn more about [managing compute resources](/docs/user-guide/compute-resources/). +* See [ResourceRequirements](/docs/api-reference/v1/definitions/#_v1_resourcerequirements). + +{% endcapture %} + + +{% include templates/task.md %} + diff --git a/docs/tasks/configure-pod-container/cpu-ram.yaml b/docs/tasks/configure-pod-container/cpu-ram.yaml new file mode 100644 index 0000000000..c45189fb1e --- /dev/null +++ b/docs/tasks/configure-pod-container/cpu-ram.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Pod +metadata: + name: cpu-ram-demo +spec: + containers: + - name: cpu-ram-demo-container + image: gcr.io/google-samples/node-hello:1.0 + resources: + requests: + memory: "64Mi" + cpu: "250m" + limits: + memory: "128Mi" + cpu: "1" diff --git a/docs/tasks/index.md b/docs/tasks/index.md index fc08a0469a..e59f8732b2 100644 --- a/docs/tasks/index.md +++ b/docs/tasks/index.md @@ -7,6 +7,7 @@ The Tasks section of the Kubernetes documentation is a work in progress * [Defining Environment Variables for a Container](/docs/tasks/configure-pod-container/define-environment-variable-container/) * [Defining a Command and Arguments for a Container](/docs/tasks/configure-pod-container/define-command-argument-container/) +* [Assigning CPU and RAM Resources to a Container](/docs/tasks/configure-pod-container/assign-cpu-ram-container/) #### Accessing Applications in a Cluster @@ -23,5 +24,4 @@ The Tasks section of the Kubernetes documentation is a work in progress ### What's next If you would like to write a task page, see -[Using Page Templates](/docs/contribute/page-templates/) -for information about the task page type and the task template. +[Creating a Documentation Pull Request](/docs/create-pull-request/).