我要评分
获取效率
正确性
完整性
易理解

Installing the MPAM Plugin

To install the MPAM plugin, obtain its source code and create an image file, mount the MPAM feature to the physical machine, and run the plugin. Unless otherwise specified, the following operations are performed on the master node.

  1. Obtain the source code.
    git clone --branch v1.00-RC2 https://gitee.com/kunpeng_compute/kunpeng-cloud-computing.git
  2. Optional: Specify the name and version of the image file. The default version of the image file is 0.1. You can specify the name and version in the Makefile file.
    1. Open the file.
      cd kunpeng-cloud-computing/Boostkit_CloudNative/K8S/k8s-mpam-controller
      vi Makefile
    2. Press i to enter the insert mode and specify the name and version of the image file. As shown in the following figure, set the name of the image file to k8s-mpam-controller and the image version to 0.1.

    3. Press Esc to exit the insert mode. Type :wq! and press Enter to save the file and exit.
  3. Go to the MPAM plugin directory and create the image file k8s-mpam-controller:0.1.
    cd kunpeng-cloud-computing/Boostkit_CloudNative/K8S
    make docker
  4. Optional: View the created image file.
    docker images | grep k8s-mpam-controller

    An example command output is as follows:

    REPOSITORY                          TAG               IMAGE ID       CREATED         SIZE
    k8s-mpam-controller                 0.1               9f363522bbc9   42 hours ago    259MB
  5. On the physical machine of the worker node, mount the MPAM feature.
    mount -t resctrl resctrl /sys/fs/resctrl

    Set the mounting parameters properly, including caPbm, mbMax, mbMin, and mbHdl. By default, select caPbm for L3 cache and mbMax for memory bandwidth, enable mbHdl, and do not mount mbMin.

    For example, select caPbm when mounting the MPAM feature.

    mount -t resctrl resctrl /sys/fs/resctrl -o caPbm
  6. Go to the samples directory and edit the k8s-mpam-controller.yaml file.

    The k8s-mpam-controller.yaml file is used to start the MPAM plugin. In this file, a service account named mpam-controller-agent is created and is assigned the resource access permission, which allows the service account to access kube-apiserver. This file deploys the MPAM plugin as a DaemonSet on each node in the cluster to enable the MPAM feature.

    1. Open the MPAM plugin configuration file.
      cd k8s-mpam-controller-config/samples
      vi k8s-mpam-controller.yaml
    2. Press i to enter the insert mode and change image: k8s-mpam-controller:0.1 in the file to the image file name and version you set in 2. The content of k8s-mpam-controller.yaml is as follows:
       1
       2
       3
       4
       5
       6
       7
       8
       9
      10
      11
      12
      13
      14
      15
      16
      17
      18
      19
      20
      21
      22
      23
      24
      25
      26
      27
      28
      29
      30
      31
      32
      33
      34
      35
      36
      37
      38
      39
      40
      41
      42
      43
      44
      45
      46
      47
      48
      49
      50
      51
      52
      53
      54
      55
      56
      57
      58
      59
      60
      61
      62
      63
      64
      65
      66
      67
      68
      69
      70
      71
      72
      73
      74
      75
      76
      77
      78
      79
      80
      81
      82
      83
      84
      85
      86
      87
      88
      89
      90
      apiVersion: v1
      kind: ServiceAccount
      metadata:
        name: mpam-controller-agent
      ---
      apiVersion: rbac.authorization.k8s.io/v1
      kind: ClusterRole
      metadata:
        name: mpam-controller-agent
      rules:
        - apiGroups:
            - ""
          resources:
            - configmaps
            - pods
          verbs:
            - get
            - list
            - watch
        - apiGroups:
            - ""
          resources:
            - nodes
          verbs:
            - get
            - list
            - patch
            - update
            - watch
      ---
      apiVersion: rbac.authorization.k8s.io/v1
      kind: ClusterRoleBinding
      metadata:
        name: mpam-controller-agent
      roleRef:
        apiGroup: rbac.authorization.k8s.io
        kind: ClusterRole
        name: mpam-controller-agent
      subjects:
        - kind: ServiceAccount
          name: mpam-controller-agent
          namespace: default
      ---
      apiVersion: apps/v1
      kind: DaemonSet
      metadata:
        name: mpam-controller-daemonset-agent
      spec:
        selector:
          matchLabels:
            app: k8s-mpam-controller-agent
        template:
          metadata:
            labels:
              app: k8s-mpam-controller-agent
          spec:
            serviceAccountName: mpam-controller-agent
            hostPID: true
            hostIPC: true
            containers:
              - name: k8s-mpam-controller-agent
                image: k8s-mpam-controller:0.1
                imagePullPolicy: IfNotPresent
                securityContext:
                  privileged: true
                command: ["/usr/bin/agent"]
                args: ["-direct"]
                env:
                  - name: NODE_NAME
                    valueFrom:
                      fieldRef:
                        apiVersion: v1
                        fieldPath: spec.nodeName
                volumeMounts:
                  - name: resctrl
                    mountPath: /sys/fs/resctrl/
                  - name: hostname
                    mountPath: /etc/hostname
                  - name: sysfs
                    mountPath: /sys/fs/cgroup/
            volumes:
              - name: resctrl
                hostPath:
                  path: /sys/fs/resctrl/
              - name: hostname
                hostPath:
                  path: /etc/hostname
              - name: sysfs
                hostPath:
                  path: /sys/fs/cgroup/
      
    3. Press Esc to exit the insert mode. Type :wq! and press Enter to save the file and exit.
  7. Apply the k8s-mpam-controller.yaml file to run the MPAM plugin.
    kubectl apply -f k8s-mpam-controller.yaml

    After the k8s-mpam-controller.yaml file is applied, Kubernetes creates a Pod on each node to run the MPAM plugin. The number of Pods that can be created on each node decreases by one.

  8. Check whether the Pod corresponding to the MPAM plugin is running properly.
    kubectl get pods

    The following information is displayed if the Pod is running properly:

    NAME                                    READY   STATUS    RESTARTS   AGE
    mpam-controller-daemonset-agent-bj2gv   1/1     Running   0          143m
  9. View the run logs of the MPAM plugin. In this example, xxx indicates the name of the Pod corresponding to the MPAM plugin.
    kubectl logs -f xxx