Usage Example

Restrictions

Generating an etcd Security Certificate

The master and slave Coordinator nodes depend on the etcd distributed lock function, which involves communication between different pods in the cluster. You are advised to use the CA certificate for two-way authentication. To configure the certificate, refer to the following steps:

If the CA certificate is not used for two-way authentication and encrypted communication, services will be transmitted in plaintext, and high network security risks may exist.

  1. You need to prepare the pre-processing files required for generating a certificate. The following uses the /home/{User name}/auto_gen_ms_cert directory as an example.

    • server.cnf
      [req] # Main request content
      req_extensions = v3_req
      distinguished_name = req_distinguished_name
      
      [req_distinguished_name] # Certificate body information
      countryName = CN
      stateOrProvinceName = State
      localityName = City
      organizationName = Organization
      organizationalUnitName = Unit
      commonName = etcd-server
      
      [v3_req] # Core attributes
      basicConstraints = CA:FALSE
      keyUsage = digitalSignature, keyEncipherment
      extendedKeyUsage = serverAuth, clientAuth
      subjectAltName = @alt_names
      
      [alt_names] # Service ID
      DNS.1 = etcd
      DNS.2 = etcd.default
      DNS.3 = etcd.default.svc
      DNS.4 = etcd.default.svc.cluster.local
      DNS.5 = etcd-0.etcd
      DNS.6 = etcd-0.etcd.default.svc.cluster.local
      DNS.7 = etcd-1.etcd
      DNS.8 = etcd-1.etcd.default.svc.cluster.local
      DNS.9 = etcd-2.etcd
      DNS.10 = etcd-2.etcd.default.svc.cluster.local
    • client.cnf
      [req] # Main request content
      req_extensions = v3_req
      distinguished_name = req_distinguished_name
      
      [req_distinguished_name] # Certificate body information
      countryName = CN
      stateOrProvinceName = State
      localityName = City
      organizationName = Organization
      organizationalUnitName = Unit
      commonName = etcd-client
      
      [v3_req] # Core attributes
      basicConstraints = CA:FALSE
      keyUsage = digitalSignature, keyEncipherment
      extendedKeyUsage = clientAuth
      subjectAltName = @alt_names
      
      [alt_names] # Service ID
      DNS.1 = mindie-service-controller
      DNS.2 = mindie-service-coordinator
    • crl.conf
      # OpenSSL configuration for CRL generation
      #
      ####################################################################
      [ ca ] # CA framework declaration, indicating the predefined CA configuration block used by OpenSSL as the default setting
      default_ca = CA_default # The default ca section
      ####################################################################
      [ CA_default ] # Core CA settings, including all key paths, files, and default operations
      dir             = {dir}  # Add the root directory definition.
      database        = $dir/index.txt
      crlnumber       = $dir/pulp_crl_number
      new_certs_dir   = $dir/newcerts
      certificate     = $dir/ca.pem
      private_key     = $dir/ca.key
      serial          = $dir/serial
      database = /home/{User name}/auto_gen_ms_cert/etcdca4/index.txt
      crlnumber = /home/{User name}/auto_gen_ms_cert/etcdca4/pulp_crl_number
      
      
      default_days = 365 # how long to certify for
      default_crl_days= 365 # how long before next CRL
      default_md = default # use public key default MD
      preserve = no # keep passed DN ordering
      
      ####################################################################
      [ crl_ext ] # CRL extension attributes
      # CRL extensions.
      # Only issuerAltName and authorityKeyIdentifier make any sense in a CRL.
      # issuerAltName=issuer:copy
      authorityKeyIdentifier=keyid:always,issuer:always

      It is recommended that the {dir} path in the file be a shared directory that can be accessed by each node.

    • gen_etcd_ca.sh
      ```bash
      #!/bin/bash
      # 1. Create required files and directories.
      mkdir -p /home/{User name}/auto_gen_ms_cert/etcdca4/newcerts
      touch /home/{User name}/auto_gen_ms_cert/etcdca4/index.txt
      echo 1000 > /home/{User name}/auto_gen_ms_cert/etcdca4/pulp_crl_number
      echo "01" > /home/{User name}/auto_gen_ms_cert/etcdca4/serial
      
      # 2. Set permissions.
      chmod 700 /home/{User name}/auto_gen_ms_cert/etcdca4/newcerts
      chmod 600 /home/{User name}/auto_gen_ms_cert/etcdca4/{index.txt,pulp_crl_number,serial}
      
      # 3. Create a CA certificate.
      openssl genrsa -out ca.key 2048
      openssl req -x509 -new -nodes -key ca.key \
      -subj "/CN=my-cluster-ca" \
      -days 3650 -out ca.pem
      
      # 4. Generate a server certificate.
      openssl genrsa -out server.key 2048
      openssl req -new -key server.key -out server.csr \
      -subj "/CN=etcd-server" -config server.cnf
      openssl x509 -req -in server.csr -CA ca.pem -CAkey ca.key -CAcreateserial \
      -out server.pem -days 3650 -extensions v3_req -extfile server.cnf
      
      # 5. Generate a CRL.
      openssl ca -passin pass:{Password} -revoke server.pem -keyfile ca.key -cert ca.pem -config crl.conf
      openssl ca -passin pass:{Password}  -gencrl -keyfile ca.key -cert ca.pem -out server_crl.pem -config crl.conf
      
      # 6. Generate a client certificate.
      openssl genrsa -out client.key 2048
      openssl req -new -key client.key -out client.csr \
      -subj "/CN=etcd-client" -config client.cnf
      openssl x509 -req -in client.csr -CA ca.pem -CAkey ca.key -CAcreateserial \
      -out client.pem -days 3650 -extensions v3_req -extfile client.cnf
      
      # 7. Encrypt the public key (using KMC).
      # The kmc_encrypt encryption tool is used as an example. Configure {Password} as required.
      kmc_encrypt -in client.key -out client.key.enc -key_id {Password}
      
      # 8. Set permissions.
      chmod 0400 ./*.key
      chmod 0400 ./*.pem

  2. Create the files and directories required by crl.conf.

    touch index.txt
    touch pulp_crl_number
    mkdir newcerts

  3. Run gen_etcd_ca.sh using the following command to generate files such as the server certificate, client certificate, and CRL.

    bash gen_etcd_ca.sh

    If information similar to the following is displayed, the generation is successful:

    Generating RSA private key, 2048 bit long modulus (2 primes)
    .................+++++
    ............................................................................................................................................................................................................................................................................................................................................................................................................+++++
    e is 65537 (0x010001)
    Generating RSA private key, 2048 bit long modulus (2 primes)
    ..............................................+++++
    ...................................+++++
    e is 65537 (0x010001)
    Signature ok
    subject=CN = etcd-server
    Getting CA Private Key
    Using configuration from crl.conf
    Adding Entry with serial number 3D619FEFB51EEA23F8707008E3C8FACFC8D45547 to DB for /CN=etcd-server
    Revoking Certificate 3D619FEFB51EEA23F8707008E3C8FACFC8D45547.
    Data Base Updated
    Using configuration from crl.conf
    Generating RSA private key, 2048 bit long modulus (2 primes)
    .........................................................+++++
    ...........+++++
    e is 65537 (0x010001)
    Signature ok
    subject=CN = etcd-client
    Getting CA Private Key

    After the command is successfully executed, the following files or directories are generated in the current directory.

    ca.key
    ca.pem
    ca.srl
    client.cnf
    client.csr
    client_encrypted.key
    client.key
    client.pem
    crl.conf
    gen_etcd_ca.sh
    index.txt
    index.txt.attr
    index.txt.attr.old
    index.txt.old
    key_pwd.txt
    newcerts
    pulp_crl_number
    pulp_crl_number.old
    serial
    server.cnf
    server_crl.pem
    server.csr
    server.key
    server.pem

Deploying the etcd Server

  1. Run the following command to load the etcd image.

    docker pull quay.io/coreos/etcd:v3.6.0-rc.4
    • If the docker pull command fails to be executed, run the podman command to download the etcd image, save it, and run the docker load command to import it. The commands are as follows:
      apt install podman
      podman pull quay.io/coreos/etcd:v3.6.0-rc.4
    • You need to load the image on three nodes.

  2. Create etcd resources in the cluster.

    1. Run the following command to create the local-pvs.yaml file:
      vim local-pvs.yaml

      Write the following information to the file:

      # Create a PV in local-pvs.yaml.
      apiVersion: v1
      kind: PersistentVolume
      metadata:
        name: etcd-data-0  # The value must comply with the PVC naming rule of the StatefulSet.
      spec:
        capacity:
          storage: 4096M
        volumeMode: Filesystem
        accessModes: [ReadWriteOnce]
        persistentVolumeReclaimPolicy: Retain
        storageClassName: local-storage  # The value must match storageClass of the PVC.
        local:
          path: /mnt/data/etcd-0  # Actual path on the node.
        nodeAffinity:
          required:
            nodeSelectorTerms:
              - matchExpressions:
                  - key: kubernetes.io/hostname
                    operator: In
                    values: ["ubuntu"]  # Bound to a specific node.
      
      ---
      apiVersion: v1
      kind: PersistentVolume
      metadata:
        name: etcd-data-1
      spec:
        capacity:
          storage: 4096M
        accessModes: [ReadWriteOnce]
        persistentVolumeReclaimPolicy: Retain
        storageClassName: local-storage
        local:
          path: /mnt/data/etcd-1
        nodeAffinity:
          required:
            nodeSelectorTerms:
              - matchExpressions:
                  - key: kubernetes.io/hostname
                    operator: In
                    values: ["worker-80-39"]
      
      ---
      apiVersion: v1
      kind: PersistentVolume
      metadata:
        name: etcd-data-2
      spec:
        capacity:
          storage: 4096M
        accessModes: [ReadWriteOnce]
        persistentVolumeReclaimPolicy: Retain
        storageClassName: local-storage
        local:
          path: /mnt/data/etcd-2
        nodeAffinity:
          required:
            nodeSelectorTerms:
              - matchExpressions:
                  - key: kubernetes.io/hostname
                    operator: In
                    values: ["worker-153"]

      Key parameters are as follows:

      • path: path of the corresponding node, which must exist.
      • values: name of the node to be deployed.
    2. Run the following command on the master node of the K8s cluster:
      kubectl apply -f  local-pvs.yaml

      If the following information is displayed, the creation is successful:

      persistentvolume/etcd data-0 created
      persistentvolume/etcd-data-1 created
      persistentvolume/etcd-data-2 created
    3. Run the following command to label the three nodes with app=etcd:
      kubectl label nodes <Node name > app=etcd
    4. Run the following command to create the etcd.yaml file and configure the etcd certificate on the pod side:
      vim etcd.yaml

      Mount the file generation path to the etcd container based on related certificate files generated in 3, configure the etcd to use encrypted communication, and specify ca.pem, server.pem, and server.key for communication. The key configuration information is as follows in bold:

      # Create a synchronized etcd database on the three nodes in the etcd.yaml file.
      ---
      apiVersion: v1
      kind: Service
      metadata:
        name: etcd
        namespace: default
      spec:
        type: ClusterIP
        clusterIP: None # Headless Service, which is used for DNS resolution of StatefulSet.
        selector:
          app: etcd  # Select the pods labeled with app=etcd.
        publishNotReadyAddresses: true  # Allow the DNS to discover the pod that is not ready.
        ports:
          - name: etcd-client
            port: 2379 # Client communication port.
          - name: etcd-server
            port: 2380 # Inter-node communication port
          - name: etcd-metrics
            port: 8080 # etcd cluster management and control port
      ---
      apiVersion: apps/v1
      kind: StatefulSet
      metadata:
        name: etcd
        namespace: default
      spec:
        serviceName: etcd # Bind Headless Service.
        replicas: 3 # The number of nodes must be an odd number to ensure Raft.
        podManagementPolicy: OrderedReady # Parallel startup is allowed (requiring cooperation with the initialization script).
        updateStrategy:
          type: RollingUpdate # Rolling update policy
        selector:
          matchLabels:
            app: etcd # Match the pod label.
        template:
          metadata:
            labels:
              app: etcd # Pod label
            annotations:
              serviceName: etcd
          spec:
            affinity:
              podAntiAffinity:
                requiredDuringSchedulingIgnoredDuringExecution:
                  - labelSelector:
                      matchExpressions:
                        - key: app
                          operator: In
                          values: [etcd]
                    topologyKey: "kubernetes.io/hostname" # Cross-node deployment
            containers:
              - name: etcd
                image: k8s.gcr.io/etcd:3.4.13-0
                imagePullPolicy: IfNotPresent
                ports:
                  - name: etcd-client
                    containerPort: 2379
                  - name: etcd-server
                    containerPort: 2380
                  - name: etcd-metrics
                    containerPort: 8080
      #          readinessProbe:
      #            httpGet:
      #              path: /readyz
      #              port: 8080
      #            initialDelaySeconds: 10
      #            periodSeconds: 5
      #            timeoutSeconds: 5
      #            successThreshold: 1
      #            failureThreshold: 30
      #          livenessProbe:
      #            httpGet:
      #              path: /livez
      #              port: 8080
      #            initialDelaySeconds: 15
      #            periodSeconds: 10
      #            timeoutSeconds: 5
      #            failureThreshold: 3
                env:
                  - name: MY_POD_IP
                    valueFrom:
                      fieldRef:
                        fieldPath: status.podIP
                  - name: K8S_NAMESPACE
                    valueFrom:
                      fieldRef:
                        fieldPath: metadata.namespace
                  - name: HOSTNAME
                    valueFrom:
                      fieldRef:
                        fieldPath: metadata.name
                  - name: SERVICE_NAME
                    valueFrom:
                      fieldRef:
                        fieldPath: metadata.annotations['serviceName']
                  - name: ETCDCTL_ENDPOINTS
                    value: "$(HOSTNAME).$(SERVICE_NAME):2379"
                  - name: URI_SCHEME
                    value: "https"
                command:
                  - /usr/local/bin/etcd
                args:
                  - --log-level=debug
                  - --name=$(HOSTNAME) # Unique node ID
                  - --data-dir=/data # Data storage path
                  - --wal-dir=/data/wal
                  - --listen-peer-urls=https://$(MY_POD_IP):2380 # Monitor inter-node communication.
                  - --listen-client-urls=https://$(MY_POD_IP):2379 # Monitor client requests.
                  - --advertise-client-urls=https://$(HOSTNAME).$(SERVICE_NAME):2379  # Client address
                  - --initial-cluster-state=new # Initialization mode of the new cluster
                  - --initial-cluster-token=etcd-$(K8S_NAMESPACE) # Unique ID of the cluster
                  - --initial-cluster=etcd-0=https://etcd-0.etcd:2380,etcd-1=https://etcd-1.etcd:2380,etcd-2=https://etcd-2.etcd:2380 # Initial node list
                  - --initial-advertise-peer-urls=https://$(HOSTNAME).$(SERVICE_NAME):2380 # Public IP address for inter-node communication
                  - --listen-metrics-urls=http://$(MY_POD_IP):8080 # IP address for cluster management and control
                  - --quota-backend-bytes=8589934592
                  - --auto-compaction-retention=5m
                  - --auto-compaction-mode=revision
                  - --client-cert-auth
                  - --cert-file=/etc/ssl/certs/etcdca/server.pem
                  - --key-file=/etc/ssl/certs/etcdca/server.key
                  - --trusted-ca-file=/etc/ssl/certs/etcdca/ca.pem
                  - --peer-client-cert-auth
                  - --peer-trusted-ca-file=/etc/ssl/certs/etcdca/ca.pem
                  - --peer-cert-file=/etc/ssl/certs/etcdca/server.pem
                  - --peer-key-file=/etc/ssl/certs/etcdca/server.key
                volumeMounts:
                  - name: etcd-data
                    mountPath: /data # Mount persistent storage.
                  - name: etcd-ca
                    mountPath: /etc/ssl/certs/etcdca # Container path to which the /home/{User name}/auto_gen_ms_cert directory on the physical machine is mounted
            volumes:
              - name: crt
                hostPath:
                  path: /usr/local/Ascend/driver
              - name: etcd-ca
                hostPath:
                  path: /home/{User name}/auto_gen_ms_cert # Path for creating and generating files on the physical machine
                  type: Directory
        volumeClaimTemplates:
          - metadata:
              name: etcd-data
            spec:
              accessModes: [ "ReadWriteOnce" ] # Read and write on a single node.
              storageClassName: local-storage
              resources:
                requests:
                  storage: 4096M # Storage space
    5. Run the following command on the master node of the K8s cluster:
      kubectl apply -f etcd.yaml

      If the following information is displayed, the creation is successful:

      service/etcd created
      statefulset.apps/etcd created
    6. Run the following command to query pods of the etcd cluster:
      kubectl get pod -A

      The command output is similar to the following:

      NAMESPACE	NAME	READY	STATUS	  RESTARTS	AGE	IP 	          NODE	          NOMINATED NODE	  READINESS GATES
      default         etcd-0	1/1	Running	  0	        44h	xxx.xxx.xxx.xxx   ubuntu          <none>	          <none>
      default         etcd-1	1/1     Running	  0	        44h	xxx.xxx.xxx.xxx   worker-153      <none>                  <none>
      default         etcd-2  1/1     Running	  0             44h	xxx.xxx.xxx.xxx   worker-80-39    <none>                  <none>

      To modify the YAML file in the etcd cluster and re-create etcd resources, run the following command to delete the resources:

      kubectl delete -f etcd.yaml && kubectl delete pvc --all && kubectl delete pv etcd-data-0 etcd-data-1 etcd-data-2

Configuring the K8s Management End

When a hardware fault (for example, machine restart) occurs, the K8s cluster cannot quickly detect the container pod status. As a result, the inference service cannot be restored within the specified time. You can perform the following steps to speed up service restoration.

If the impact duration of a hardware fault is not required, skip the following steps.

  1. Run the following command to query the heartbeat timeout flag threshold (node-monitor-grace-period) of the K8s management node. If the command output is empty, the default value is used.

    kubectl describe pod <kube-controller-manager-pod name> -n kube-system | grep "node-monitor-grace-period"

  2. Run the following command to open and modify the heartbeat timeout flag threshold (node-monitor-grace-period) of the configured node. Generally, the configuration file is stored in the /etc/kubernetes/manifests/kube-controller-manager.yaml directory on the control plane node (on which the kube-controller-manager is running).

    vi /etc/kubernetes/manifests/kube-controller-manager.yaml
    The modified content is as follows:
    apiVersion: v1
    kind: Pod
    metadata:
      name: kube-controller-manager-<Control plane node name >  # For example, kube-controller-manager-node-97-10
      namespace: kube-system
    spec:
      containers:
      - command:
        - kube-controller-manager
        # Other original parameters... (Retain the original values.)
        - --kubeconfig=/etc/kubernetes/controller-manager.conf
        - --authentication-kubeconfig=/etc/kubernetes/controller-manager.conf
        # Add or modify the node-monitor-grace-period parameter (change the value to 20s).
        - --node-monitor-grace-period=20s
        # Other original parameters...

  3. Press Esc. Type :wq! and press Enter to save the changes and exit.
  4. Restart the node where kube-controller-manager is running.
  5. Run the following command to check whether the parameters take effect:

    kubectl describe pod <kube-controller-manager-pod name> -n kube-system | grep "node-monitor-grace-period"

    If the following information is printed, the parameters have taken effect:

    --node-monitor-grace-period=20s

Configuring and Starting the MindIE

  1. Configure certificates on the Coordinator.

    To enable CA certificate authentication, perform the following: Based on related certificate files generated in 3, mount the file generation path to the Coordinator container, that is, modify the deployment/coordinator_init.yaml file.

    apiVersion: mindxdl.gitee.com/v1
    kind: AscendJob
    metadata:
      name: mindie-ms-coordinator       # 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-coordinator      # 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 the Coordinator replicas
          restartPolicy: Always
          template:
            metadata:
              labels:
                #ring-controller.atlas: ascend-910b
                app: mindie-ms-coordinator
                jobID: xxxx      # Name of the inference job, which is user-defined and appended. The default value is mindie.
            spec:                #  The value must be the same as the previous one.
    #          nodeSelector:
                #accelerator: huawei-Ascend910
                # 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
                    timeoutSeconds: 4
                  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: COORDINATOR_LOG_CONFIG_PATH
                      value: /root/mindie
                  envFrom:
                    - configMapRef:
                        name: common-env
                  command: [ "/bin/bash", "-c", "
                          /mnt/configmap/boot.sh; \n
                      " ]
                  resources:
                    requests:
                      memory: "4Gi"
                      cpu: "16"
                    limits:
                      memory: "8Gi"
                      cpu: "64"
                  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: mindie-ms-coordinator-config
                      mountPath: /mnt/configmap/ms_coordinator.json
                      subPath: ms_coordinator.json
                    - name: localtime
                      mountPath: /etc/localtime
                    - name: mnt
                      mountPath: /mnt
                    - name: coredump
                      mountPath: /var/coredump
    		- name: coordinator-ca
    		  mountPath: /etc/ssl/certs/etcdca # Container path to which the /home/{User name}/auto_gen_ms_cert directory on the physical machine is mounted
              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: mindie-ms-coordinator-config
                  configMap:
                    name: mindie-ms-coordinator-config
                    defaultMode: 0640
                - name: mnt
                  hostPath:
                    path: /mnt
                - name: coredump
                  hostPath:
                    path: /var/coredump
                    type: DirectoryOrCreate
    	    - name: coordinator-ca
                  hostPath:
                    path: /home/{User name}/auto_gen_ms_cert # Path for creating and generating files on the physical machine
                    type: Directory
    ---
    apiVersion: v1
    kind: Service
    metadata:
      labels:
        app: mindie-ms-coordinator
        jobID: xxxx                     # Name of the inference job, which is user-defined and appended. The default value is mindie-ms.
      name: mindie-ms-coordinator-infer
      namespace: mindie
    spec:
      ports:
        - nodePort: 31015
          port: 1025
          protocol: TCP
          targetPort: 1025
      selector:
        app: mindie-ms-coordinator
      sessionAffinity: None
      type: NodePort
    status:
      loadBalancer: {}

  2. Configure the user_config.json file.

    • Change the value of tls_enable to true to make the CA authentication process take effect.
    • Configure the KMC encryption tool, that is, configure the kmc_ksf_master and kmc_ksf_standby parameters.
    • Configure the certificates related to infer_tls_items and management_tls_items. For details, see Function Description.
    • Change the value of etcd_server_tls_enable to true and configure the generated client certificate in etcd_server_tls_items.
    {
      "version": "v1.0",
      "deploy_config": {
        "p_instances_num": 1,
        "d_instances_num": 1,
        "single_p_instance_pod_num": 2,
        "single_d_instance_pod_num": 8,
        "p_pod_npu_num": 8,
        "d_pod_npu_num": 8,
        "prefill_distribute_enable": 0,
        "decode_distribute_enable": 1,
        "image_name": "mindie:dev-2.0.RC1.B091-800I-A2-py311-ubuntu22.04-aarch64",
        "job_id": "mindie",
        "hardware_type": "800I_A2",
        "mindie_env_path": "./conf/mindie_env.json",
        "mindie_host_log_path": "/root/log/ascend_log",
        "mindie_container_log_path": "/root/mindie",
        "weight_mount_path": "/mnt/mindie_data/deepseek_diff_level/deepseek_r1_w8a8_ep_level2",
        "coordinator_backup_cfg": {
          "function_enable": true
        },
        "controller_backup_cfg": {
          "function_sw": false
        },
    
        "tls_config": {
          "tls_enable": true,
          "kmc_ksf_master": "/etc/ssl/certs/etcdca/tools/pmt/master/ksfa",
          "kmc_ksf_standby": "/etc/ssl/certs/etcdca/tools/pmt/standby/ksfb",
          "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": ""
          },
          "management_tls_items": {
            "ca_cert": "./security/management/security/certs/management_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": ""
          },
          "cluster_tls_enable": true,
          "cluster_tls_items": {
            "ca_cert": "./security/clusterd/security/certs/ca.pem",
            "tls_cert": "./security/clusterd/security/certs/cert.pem",
            "tls_key": "./security/clusterd/security/keys/cert.key.pem",
            "tls_passwd": "./security/clusterd/security/pass/key_pwd.txt",
            "tls_crl": ""
          },
          "etcd_server_tls_enable": true,
          "etcd_server_tls_items": {
            "ca_cert" : "/etc/ssl/certs/etcdca/ca.pem",
            "tls_cert": "/etc/ssl/certs/etcdca/client.pem",
            "tls_key": "/etc/ssl/certs/etcdca/client.key.enc",
            "tls_passwd": "/etc/ssl/certs/etcdca/key_pwd.txt",
            "kmc_ksf_master": "/etc/ssl/certs/etcdca/tools/pmt/master/ksfa",
            "kmc_ksf_standby": "/etc/ssl/certs/etcdca/tools/pmt/standby/ksfb",
            "tls_crl": "/etc/ssl/certs/etcdca/server_crl.pem"
          }
        }
      },
    ...
    }

  3. In the user_config.json configuration file, configure the following parameters to allow two Coordinator nodes to be deployed:

    ...
            "coordinator_backup_cfg": {
              "function_enable": true
            },
    ...
    • false: disabled
    • true: enabled

  4. Run the following command to start MindIE:

    1
    python deploy_ac_job.py
    

    You can check the logs of the corresponding node to identify whether it is a master or slave node. If "[TryRenewLease]Renewed lease" is displayed in the logs, the node has acquired the etcd distributed lock and is functioning as the master node.

  5. Send a request to check whether the service is started successfully.

    Use either of the following methods to send a request:

    • Virtual IP address and port number of the Coordinator: https://PodIP:1025. (Only the pod whose READY is 1 can execute the inference request.)
    • IP address of any physical machine in the K8s cluster: 31015. (The port number must be the same as the value of service nodePort in the coordinator.yaml file.)
    In this example, the IP address and port number of the physical machine are used.
    #!/bin/bash
    url="https://{IP address of the physical machine}:31015/infer"
    data='{
        "inputs": "My name is Olivier and I",
        "stream": true,
        "parameters": {
            "max_new_tokens": 10
        }
    }'
    curl -i -L -H "Content-Type: application/json" -X POST --data "$data"  -w '%{http_code}\n'  \
            --cert   /home/ras/public/clusterD-ca/client.pem   \
            --key /home/ras/public/clusterD-ca/client.key.pem \
            --cacert /home/ras/public/clusterD-ca/ca.pem \
            --pass 1234qwer \
            $url

    If the following information is displayed, the service is started successfully:

    HTTPS/1.1 200 OK
    Server: MindIE-MS
    Content-Type: text/event-stream; charset=utf-8
    Transfer-Encoding: chunked
    data: {"prefill_time":470,"decode_time":null,"token":{"id":4571,"text":"'m"}}
    data: {"prefill_time":null,"decode_time":102,"token":{"id":260,"text":" a"}}
    data: {"prefill_time":null,"decode_time":46,"token":{"id":223,"text":" "}}
    data: {"prefill_time":null,"decode_time":23,"token":{"id":1737,"text":"25 years"}}
    data: {"prefill_time":null,"decode_time":23,"token":{"id":9916,"text":" old boy"}}
    data: {"prefill_time":null,"decode_time":23,"token":{"id":30609,"text":" from Switzerland"}}
    data: {"prefill_time":null,"decode_time":23,"generated_text":"'m a 25 years old boy from Switzerland.","details":null,"token":{"id":16,"text":null}}
    200