Container Service for Kubernetes (ACK) add-ons extend cluster capabilities—specify them at cluster creation and manage their lifecycle afterward with Terraform.
Add-on types
ACK add-ons are either system add-ons or optional add-ons. See Add-ons.
System add-ons
System add-ons are foundational services installed by default during cluster creation.
Examples:
-
kube-apiserver
-
kube-controller-manager
-
cloud-controller-manager
-
kube-proxy
-
CoreDNS
Optional add-ons
Optional add-ons are not required but can be installed to extend cluster capabilities. They are grouped into categories including:
-
Application management
-
Logging and monitoring
-
Storage
-
Networking
-
Security
Generate Terraform configuration parameters from the console
The ACK console can automatically generate the Terraform configuration for managing cluster add-ons.
Log on to the ACK console. In the left navigation pane, click Clusters.
On the Clusters page, click the name of your cluster. In the left navigation pane, click Components and Add-ons.
-
On the Add-ons page, find the target add-on and click Install or Configuration.
-
In the dialog box, click Console-to-Code. Click the Terraform tab and copy the displayed configuration.
Best practices for add-on management
Specify add-ons at cluster creation and manage their lifecycle afterward. The following sections cover lifecycle management and best practices for different scenarios.
Specify add-ons at cluster creation
The following Terraform resources correspond to different cluster types:
-
ACK managed cluster: alicloud_cs_managed_kubernetes
-
ACK dedicated cluster: alicloud_cs_kubernetes
-
ACK Edge cluster: alicloud_cs_edge_kubernetes
-
ACK Serverless cluster: alicloud_cs_serverless_kubernetes
Set the addons object in the Resource to specify add-ons. The following code block shows the addons object attributes:
# This example uses an ACK managed cluster.
resource "alicloud_cs_managed_kubernetes" "default" {
# Other parameters.
# ...
# The addons object is a list. You can set the addons object in a Resource to specify the add-ons to be installed when the system creates the cluster.
addons {
# The name of the add-on. You can query the name of an add-on by using alicloud_cs_kubernetes_addons of Data Source.
# The add-ons that are already installed and can be installed in the cluster and the versions of the add-ons.
name = "XXX"
# Custom add-on parameters. You can set this attribute for cluster add-ons that support custom parameters. For more information, see the Modify the custom parameters of a cluster add-on section.
config = jsonencode(
{
....
}
)
# The value is of Boolean type and the default is false. By default, ACK automatically installs specific add-ons for you to manage the cluster. If you do not want ACK to install add-ons when ACK creates the cluster, set disabled=true.
disabled = XXX
}
}
The addons object only applies at cluster creation. You cannot modify it afterward to update, uninstall, or reconfigure add-ons. See Manage add-ons after cluster creation.
The following table lists add-ons configurable with Terraform.
|
Add-on |
Add-on type |
Description |
How to configure by using Terraform |
|
appcenter |
Application management |
Centrally manages application deployments and lifecycles across clusters. |
|
|
progressive-delivery-tool |
Application management |
Allows phased releases of applications. |
|
|
alicloud-monitor-controller |
Logging and monitoring |
Enables integration with CloudMonitor. |
|
|
metrics-server |
Logging and monitoring |
Collects resource metrics based on open source Metrics Server. Provides the Metrics API and supports Horizontal Pod Autoscaler (HPA). |
|
|
ack-node-problem-detector |
Logging and monitoring |
Monitors node health based on open source Node Problem Detector (NPD). Connects to third-party monitoring platforms. |
|
|
ags-metrics-collector |
Logging and monitoring |
Monitors per-node resource usage in Alibaba Cloud Genomics Service (AGS) workflows. |
|
|
ack-arms-prometheus |
Logging and monitoring |
Monitors ACK clusters by using Managed Service for Prometheus. |
|
|
loongcollector |
Logging and monitoring |
Collects container logs by using Log Service. |
|
|
csi-plugin |
Storage |
Mounts and unmounts volumes. Automatically installed when CSI is selected at cluster creation. |
|
|
csi-provisioner |
Storage |
Automates volume provisioning. Automatically installed when CSI is selected at cluster creation. |
|
|
storage-operator |
Storage |
Manages the lifecycle of volume add-ons. |
|
|
alicloud-disk-controller |
Storage |
Automates disk volume provisioning. |
|
|
flexvolume |
Storage |
An early storage volume extension mechanism developed by the Kubernetes community. Mounts and unmounts volumes. Automatically installed when FlexVolume is selected at cluster creation. |
|
|
nginx-ingress-controller |
Networking |
Parses Ingress routing rules and forwards matching requests to backend Services. |
|
|
terway-eniip |
Networking |
An Alibaba Cloud CNI add-on that works with VPC and supports standard Kubernetes network policies. Sets up network connectivity within clusters. Automatically installed when Terway is selected at cluster creation. |
|
|
ack-node-local-dns |
Networking |
A local DNS caching solution developed based on the open source NodeLocal DNSCache project. |
|
|
aliyun-acr-credential-helper |
Security |
Pulls private images without passwords from Container Registry Enterprise Edition and Personal Edition. |
|
|
gatekeeper |
Security |
Manages and enforces OPA policies in ACK clusters and manages namespace labels. |
|
|
kritis-validation-hook |
Security |
Verifies image signatures. |
|
|
security-inspector |
Security |
Performs security inspections. |
|
|
ack-kubernetes-webhook-injector |
Security |
Dynamically manages pod IP addresses in Alibaba Cloud service whitelists. |
|
|
ack-arena |
Others |
Installs open source Arena in the ACK console. |
|
|
ack-cost-exporter |
Others |
Enables cost analysis data processing. |
|
|
ack-kubernetes-cronhpa-controller |
Others |
Scales workloads on a schedule. |
|
|
ack-virtual-node |
Others |
Based on open source Virtual Kubelet with Aliyun Provider support. Enables seamless integration between Kubernetes and Elastic Container Instance. |
|
|
aesm |
Others |
An Intel SGX system add-on that provides launch support for SGX Enclave, including services such as key provisioning and remote attestation. |
|
|
aliyun-acr-acceleration-suite |
Others |
Enables on-demand image loading. Deployed as a DaemonSet on worker nodes. |
|
|
migrate-controller |
Others |
Migrates Kubernetes applications based on open source Velero. |
|
|
resource-controller |
Others |
Dynamically controls pod resources. Required for topology-aware CPU scheduling in ACK Pro clusters. |
|
|
sandboxed-container-controller |
Others |
Enhances and extends sandboxed container features in the Sandboxed-Container runtime. |
|
|
sandboxed-container-helper |
Others |
Performs health checks and O&M operations on sandboxed containers. |
|
|
sgx-device-plugin |
Others |
Simplifies Intel SGX usage in containers. Developed by the ACK team and Ant Group. |
|
Manage add-ons after cluster creation
Ensure you have an ACK cluster before managing add-on lifecycle.
Use the alicloud_cs_kubernetes_addon resource to install, update, uninstall, and configure add-ons. The following code block shows the alicloud_cs_kubernetes_addon attributes:
resource "alicloud_cs_kubernetes_addon" "addon-example" {
# The ID of the cluster.
cluster_id = "XXXX"
# The name of the add-on. You can query the add-ons that are already installed and can be installed and their versions by using alicloud_cs_kubernetes_addons of Data Source.
name = "XXXX"
# The version of the add-on.
version = "XXXX"
# Custom add-on parameters in a JSON string. You can use the jsonencode method of Terraform to specify the parameters or directly specify the parameters in a JSON string. Pay attention to character escaping if you directly specify the parameters in a JSON string. You can set this attribute for cluster add-ons that support custom parameters. For more information, see the Modify the custom parameters of a cluster add-on section.
config = jsonencode(
{
....
}
)
}
You can also specify custom parameters directly in a JSON string. Pay attention to character escaping. For example, configure nginx-ingress-controller using either method:
-
Use
jsonencodeto configure custom parameters:config = jsonencode( { IngressSlbNetworkType="internet" IngressSlbSpec="slb.s2.small" } ) -
Directly specify custom parameters in a JSON string:
config = "{\"IngressSlbNetworkType\":\"internet\",\"IngressSlbSpec\":\"slb.s2.small\"}"
Import installed add-ons into Terraform
Use terraform import to import cluster add-ons into Terraform for management. The following example uses nginx-ingress-controller.
-
Create a .tf file and define a Resource. If you already have a .tf file, define the Resource there.
The
alicloud_cs_kubernetes_addonresource manages cluster add-ons. Leave it empty initially.resource "alicloud_cs_kubernetes_addon" "nginx-ingress-controller" { } -
Import nginx-ingress-controller:
Terraform pulls the nginx-ingress-controller configuration from the cluster into the .state.
terraform import alicloud_cs_kubernetes_addon.nginx-ingress-controller <cluster_id>:nginx-ingress-controller -
Run
terraform plan. The output shows the configuration difference between nginx-ingress-controller and the Resource.Update the Resource from Step 1 based on the diff and the .state. When
terraform planshows no difference, the import is complete.resource "alicloud_cs_kubernetes_addon" "nginx-ingress-controller" { cluster_id = "XXXXX" name = "nginx-ingress-controller" version = "v1.2.1-aliyun.1" config = jsonencode( { IngressSlbNetworkType = "internet" IngressSlbSpec = "slb.s2.small" } ) }
Install cluster add-ons
Use the alicloud_cs_kubernetes_addon resource to install add-ons. The following example uses Gatekeeper.
-
Specify the add-on in your .tf:
-
The cluster ID.
-
The name and version of the add-on:
Query installable add-ons and versions with
alicloud_cs_kubernetes_addonsData Source. Only the latest version is shown; for earlier versions, check the add-on release notes. -
(Optional) Custom add-on configuration:
Customize the
configfield withjsonencode. Query supported parameters withalicloud_cs_kubernetes_addon_metadataData Source. See Customize add-on parameters.
-
-
Install the add-on:
terraform applyExpected output:
Plan: 1 to add, 0 to change, 0 to destroy. Do you want to perform these actions? Terraform will perform the actions described above. Only 'yes' will be accepted to approve. Enter a value: yes alicloud_cs_kubernetes_addon.gatekeeper: Creating... alicloud_cs_kubernetes_addon.gatekeeper: Still creating... [10s elapsed] alicloud_cs_kubernetes_addon.gatekeeper: Creation complete after 16s [id=XXXXX:gatekeeper] Apply complete! Resources: 1 added, 0 changed, 0 destroyed.When
Apply complete!appears, the add-on is installed.
Update cluster add-ons
Query available versions with alicloud_cs_kubernetes_addons Data Source, then change the version number to update. The following example uses Gatekeeper.
Run terraform apply to update the add-on. Apply complete! indicates the update succeeded.
Customize add-on parameters
Modify the config field in alicloud_cs_kubernetes_addons to customize add-on configuration. The following example uses Gatekeeper.
Query supported custom parameters with alicloud_cs_kubernetes_addon_metadata Data Source, which returns a JSON schema. For example, to query Gatekeeper parameters, add the following to your .tf file:
# Define Data Source to obtain the schema that includes the custom parameters supported by the Gatekeeper add-on.
data "alicloud_cs_kubernetes_addon_metadata" "default" {
cluster_id = "ce36b7c61e126430b8b245730ca6d****"
name = "gatekeeper"
version = "v3.8.1.113-geb7947ef-aliyun"
}
# Output the schema.
output "addon_config_schema" {
value = data.alicloud_cs_kubernetes_addon_metadata.default.config_schema
}
Run terraform apply. The result is a JSON schema where the properties attribute lists all supported custom parameters:
-
default: the default value.
-
Description: the parameter description.
-
pattern: a regular expression for valid values.
-
type: the data type.
Configure network add-ons
ACK clusters use Terway for container networking. See Overview.
The following example configures a network add-on with Terraform:
Configure volume add-ons
ACK provides FlexVolume and CSI volume add-ons. FlexVolume is discontinued; use CSI instead. If no storage add-on is specified at cluster creation, CSI is installed by default.
Configure logging add-ons
The ACK log collection add-on stores logs in Simple Log Service (SLS) using one of two methods:
-
Use an existing SLS project.
-
Let ACK automatically create an SLS project during cluster creation.
The following example configures loongcollector with Terraform based on your Log Service project choice:
Configure monitoring add-ons
ACK provides the CloudMonitor agent for ECS nodes and the Managed Service for Prometheus add-on. Configure the install_cloud_monitor parameter with Terraform to install the CloudMonitor agent.
Configure Ingress add-ons
ACK provides nginx-ingress-controller and alb-ingress-controller to route traffic to applications.
-
nginx-ingress-controller: Based on open source ingress-nginx. Provides flexible and reliable routing. See Overview of NGINX Ingresses.
-
alb-ingress-controller: Managed by ACK. Provides flexible and reliable routing. See Access Services by using an ALB Ingress.
The following example configures Ingress add-ons with Terraform:
Disable default add-on installation
ACK installs default add-ons during cluster creation. To prevent a specific add-on from being installed, set disabled = true. The following example disables nginx-ingress-controller:
# Disable the system to install the nginx-ingress-controller add-on.
resource "alicloud_cs_managed_kubernetes" "default" {
# Other parameters.
# ...
addons {
name = "nginx-ingress-controller"
disabled = true
}
}
Add-ons installed by default
Without explicit addons configuration, the system installs the following add-ons:
|
Cluster type |
Add-on type |
Name of the default add-on that is installed |
Description |
|
|
ACK cluster |
System add-ons |
kube-scheduler |
Schedules cluster resources. |
|
|
cloud-controller-manager |
Creates SLB instances and manages node route entries. |
|||
|
kube-apiserver |
The bus and Ingress gateway of an ACK cluster. |
|||
|
kube-controller-manager |
A cluster internal resource manager. |
|||
|
Logging and monitoring add-ons |
alicloud-monitor-controller |
Monitors container lifecycles and status. |
||
|
metrics-server |
Collects container resource metrics for auto scaling. |
|||
|
Volume add-ons |
csi-plugin |
Manages the lifecycle of volumes. This add-on is recommended. |
||
|
csi-provisioner |
Creates and deletes volumes. This add-on is recommended. |
|||
|
storage-operator |
Manages the lifecycle of storage add-ons. This add-on is recommended. |
|||
|
Network add-ons |
CoreDNS |
Serves as a DNS server for a Kubernetes cluster. |
||
|
Gateway API |
A gateway resource model. |
|||
|
terway-eniip |
The Terway network add-on. |
|||
|
nginx-ingress-controller (the Pro edition is installed by default) |
Parses NGINX Ingress traffic forwarding rules. |
|||
|
ACK Serverless cluster |
System add-ons |
kube-scheduler |
Schedules cluster resources. |
|
|
ack-virtual-node |
Scales resources with virtual nodes and elastic container instances. |
|||
|
cloud-controller-manager |
Creates SLB instances and manages node route entries. |
|||
|
kube-apiserver |
The bus and Ingress gateway of an ACK cluster. |
|||
|
kube-controller-manager |
A cluster internal resource manager. |
|||
|
Network add-ons |
CoreDNS |
Serves as a DNS server for a Kubernetes cluster. |
||
|
ACK Edge cluster |
System add-ons |
kube-scheduler |
Schedules cluster resources. |
|
|
cloud-controller-manager |
Creates SLB instances and manages node route entries. |
|||
|
kube-apiserver |
The bus and Ingress gateway of an ACK cluster. |
|||
|
kube-controller-manager |
A cluster internal resource manager. |
|||
|
Logging and monitoring add-ons |
alicloud-monitor-controller |
Monitors container lifecycles and status. |
||
|
metrics-server |
Collects container resource usage metrics for the auto scaling mechanism. |
|||
|
Network add-ons |
CoreDNS |
Serves as a DNS server for a Kubernetes cluster. |
||
|
terway-eniip |
The Terway network add-on. |
|||
|
Others |
edge-controller-manager |
- |
||
|
edge-tunnel-agent |
Creates reverse O&M tunnels for cloud-edge collaboration using C/S architecture. |
|||
|
edge-tunnel-server |
Creates reverse O&M tunnels for cloud-edge collaboration using C/S architecture. |
|||
|
yurt-app-manager |
Provides node pools and cell-based deployment for ACK Edge clusters. |
|||
Common configuration examples
The following examples cover common add-on configurations.
-
Use Terway as the network add-on.
-
Use CSI (recommended) or FlexVolume. FlexVolume is discontinued.
-
Choose nginx-ingress-controller or alb-ingress-controller based on your requirements.
-
Choose other add-ons based on your requirements.