Configure eci-profile
Elastic Container Instance (ECI) supports the eci-profile feature, which reduces the changes required in business YAML. eci-profile provides a cluster-level view of ECI resources and orchestrates pods based on selectors, so pods are scheduled to ECI without per-pod YAML edits.
Features
When Container Service for Kubernetes (ACK) uses ECI through Virtual Kubelet (VK) by deploying the ack-virtual-node add-on, you may encounter the following issues:
-
Business application YAML must be edited to schedule pods to ECI.
-
Business application YAML must be edited to enable advanced ECI-specific features.
These issues mix operations management with business management. To resolve such issues, ECI supports eci-profile. eci-profile provides the following three features:
-
ECI Scheduler
When ECI and regular nodes are used together, pods are generally scheduled to ECI by using methods such as configuring pod labels, namespace labels, or ECI elastic scheduling. However, all these methods require changes to existing resources and cannot achieve zero intrusion.
For these situations, ECI Scheduler implements a new scheduling mechanism based on the Mutating Webhook mechanism. In eci-profile, a custom selector filters pods based on pod labels or the labels of the namespace to which a pod belongs. Pods that meet the filter conditions of the selector are automatically scheduled to ECI.
-
ECI Effect
Some ECI features, such as specifying an Elastic Compute Service (ECS) instance type, enabling image cache, and configuring an NTP service, must be implemented by adding annotations or labels to pods. For more information, see ECI pod annotations.
For these situations, ECI Effect automatically adds annotations and labels. In eci-profile, a custom selector specifies both the filter conditions and the annotations and labels to add. Pods that meet the filter conditions of the selector are automatically scheduled to ECI, and the specified annotations and labels are automatically added.
-
Hot configuration update
eci-profile contains configurations such as Cluster IP, hybrid cloud mode, log collection, and vSwitches. These configurations can be updated when needed.
-
VK does not need to be restarted when you update the configurations.
-
For newly created ECI-based pods, the updated configurations take effect immediately. For existing ECI-based pods, the updated configurations take effect only after a rolling release.
-
Considerations
-
When you use this feature, make sure that the VK (ack-virtual-node add-on) in your cluster is the latest version. For information about how to upgrade an add-on, see Components.
-
To use the ECI Scheduler feature, enable Webhook. ACK Serverless cluster schedules pods to ECI by default and does not require the ECI Scheduler feature.
Configuration notes
When a pod is created, the system reads the eci-profile configuration file (the ConfigMap named eci-profile) in the kube-system namespace and creates the pod based on its data configuration. Run the kubectl get cm -n kube-system eci-profile -o yaml command to view the YAML of eci-profile. The YAML template of eci-profile is as follows:
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****
To configure selectors or update fixed configuration items, modify the data configuration in eci-profile.
|
Configuration items in data |
Description |
Detailed description and examples |
|
selectors |
Add custom selectors (objectSelector and namespaceSelector) and effects to implement the ECI Scheduler and ECI Effect features. |
|
|
Fixed configuration items other than selectors, such as vpcId and vSwitchIds |
Cluster-level configuration items that support hot updates. |
Modify eci-profile in the following ways:
-
By using the kubectl edit command
kubectl edit configmap eci-profile -n kube-system -
By using the Container Service console
-
Log on to the Container Service console .
-
On the Clusters page, find the target cluster and click the name of the cluster.
-
In the left-side navigation pane of the cluster management page, choose Configurations > ConfigMaps.
-
Set the namespace to kube-system.
-
Find eci-profile and click Edit YAML.
-
Configure selectors
selectors contain the configurations of ECI Scheduler and ECI Effect. When a pod is created, the system matches pods against the selectors. A pod whose labels match is automatically scheduled to ECI, or the specified annotations and labels are added to it so that ECI features take effect.
selectors can contain multiple selectors. Each selector must declare a selector name, and the following information is optional:
-
namespaceSelector: the namespace labels to match.
-
objectSelector: the pod labels to match.
-
effect: the annotations and labels to dynamically add.
The configuration template of selectors is as follows:
Design selectors based on your business requirements. When you configure selectors in practice, remove the comments.
data:
selectors: |
[
{
"name": "selector-demo1", #selector name, required, cannot be empty
"namespaceSelector": { #Filter by namespace label, optional
"matchLabels": { #The namespace labels to match. If you specify multiple labels, they have an AND relationship.
"eci": "true"
}
},
"objectSelector": { #Filter by pod label, optional
"matchLabels": { #The pod labels to match. If you specify multiple labels, they have an AND relationship.
"eci": "true"
}
},
"effect": { #The annotations and labels to dynamically add, 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 features:
If the namespace to which a pod belongs contains the eci: true label and the pod itself contains the eci: true label, the pod is automatically scheduled to ECI. The "k8s.aliyun.com/eci-use-specs": "ecs.c6.xlarge" annotation and the created-by-eci: true label are added.
-
Configure at least one of namespaceSelector and objectSelector in each selector (recommended). If you configure both, a pod must match both. If you configure neither but configure effect, effect applies to all pods that are scheduled to ECI.
-
If you configure multiple selectors, the selectors are matched in order. After a successful match, the annotations and labels declared in effect are automatically added to the pod (added only, not overwritten). For duplicate annotations and labels, the value originally declared in the pod has the highest priority, followed by the effect of the first selector matched in order, and so on.
After you configure selectors, verify whether the selectors have taken effect. If the returned YAML contains the configured selectors, the configuration is successful. If the selectors are not included, check whether the format of the selectors is incorrect.
kubectl get mutatingwebhookconfigurations -o yaml vk-webhook
Configuration example 1: Schedule specific pods to ECI
Configure namespaceSelector and objectSelector to implement the following features:
If a pod contains the created-by-eci: true label and the namespace to which the pod belongs contains 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"
}
}
}
]
Configuration example 2: Schedule specific pods to ECI and create them with a GPU instance type
Configure namespaceSelector and effect to implement the following features:
If the namespace to which a pod belongs contains the gpu: true label, the pod is scheduled to ECI and created with the specified GPU instance type ecs.gn6v-c8g1.2xlarge. The gpu: test label is added.
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"
}
}
}
]
Configuration example 3: Schedule specific pods to ECI and enable automatic image cache matching
Configure objectSelector and effect to implement the following features:
If a pod contains the imc: auto label, the pod is scheduled to ECI and uses the automatic image cache matching feature.
data:
selectors: |
[
{
"name":"autoimc-object-selector",
"objectSelector":{
"matchLabels":{
"imc":"auto"
}
},
"effect": {
"annotations": {
"k8s.aliyun.com/eci-auto-imc": "true"
}
}
}
]
Update fixed configuration items
The fixed configuration items in data, such as vpcId and vSwitchIds, correspond to information such as the VPC and vSwitches. You can update these items when needed, and the updated configurations take effect immediately (without restarting VK). The configuration items that can be updated are as follows:
The following configuration items are all cluster-level configuration items. That is, when an ECI-based pod is created, the configurations in eci-profile are used if no additional configuration is specified.
|
Configuration item |
Example value |
Description |
|
enableClusterIp |
"true" |
Specifies whether Cluster IP is supported. |
|
enableLinuxArm64Node |
"false" |
Specifies whether to enable ARM nodes. For more information, see Schedule pods to an ARM-based virtual node. |
|
enableLogController |
"false" |
Specifies whether to enable the Simple Log Service (SLS) custom resource definition (CRD) log collection feature. If this configuration item is set to true, you must also configure slsMachineGroup. |
|
enablePVCController |
"false" |
Specifies whether to enable the online disk expansion feature. If this configuration item is set to true, online expansion is allowed for persistent volume claims (PVCs) that are bound to cloud disks. |
|
enablePrivateZone |
"false" |
Specifies whether to use PrivateZone for DNS resolution. |
|
enableReuseSSLKey |
"false" |
Specifies whether to enable SSL key reuse. If this configuration item is set to true, SSL keys are reused when ECI-based pods are created to improve creation efficiency. Important
By default, when an ECI-based pod is created, VK issues a different SSL certificate to each ECI-based pod, which affects efficiency during large-scale creation. After SSL key reuse is enabled, VK issues the same SSL certificate to each ECI-based pod, which reduces security to some extent. |
|
securityGroupId |
sg-2ze0b9o8pjjzts4h**** |
The security group to which the ECI-based pod belongs. |
|
slsMachineGroup |
"test-mg" |
The machine group to which the ECI-based pod belongs. You must configure this configuration item when enableLogController is set to true. |
|
vSwitchIds |
vsw-2zeet2ksvw7f14ryz**** |
The vSwitches to which the ECI-based pods belong. Separate multiple vSwitch IDs with commas (,). |
|
vpcId |
vpc-2zeghwzptn5zii0w7**** |
The VPC to which the ECI-based pod belongs. |
The configuration example is as follows:
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****