Commit 3f3e8a73 authored by Kubernetes Submit Queue's avatar Kubernetes Submit Queue Committed by GitHub

Merge pull request #51929 from ConnorDoyle/cpu-manager-examples

Automatic merge from submit-queue (batch tested with PRs 51929, 52015, 51906, 52069, 51542). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>.. Add example pods to demonstrate CPU manager. **What this PR does / why we need it**: Adds example pods and README for the CPU manager static policy which is a new feature in Kubernetes v1.8. **Release note**: ```release-note NONE ```
parents 4acacc6e 00f0e0f6
approvers:
- derekwaynecarr
- vishh
- ConnorDoyle
- sjenning
- balajismaniam
# CPU Manager Example
This example flow uses a pre-built docker image based on
[cpuset-visualizer](https://github.com/ConnorDoyle/cpuset-visualizer).
Each container run here hosts an endpoint serving an up-to-the-second
system representation generated by
[`lstopo`](https://www.open-mpi.org/projects/hwloc).
## Setup
1. Start a local cluster with the static CPU manager policy enabled :
```
sudo PATH=$PATH \
KUBELET_FLAGS="\
--feature-gates=CPUManager=true \
--cpu-manager-policy=static \
--cpu-manager-reconcile-period=5s \
--kube-reserved=cpu=500m" \
./hack/local-up-cluster.sh
```
## Run pods
The example pods are in the `/examples/cpu-manager` directory of the
Kubernetes source tree. Your ability to run all of the example pods
simultaneously depends on how many CPUs are available on the test system.
The required CPUs for each example pod are listed below:
```
POD | CPUs
------------------|---------
be.yaml | >= 1 CPU
shared.yaml | >= 1 CPU
exclusive-1.yaml | >= 2 CPU
exclusive-2.yaml | >= 3 CPU
exclusive-3.yaml | >= 4 CPU
exclusive-4.yaml | >= 5 CPU
```
### Example
Run a pod with a single container in the shared pool, and another pod
with a single container in an exclusive cpuset with one CPU.
```
$ kubectl create -f examples/cpu-manager/shared.yaml
$ kubectl create -f examples/cpu-manager/exclusive-1.yaml
```
To list IP addresses of the pods running in the local cluster, do:
```
$ watch ./examples/cpu-manager/pod-ips
exclusive-1 http://172.17.0.4
shared http://172.17.0.3
```
#### Sample cpuset-visualizer output
![Sample cpuset-visualizer output](https://user-images.githubusercontent.com/379372/28648573-974693ce-7223-11e7-84ed-17cce11910ff.png)
apiVersion: v1
kind: Pod
metadata:
name: be
spec:
containers:
- image: quay.io/connordoyle/cpuset-visualizer
name: be
apiVersion: v1
kind: Pod
metadata:
name: exclusive-1
spec:
containers:
- image: quay.io/connordoyle/cpuset-visualizer
name: exclusive-1
resources:
requests:
cpu: 1
memory: "256M"
limits:
cpu: 1
memory: "256M"
apiVersion: v1
kind: Pod
metadata:
name: exclusive-2
spec:
containers:
- image: quay.io/connordoyle/cpuset-visualizer
name: exclusive-2
resources:
requests:
cpu: 2
memory: "256M"
limits:
cpu: 2
memory: "256M"
apiVersion: v1
kind: Pod
metadata:
name: exclusive-3
spec:
containers:
- image: quay.io/connordoyle/cpuset-visualizer
name: exclusive-3
resources:
requests:
cpu: 3
memory: "256M"
limits:
cpu: 3
memory: "256M"
apiVersion: v1
kind: Pod
metadata:
name: exclusive-4
spec:
containers:
- image: quay.io/connordoyle/cpuset-visualizer
name: exclusive-4
resources:
requests:
cpu: 4
memory: "256M"
limits:
cpu: 4
memory: "256M"
#!/bin/bash
# Copyright 2017 The Kubernetes Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Requires `jq`. See https://stedolan.github.io/jq/download
set -o nounset -o pipefail -o errexit
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
KUBECTL="$DIR/../../cluster/kubectl.sh"
export KUBECONFIG="${KUBECONFIG:-/var/run/kubernetes/admin.kubeconfig}"
$KUBECTL get pods -o json | \
jq -r '.items[] | "\(.metadata.name) http://\(.status.podIP)"'
apiVersion: v1
kind: Pod
metadata:
name: shared
spec:
containers:
- image: quay.io/connordoyle/cpuset-visualizer
name: shared
resources:
requests:
cpu: 100m
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment