Usage Example

Restrictions

You have configured the IP address and port number of the CCAE in the ms_controller.json configuration file of the Controller. If the log reporting function is required, you also need to configure the certificate information.

Generating the Certificate for Interconnecting the OM Adapter with CCAE

You can choose whether to configure a certificate to interconnect the OM Adapter with CCAE. If a certificate is required, perform the following steps to generate a certificate. If no certificate is required, log in to the CCAE by referring to 1, disable the three configuration items starting with MindIE on the certificate authentication configuration page, and connect the OM Adapter to the CCAE by referring to Configuring the Interconnection Between the OM Adapter and CCAE.

  1. Enable the CCAE certificate configuration function.

    1. On the service plane of the CCAE, choose System > System Settings > Certificate Item from the main menu, as shown in Figure 1.
      Figure 1 Configuration item management
    2. On the Certificate Configuration page, find the three configuration items starting with MindIE and select Enable in the Operation column, as shown in Figure 2.
      Figure 2 Certificate configuration

  2. Obtain the CA certificate file. The file path of the CA certificate is the path that needs to be configured for the ca_cert parameter of the ccae_tls_items field in the ms_controller.json configuration file of the Controller.

    1. On the service plane of CCAE, choose System > Security Management > Certificate Authority Service from the main menu. The CA certificate management page is displayed, as shown in Figure 3.
      Figure 3 CA certificate management
    2. Click Download CA Certificate. In the dialog box that is displayed, set File format to PEM and click Submit. A .pem file is generated, which is the CA certificate without the trust chain.
      Figure 4 Downloading a CA certificate
    3. On the service plane of the CCAE, choose System > Security Management > Certificate Management from the main menu. The Service Certificate Management page is displayed. Obtain the CA certificate trust chain, as shown in Figure 5.
      Figure 5 Certificate management
    4. Click SouthBoundService. The SouthBoundService Certificates page is displayed.
      Figure 6 SouthBoundService
    5. Click Export Trust Chain in the upper right corner to obtain a .pem file, which is the CA certificate trust chain file.
      Figure 7 Exporting the trust chain
    6. Copy the content of the CA certificate trust chain file and paste it to the end of the CA certificate file. That is, combine the content of the two files into a .pem file, which is a complete CA certificate file.

  3. Obtain the TLS certificate file and TLS private key. The file paths of the TLS certificate file and TLS private key are the paths that need to be configured for the tls_cert and tls_key parameters respectively in the ccae_tls_items field in the ms_controller.json configuration file of the Controller.

    1. On the service plane of CCAE, choose System > Security Management > Certificate Authority Service from the main menu. The Certificate Authority Service page is displayed, as shown in Figure 8.
      Figure 8 CA service
    2. Choose Certificate Application > Certificate Application from the navigation pane. On the displayed Certificate Application page, set the following parameters on the Apply by Basic Info tab page and submit the application, as shown in Figure 9.
      • Associated CA: name of the CA downloaded in 2.b.
      • Certificate profile: Select CCAGENT_ENTITY_60YEARS.
      • Common name(CN): user-defined name.
      Figure 9 Applying for a certificate
    3. In the navigation pane, choose PKI Management > Certificate. The Certificate page is displayed, as shown in Figure 10.

      Select the certificate to be downloaded and click Download. In the Download Certificate dialog box, enter the following information and click Submit.

      • File type: Select Certificate.
      • File Name: Enter a user-defined name, for example, tls_cert.
      • File format: Select PEM(.pem).
      Figure 10 Obtaining the TLS certificate file
    4. In the Download Certificate dialog box shown in 3.c, enter the following information and click Submit to download the TLS private key, as shown in Figure 11.
      • File type: Select Private key.
      • File name: user-defined, for example, tls_key.
      • File format: Select PKCS#8(.pem).
      • File password: user-defined.
      Figure 11 Obtaining the TLS private key

  4. Obtain the ciphertext data. The file path of the ciphertext data is the path that needs to be configured for the tls_passwd parameter in the ccae_tls_items field in the ms_controller.json configuration file of the Controller.

    This operation must be performed in the MindIE container. The MindIE image contains the tool for generating a ciphertext. For details, see encrypt.
    1. Run the following command to go to the directory where MindIE Service is installed:
      cd /usr/local/Ascend/mindie/latest/mindie-service
    2. Run the following command to generate a ciphertext:
      ./bin/seceasy_encrypt --encrypt 1 2
    3. Enter the password configured when obtaining the TLS private key file in 3.d based on the command output. The ciphertext is generated after encrypted:, as shown in the following:
      root@mindie-controller-master-0:/usr/local/Ascend/mindie/latest/mindie-service# ./bin/seceasy_encrypt --encrypt 1 2
      please input the password to encrypt 
      please input the password to encrypt again
      encrypted: AAAAAgAAAAAAAAABAAAQAAAl+zJLrsq6Bduk6QPIWUNIsc+DyyOnVmy2xtrh2AAAAAEAAAAEAAAAAAAAAGXqKpZ+ZKbuFdCHBZH9ZYCYOTBTbxyIlRQ=
    4. Create a .txt file and copy the ciphertext generated following encrypted: to the .txt file.

  5. After 4 is executed, a /tools folder is generated in the current directory. /tools/pmt/master/ksfa and /tools/pmt/standby/ksfb are the file paths to be configured for the kmc_ksf_master and kmc_ksf_standby parameters respectively in the ccae_tls_items field in the ms_controller.json configuration file of the Controller.
  6. Place the files or directories obtained from 2 to 5 in the same directory on the physical machine. The following uses /mnt as an example. If the directory does not exist in the environment, create it as follows:

    mkdir /mnt

