Advanced configuration

Updated at:

When you create an application service, you can enable advanced configuration for the pod template to optimize performance and increase flexibility. This topic describes the advanced configuration settings for pod templates.

hostNetwork configuration

Note

When you use hostNetwork, mount a maximum of one pod to a node to avoid port listener conflicts.

In some scenarios, you may need to change the pod network from the container network to the host network. This can help resolve network connectivity issues.

If you use hostNetwork for network configuration, the pod IP address is the same as the node IP address after the application service is published.

Environment variables

You can configure environment variables for a pod as key-value pairs. This adds environment flags or passes configurations to the pod. The variables are passed to the application process when the container starts. For example: USER=tester. For more information, see Pod variable.

The following table describes the parameters.

Parameter name

Description

Source

The source of the environment variable configuration. Valid values:

  • Manual Input: Manually specify the name and value of the environment variable.

  • Configuration Item: Select a configured ConfigMap to specify the value of the environment variable.

  • Secret: Select a configured Secret to specify the value of the environment variable.

Variable name

The name of the environment variable.

Note

The name must consist of letters, digits, underscores (_), hyphens (-), or periods (.), and cannot start with a digit.

Variable value/Variable reference

Configure a value or reference based on the selected source.

  • If you select Manual Input, enter the value of the environment variable.

  • If you select Configuration Item or Secret, enter the reference to the ConfigMap or Secret.

Volume configuration

You can configure the volumes that the container uses. Currently, you can only mount directories from the host where the container resides.

The following table describes the parameters.

Parameter Name

Description

Type

The supported types are:

  • Local storage

  • Configuration item

  • Secret

  • PVC template

  • PVC

For more information, see Volumes.

Permission

Supports Read/Write and Read-only.

Container directory

The path of the volume in the container.

Host directory/Configuration item reference/PVC name

Set the corresponding host directory or configuration item reference based on the selected volume type.

  • If you select Local storage, enter the directory on the host where the pod resides.

  • If you select Configuration item, select the corresponding configuration item from the drop-down list.

  • If you select Secret, select the corresponding secret from the drop-down list.

  • If you select PVC template, select the corresponding PVC template from the drop-down list.

    Note

    If no PVC template is configured, you can configure one when you create or edit the application service. For more information, see Volume template configuration.

  • If you select PVC, select the corresponding PVC from the drop-down list.

subPath/subPathExpr

Enter the subPath or subPathExpr name to specify a subpath within the referenced volume instead of its root. After the configuration is complete, existing files in the container directory are not overwritten.

Health check configuration

A health check periodically checks the health of a container based on your configuration while the container is running. If you do not configure a health check, the container cannot detect business exceptions and will not automatically restart to recover the service. This may affect normal business operations.

Two check mechanisms are available: Readiness Probe and Liveness Probe. For more information, see Kubernetes Probe.

Note
  • Readiness Probe: Checks if the container is ready to accept traffic.

    • If the check fails, the cluster blocks requests to the container.

    • If the check succeeds, access to the container is enabled.

  • Liveness Probe: Checks if the container is running normally. If the check fails, the cluster restarts the container.

The following table describes the parameters for Readiness Probes and Liveness Probes.

Parameter name

Description

Check method

  • TCP Socket port: Sends a TCP request. The check passes if a connection is successfully established.

  • HTTP Get method: Sends an HTTP GET request. The check passes if the returned status code is greater than or equal to 200 and less than 400.

  • Execute command in container: Executes a command in the container. The check passes if the command is successfully executed and returns 0.

Run a command

Required when Check method is set to HTTP Get method or Execute command in container.

  • If you select HTTP Get method, specify the command for the HTTP request.

  • If you select Execute command in container, specify the command to execute in the container.

Access port

Required when Check method is set to TCP Socket port or HTTP Get method.

  • If you select TCP Socket port, enter the container port for TCP access.

  • If you select HTTP Get method, enter the container port for the HTTP request.

Initial Check Delay

initialDelaySeconds. The number of seconds to wait after the container starts before the first probe is executed. The default value is 3 seconds.

Timeout

timeoutSeconds. The probe timeout period. The default value is 1 second. The minimum value is 1 second.

Health Check Interval

periodSeconds. The interval at which the probe is executed. The default value is 10 seconds. The minimum value is 1 second.

Healthy Threshold

The minimum number of consecutive successful probes required to consider the container healthy after a failure. The default value is 1. The minimum value is 1.

Unhealthy Threshold

The minimum number of consecutive failed probes required to consider the container unhealthy after a success. The default value is 3. The minimum value is 1.

Lifecycle event callback configuration

You can add lifecycle event callbacks for the container. The callbacks are executed after the container starts and before it stops.

The following table describes the parameters for Post Start and Pre Stop.

Parameter

Description

Callback method

Supports Execute command in container and HTTP GET method.

Access path

Required when Callback method is set to HTTP Get method.

Enter the access path, such as /healthy/readiness.

Access port

Required when Callback method is set to HTTP Get method.

Enter an access port from 1 to 65535.

Execute Command

Required when Callback method is set to Execute command in container.

Enter the command to execute, such as cat tmp/healthy.

Simple Log Service configuration

You can configure Simple Log Service. You can select an existing Logstore or create a new one.

Note

The first time you use the Simple Log Service configuration feature, go to the Simple Log Service console to enable and configure indexes. For more information, see Configure indexes.

The following table describes the parameters.

Parameter name

Description

Logstore

A Logstore is created in Simple Log Service to store the collected logs.

Select an existing Logstore. If no Logstore is available, click Create Logstore to create one.

Log type

Container text log.

Path

Collects logs from a specified path in the container. For example: /home/admin/*.log or /root/*.log.