Updated on 2023-01-13 GMT+08:00

Creating an Agent DaemonSet Workload

After you create a ConfigMap, deploy the database audit agent and configure database information in the agent DaemonSet. Your database can then be connected to the database audit instance.

Creating an Agent DaemonSet

  1. In the navigation pane, choose Workloads > DaemonSets. Click Create DaemonSet.
  2. Configure basic information about the workload For more information, see Table 1.

    Table 1 Workload parameters

    Parameter

    Description

    Example Value

    Workload Name

    Name of a workload, which must be unique

    agent-docker

    Cluster Name

    Cluster connected to the database to be audited

    scc-cmv-bj4

    Namespace

    Namespace of the cluster connected to the database to be audited

    default

  3. Click Next: Add Container. Click Add Container. In the dialog box that is displayed, click the Open source Images tab. Search for centos, and click OK.
  4. Set CentOS image parameters.

    1. Click the Basic Information tab. Select the image centos7.6.1810 and retain the default values for other parameters.

      If the centos7.5.1804 image is not supported in your region, perform the operations in Changing an Image.

    2. Click the Lifecycle tab and set the commands used when the container is started or running. Configure the following parameters and retain the default values for other parameters.
      • Start Command: command executed when a container is started
        • Command: top
        • Args: -b
      • Post-Start: command executed while a container is up and running
        • Args: CLI
        • Command:

          /bin/bash

          -c

          tar xvf /tmp/dbss/agent/dbss_agent.tar.gz -C /opt;/opt/dbss_agent/install.sh;rm -rf /opt/dbss_agent

    3. Click the Data Storage tab and mount extra volumes to the container.
      1. Click the Local Volume tab and click Add Local Volume. In the dialog box that is displayed, set the following parameters and retain the default values for other parameters.
        • Set Type to ConfigMap.
        • Set ConfigMap to the one created in Creating a ConfigMap.
        • Set Container Path for the ConfigMap (for example, /tmp/dbss/db).
      2. Click OK.
      3. Click the Cloud Volume tab and click Add Cloud Volume. In the dialog box that is displayed, set the following parameters and retain the default values for other parameters.
        • Set Type to OBS.
        • Set Allocation Mode to Manual.
        • Set Name to the PVC of the OBS bucket created in Importing Configurations to OBS.
        • Set Container Path for the storage (for example, /tmp/dbss/agent).
      4. Click OK.

        If your database configurations changed, you need to add a new cloud volume and remove the old one.

        To add a cloud volume, click a workload and click the Upgrade tab. Click Advanced Settings, Data Storage, and Cloud Volume. Click Add Cloud Volume.

  5. Keep the access settings and advanced settings as they are. Click Next: Set Application Access, Next: Configure Advanced Settings, and Create.
  6. Choose Workloads > DaemonSets. In the Operation column of the new DaemonSet, choose More > Edit YAML.
  7. In the Edit YAML dialog box, add hostNetwork: true under the spec.template.spec field.

    Figure 1 Editing a YAML file

  8. Click Edit.
  9. Check the DaemonSet workload status.

    If the workload is in the Running state, it has been successfully created.

  10. Wait for 2 to 3 minutes. After the deployment succeeded, return to the DBSS console. Check the agent status.

    In the agent list of a database, if the value of General is Yes and Status is Running, the agent has been connected to the database audit instance.

Changing an Image

If the centos7.5.1804 image is not supported in your region, perform the following steps to change to this image:

  1. Configure the image name.

    1. You are advised to do this in a new browser window: On the management console, choose Containers > SoftWare Repository for Container.
    2. In the navigation pane, choose Image Resources > Image Center.
    3. Click Image Accelerator. In the displayed Image Accelerator dialog box, copy the accelerator address. Remove https:// from the address, and add /library/centos:centos7.5.1804 to the end of the address.

      Example: 7b01ab6xxxxfb06b2.mirror.swr.myhuaweicloud.com/library/centos:centos7.5.1804

  2. Change the image.

    1. Go back to the page for setting CentOS image parameters.
    2. Click Change Image. In the Select Container Image dialog box, click the Third-Party Images tab.
    3. Enter an image name.
    4. Click OK.