Configuring the Interconnection Between the OM Adapter and CCAE

  1. In the ms_controller.json configuration file of the Controller, configure the IP address and port number of CCAE. The CCAE-related parameters are in bold as follows:

    {
      "allow_all_zero_ip_listening": false,
      "deploy_mode": "pd_separate",
      "initial_dist_server_port": 10000,
      "cluster_port":8899,
      "process_manager" : {
        "to_file": true,
        "file_path": "./logs/controller_process_status.json"
      },
      "ccae": {
        "ip": "xxx.xxx.xxx.xxx",
        "port": 31948,
        "kafka_port" : 26329
      },
      "cluster_status" : {
        "to_file": true,
        "file_path": "./logs/cluster_status_output.json"
      },
    ...
    }

  2. (Optional) Enable certificate verification and mount the certificate path to the visible container path. For details about how to generate a certificate, see Generating the Certificate for Interconnecting the OM Adapter with CCAE.

    1. Mount the certificate path to the deployment/controller_init.yaml file. The bold information in the following content indicates the mount path:
      apiVersion: mindxdl.gitee.com/v1
      kind: AscendJob
      metadata:
        name: mindie-ms-controller        # The value varies according to the job. The default value is mindie-ms.
        namespace: mindie            # MindIE is used as an example. You can change the value as required.
        labels:
          framework: pytorch
          app: mindie-ms-controller      # Fixed
          jobID: xxxx               # Name of the inference job, which is user-defined and appended. The default value is mindie-ms.
          ring-controller.atlas: ascend-910b
      spec:
        schedulerName: volcano   # work when enableGangScheduling is true
        runPolicy:
          schedulingPolicy:      # work when enableGangScheduling is true
            minAvailable: 1      # The value must be the same as that of replicas.
            queue: default
        successPolicy: AllWorkers
        replicaSpecs:
          Master:
            replicas: 1           # Number of Controller replicas
            restartPolicy: Always
            template:
              metadata:
                labels:
                  #ring-controller.atlas: ascend-910b
                  app: mindie-ms-controller
                  jobID: xxxx      # Name of the inference job, which is user-defined and appended. The default value is mindie.
              spec:                              # Retain the default value.
                affinity:
                  podAntiAffinity:
                    requiredDuringSchedulingIgnoredDuringExecution:
                      - labelSelector:
                          matchExpressions:
                            - key: app
                              operator: In
                              values:
                                - mindie-ms-controller
                        topologyKey: kubernetes.io/hostname
                nodeSelector:
                  # masterselector: dls-master-node
                  accelerator: huawei-Ascend310P
                  # machine-id: "7"
                terminationGracePeriodSeconds: 0
                automountServiceAccountToken: false
                securityContext:
                  fsGroup: 1001
                containers:
                  - image: mindie:dev-2.0.RC1-B087-800I-A2-py311-ubuntu22.04-aarch64
                    imagePullPolicy: IfNotPresent
                    name: ascend
                    securityContext:
                      # allowPrivilegeEscalation: false
                      privileged: true
                      capabilities:
                        drop: [ "ALL" ]
                      seccompProfile:
                        type: "RuntimeDefault"
                    readinessProbe:
                      exec:
                        command:
                          - bash
                          - -c
                          - "$MIES_INSTALL_PATH/scripts/http_client_ctl/probe.sh readiness"
                      periodSeconds: 5
                    livenessProbe:
                      exec:
                        command:
                          - bash
                          - -c
                          - "$MIES_INSTALL_PATH/scripts/http_client_ctl/probe.sh liveness"
                      periodSeconds: 5
                    startupProbe:
                      exec:
                        command:
                          - bash
                          - -c
                          - "$MIES_INSTALL_PATH/scripts/http_client_ctl/probe.sh startup"
                      periodSeconds: 5
                      failureThreshold: 100
                    env:
                      - name: POD_IP
                        valueFrom:
                          fieldRef:
                            fieldPath: status.podIP
                      - name: GLOBAL_RANK_TABLE_FILE_PATH
                        value: "/user/serverid/devindex/config/..data/global_ranktable.json"
                      - name: MIES_INSTALL_PATH
                        value: $(MINDIE_USER_HOME_PATH)/Ascend/mindie/latest/mindie-service
                      - name: CONFIG_FROM_CONFIGMAP_PATH
                        value: /mnt/configmap
                      - name: CONTROLLER_LOG_CONFIG_PATH
                        value: /root/mindie
                    envFrom:
                      - configMapRef:
                          name: common-env
                    command: [ "/bin/bash", "-c", "
                        /mnt/configmap/boot.sh; \n
                    " ]
                    resources:
                      requests:
                        memory: "2Gi"
                        cpu: "4"
                      limits:
                        memory: "4Gi"
                        cpu: "8"
                    volumeMounts:
                      - name: global-ranktable
                        mountPath: /user/serverid/devindex/config
                      - name: mindie-http-client-ctl-config
                        mountPath: /mnt/configmap/http_client_ctl.json
                        subPath: http_client_ctl.json
                      - name: python-script-get-group-id
                        mountPath: /mnt/configmap/get_group_id.py
                        subPath: get_group_id.py
                      - name: boot-bash-script
                        mountPath: /mnt/configmap/boot.sh
                        subPath: boot.sh
                      - name: mindie-ms-controller-config
                        mountPath: /mnt/configmap/ms_controller.json
                        subPath: ms_controller.json
                      - name: status-data
                        mountPath: /usr/local/Ascend/mindie/latest/mindie-service/logs
                      - name: localtime
                        mountPath: /etc/localtime
                      - name: mnt
                        mountPath: /mnt
                volumes:
                  - name: localtime
                    hostPath:
                      path: /etc/localtime
                  - name: global-ranktable
                    configMap:
                      name: global-ranktable
                      defaultMode: 0640
                  - name: mindie-http-client-ctl-config
                    configMap:
                      name: mindie-http-client-ctl-config
                      defaultMode: 0640
                  - name: python-script-get-group-id
                    configMap:
                      name: python-script-get-group-id
                      defaultMode: 0640
                  - name: boot-bash-script
                    configMap:
                      name: boot-bash-script
                      defaultMode: 0550
                  - name: mindie-ms-controller-config
                    configMap:
                      name: mindie-ms-controller-config
                      defaultMode: 0640
                  - name: status-data
                    hostPath:
                      path: /data/mindie-ms/status
                      type: Directory
                  - name: mnt
                    hostPath:
                      path: /mnt
    2. Configure certificate verification in the user_config.json file of the Controller component, as shown in the following information in bold:

      When configuring the CCAE certificate, set tls_enable to true or null.

      • If tls_enable is set to true, all xxx_tls_enable configuration items are set to true and will take effect.
      • If tls_enable is set to null, all configuration items that are set to true in tls_config will take effect.
      • If tls_enable is set to false, all xxx_tls_enable configuration items are set to false and will not take effect.
      ...    
            "tls_config": {
            "tls_enable": true,
            "kmc_ksf_master": "./security/master/tools/pmt/master/ksfa",
            "kmc_ksf_standby": "./security/standby/tools/pmt/standby/ksfb",
            "infer_tls_enable": true,
            "infer_tls_items": {
              "ca_cert": "./security/infer/security/certs/ca.pem",
              "tls_cert": "./security/infer/security/certs/cert.pem",
              "tls_key": "./security/infer/security/keys/cert.key.pem",
              "tls_passwd": "./security/infer/security/pass/key_pwd.txt",
              "tls_crl": "infer"
            },
            "management_tls_enable": true,
            "management_tls_items": {
              "ca_cert": "./security/management/security/certs/ca.pem",
              "tls_cert": "./security/management/security/certs/cert.pem",
              "tls_key": "./security/management/security/keys/cert.key.pem",
              "tls_passwd": "./security/management/security/pass/key_pwd.txt",
              "tls_crl": "management"
            },
            "ccae_tls_enable": true,
            "ccae_tls_items": {
              "ca_cert": "./security/ccae/security/certs/ca.pem",
              "tls_cert": "./security/ccae/security/certs/cert.pem",
              "tls_key": "./security/ccae/security/keys/cert.key.pem",
              "tls_passwd": "./security/ccae/security/pass/key_pwd.txt",
              "tls_crl": "ccae"
            },
             ...
          }
      ...

      The certificate must be placed on the physical machine node scheduled by the Controller container to ensure that the Controller container can access the certificate path. By default, the Coordinator container is randomly scheduled. You can modify the Coordinator scheduling label or place the certificate on each node to ensure that the Coordinator container can access the certificate path.

  3. Set the following environment variables to enable performance control:

    • Prefill-decode hybrid deployment: Run the following environment variable in the container. In the multi-node scenario, run the following environment variable in each container.
    • Prefill-decode disaggregation: Add the following environment variable to examples/kubernetes_deploy_scripts/boot_helper/boot.sh. You are advised to add it between #!/bin/bash and set_common_env.
    export MIES_SERVICE_MONITOR_MODE=1

    Before starting the service, ensure that the host time is consistent with the local time. Otherwise, the time corresponding to the performance data observed on the CCAE is inaccurate.

  4. Run the following command to start MindIE:

    python deploy_ac_job.py

  5. About 5 minutes after the service is started, the OM Adapter reports the heartbeat, alarm, log, and inventory information to CCAE. For details about the alarm information, see Alarm Reference.