github.com/qsunny/k8s@v0.0.0-20220101153623-e6dca256d5bf/examples-master/staging/cpu-manager/README.md (about)

     1  # CPU Manager Example
     2  
     3  This example flow uses a pre-built docker image based on
     4  [cpuset-visualizer](https://github.com/ConnorDoyle/cpuset-visualizer).
     5  Each container run here hosts an endpoint serving an up-to-the-second
     6  system representation generated by
     7  [`lstopo`](https://www.open-mpi.org/projects/hwloc).
     8  
     9  ## Setup
    10  
    11  1. Start a local cluster with the static CPU manager policy enabled :
    12  
    13     ```
    14     sudo PATH=$PATH \
    15       KUBELET_FLAGS="\
    16       --feature-gates=CPUManager=true \
    17       --cpu-manager-policy=static \
    18       --cpu-manager-reconcile-period=5s \
    19       --kube-reserved=cpu=500m" \
    20       ./hack/local-up-cluster.sh
    21     ```
    22  
    23  ## Run pods
    24  
    25  The example pods are in the `/examples/staging/cpu-manager` directory of the
    26  Kubernetes source tree. Your ability to run all of the example pods
    27  simultaneously depends on how many CPUs are available on the test system.
    28  
    29  The required CPUs for each example pod are listed below:
    30  
    31  ```
    32   POD              | CPUs
    33  ------------------|---------
    34   be.yaml          | >= 1 CPU
    35   shared.yaml      | >= 1 CPU
    36   exclusive-1.yaml | >= 2 CPU
    37   exclusive-2.yaml | >= 3 CPU
    38   exclusive-3.yaml | >= 4 CPU
    39   exclusive-4.yaml | >= 5 CPU
    40  ```
    41  
    42  ### Example
    43  
    44  Run a pod with a single container in the shared pool, and another pod
    45  with a single container in an exclusive cpuset with one CPU.
    46  
    47  ```
    48  $ kubectl create -f examples/staging/cpu-manager/shared.yaml
    49  $ kubectl create -f examples/staging/cpu-manager/exclusive-1.yaml
    50  ```
    51  
    52  To list IP addresses of the pods running in the local cluster, do:
    53  
    54  ```
    55  $ watch ./examples/staging/cpu-manager/pod-ips
    56  exclusive-1 http://172.17.0.4
    57  shared http://172.17.0.3
    58  ```
    59  
    60  #### Sample cpuset-visualizer output
    61  
    62  ![Sample cpuset-visualizer output](https://user-images.githubusercontent.com/379372/28648573-974693ce-7223-11e7-84ed-17cce11910ff.png)