To avoid modifying your application YAML files, ECI provides the eci-profile feature. An eci-profile is a cluster-level ConfigMap that allows you to define rules with selectors to automatically schedule pods to ECI and inject specific configurations. This topic describes how to configure an eci-profile.
How it works
When you use ECI in an ACK cluster via the Virtual Kubelet (VK), which is deployed as the ack-virtual-node add-on, you may encounter the following issues:
-
Application teams must modify YAML files to schedule pods to ECI.
-
Application teams must modify YAML files to enable ECI-specific advanced features.
These issues blur the boundary between platform operations and application management. To address this, ECI provides the eci-profile feature, which offers the following three capabilities:
-
ECI Scheduler
In hybrid clusters that use both ECI and regular nodes, you can schedule pods to ECI by configuring pod labels, namespace labels, or ECI elastic scheduling. However, these methods require changes to existing resources and are not truly zero-touch.
To solve this, the ECI Scheduler introduces a new scheduling mechanism based on a mutating webhook. In the
eci-profile, you can define custom selectors that filter pods based on their labels or the labels of their namespace. Pods that match the selector criteria are automatically scheduled to ECI. -
ECI Effect
Some ECI features, such as specifying an ECS instance type, enabling an image cache, or configuring an NTP service, require you to add annotations or labels to pods. For more information, see ECI Pod Annotation.
The ECI Effect automates this process by injecting annotations and labels. In an
eci-profile, you can define a selector that specifies both the matching criteria and the annotations and labels to inject. Pods that match the selector are automatically scheduled to ECI, and the specified annotations and labels are injected. -
Hot updates
The
eci-profileincludes settings such as ClusterIP, hybrid cloud mode, log collection, and vSwitches. You can update these settings as needed.-
You do not need to restart VK when you update the configuration.
-
The updated configuration takes effect immediately for new ECI pods. For existing ECI pods, you must perform a rolling update to apply the changes.
-
Prerequisites
-
Ensure that the VK (ack-virtual-node add-on) in your cluster is updated to the latest version. For more information about how to upgrade components, see Manage components.
-
To use the ECI Scheduler feature, you must enable webhooks. Pods in an ACK Serverless cluster are scheduled to ECI by default and do not require the ECI Scheduler feature.
Configuration
When a pod is created, the system uses the configuration in the data field of the eci-profile ConfigMap in the kube-system namespace to create the pod. You can view the YAML file of the eci-profile by running the kubectl get cm -n kube-system eci-profile -o yaml command. The following is a template of the eci-profile YAML file:
apiVersion: v1
data:
enableClusterIp: "true"
enableHybridMode: "false"
enableLinuxArm64Node: "false"
enableLogController: "false"
enablePVCController: "false"
enablePrivateZone: "false"
enableReuseSSLKey: "false"
featureGates: "WaitForFirstConsumer=false"
securityGroupId: sg-2zeeyaaxlkq9sppl****
selectors: ""
slsMachineGroup: ""
vSwitchIds: vsw-2ze23nqzig8inprou****,vsw-2ze94pjtfuj9vaymf****
vpcId: vpc-2zeghwzptn5zii0w7****
kind: ConfigMap
metadata:
creationTimestamp: "2023-01-11T08:28:14Z"
name: eci-profile
namespace: kube-system
resourceVersion: "356"
uid: b345fa8c-919e-41fc-a981-57864b1a****
You can modify the data configuration in the eci-profile to configure selectors or update cluster-level parameters.
|
Parameter |
Description |
Details |
|
selectors |
Defines custom selectors ( |
|
|
Cluster-level parameters other than |
These are cluster-level parameters that support hot updates. You can update their values as needed. |
You can modify the eci-profile in one of the following ways:
-
Use the
kubectl editcommand:kubectl edit configmap eci-profile -n kube-system -
Use the ACK console:
-
Log on to the ACK console.
-
On the Clusters page, find the target cluster and click its name.
-
In the left-side navigation pane, choose Configurations > ConfigMaps.
-
Select kube-system from the Namespace drop-down list.
-
Find
eci-profileand click Edit YAML.
-
Configure selectors
The selectors field defines the configurations for ECI Scheduler and ECI Effect. When a pod is created, the system evaluates the selectors against the pod. If the pod labels match, the pod is automatically scheduled to ECI, and annotations or labels are injected to enable ECI features.
The selectors field can contain multiple selectors. In each selector, you must declare a name and can optionally include the following fields:
-
namespaceSelector: the namespace labels to match. -
objectSelector: the pod labels to match. -
effect: the annotations and labels to dynamically inject.
The following is a template for the selectors configuration:
Design the selectors based on your workload requirements. Remove the comments from the configuration before you apply it.
data:
selectors: |
[
{
"name": "selector-demo1", # Selector name. Required. Cannot be empty.
"namespaceSelector": { # Match by namespace labels. Optional.
"matchLabels": { # Namespace labels to match. Multiple labels use AND logic.
"eci": "true"
}
},
"objectSelector": { # Match by pod labels. Optional.
"matchLabels": { # Pod labels to match. Multiple labels use AND logic.
"eci": "true"
}
},
"effect": { # Annotations and labels to inject. Optional.
"annotations": {
"k8s.aliyun.com/eci-use-specs": "ecs.c6.xlarge"
},
"labels": {
"created-by-eci": "true"
}
}
},
{
"name": "selector-demo2",
"objectSelector": {
"matchLabels": {
"eci": "test"
}
}
}
]
In the preceding template, the selector named selector-demo1 implements the following logic:
If a pod belongs to a namespace with the eci: true label and the pod itself has the eci: true label, the pod is automatically scheduled to ECI. The system also adds the annotation "k8s.aliyun.com/eci-use-specs": "ecs.c6.xlarge" and the label created-by-eci: true to the pod.
-
In a selector, configure at least one of
namespaceSelectororobjectSelector. If both are configured, a pod must match both. If neither is configured buteffectis, the effect applies to all pods scheduled to ECI. -
If you configure multiple selectors, the system evaluates them in order. After a match, the system injects the annotations and labels defined in
effectwithout overwriting existing values. For duplicate annotations and labels, the values defined on the pod take the highest priority, followed by theeffectfrom the first-matched selector, and so on.
After you configure the selectors, run the following command to verify the configuration. If the returned YAML includes your selectors, the configuration is successful. If not, check whether the selector format is correct.
kubectl get mutatingwebhookconfigurations -o yaml vk-webhook
Example 1: Schedule specific pods
This example configures namespaceSelector and objectSelector for the following behavior:
If a pod has the created-by-eci: true label and belongs to a namespace with the type: eci label, the pod is scheduled to ECI.
data:
selectors: |
[
{
"name":"eci-selector",
"namespaceSelector":{
"matchLabels":{
"type":"eci"
}
},
"objectSelector":{
"matchLabels":{
"created-by-eci":"true"
}
}
}
]
Example 2: Use GPU instances
This example configures namespaceSelector and effect for the following behavior:
If a pod belongs to a namespace with the gpu: true label, the pod is scheduled to ECI. The system uses the specified GPU-accelerated ECS instance type ecs.gn6v-c8g1.2xlarge and adds the gpu: test label.
data:
selectors: |
[
{
"name":"gpu-namespace-selector",
"namespaceSelector":{
"matchLabels":{
"gpu":"true"
}
},
"effect": {
"annotations": {
"k8s.aliyun.com/eci-use-specs":"ecs.gn6v-c8g1.2xlarge"
},
"labels":{
"gpu":"test"
}
}
}
]
Example 3: Enable automatic image cache
This example configures objectSelector and effect for the following behavior:
If a pod has the imc: auto label, the pod is scheduled to ECI and the automatic image cache matching feature is enabled.
data:
selectors: |
[
{
"name":"autoimc-object-selector",
"objectSelector":{
"matchLabels":{
"imc":"auto"
}
},
"effect": {
"annotations": {
"k8s.aliyun.com/eci-auto-imc": "true"
}
}
}
]
Update cluster parameters
Cluster-level parameters in the data field, such as vpcId and vSwitchIds, define the VPC and vSwitch settings. You can update these parameters as needed. Updates take effect immediately without requiring a VK restart. The following parameters are supported:
When you create an ECI pod, the system uses these values unless they are overridden in the pod's specification.
|
Parameter |
Example |
Description |
|
enableClusterIp |
"true" |
Specifies whether to support ClusterIP. |
|
enableLinuxArm64Node |
"false" |
Specifies whether to enable ARM-based nodes. For more information, see Schedule pods to ARM-based virtual nodes. |
|
enableLogController |
"false" |
Specifies whether to enable log collection based on the Log Service CRD. If you set this parameter to
|
|
enablePVCController |
"false" |
Specifies whether to enable online disk expansion. If set to |
|
enablePrivateZone |
"false" |
Specifies whether to use PrivateZone for DNS resolution. |
|
enableReuseSSLKey |
"false" |
Specifies whether to enable SSL key reuse. If set to Important
By default, when you create ECI pods, VK issues a different SSL certificate to each ECI pod, reducing creation efficiency at scale. If you enable SSL key reuse, VK issues the same SSL certificate to all ECI pods. This improves efficiency but reduces security. |
|
securityGroupId |
sg-2ze0b9o8pjjzts4h**** |
The ID of the security group to which the ECI pods belong. |
|
slsMachineGroup |
"test-mg" |
The machine group to which the ECI pods belong. This parameter is required when |
|
vSwitchIds |
vsw-2zeet2ksvw7f14ryz**** |
The IDs of the vSwitches to which the ECI pods belong. You can specify multiple IDs, separated by commas. |
|
vpcId |
vpc-2zeghwzptn5zii0w7**** |
The ID of the VPC to which the ECI pods belong. |
The following is an example configuration:
data:
enableClusterIp: "true"
enableHybridMode: "false"
enableLinuxArm64Node: "false"
enableLogController: "false"
enablePVCController: "false"
enablePrivateZone: "false"
enableReuseSSLKey: "false"
securityGroupId: sg-2zeeyaaxlkq9sppl****
selectors: ""
slsMachineGroup: ""
vSwitchIds: vsw-2ze23nqzig8inprou****,vsw-2ze94pjtfuj9vaymf****
vpcId: vpc-2zeghwzptn5zii0w7****