すべてのプロダクト
Search
ドキュメントセンター

Container Service for Kubernetes:Terraformを使用してアドオンを管理する

最終更新日:Jan 26, 2025

Container Service for Kubernetes (ACK) は、クラスター機能を拡張するためのさまざまなアドオンを提供します。 このトピックでは、Terraformを使用してアドオンを設定し、さまざまなシナリオの要件を満たす方法について説明します。

アドオンの種類

ACKは、システムアドオンとオプションのアドオンのタイプを管理します。 詳細については、「コンポーネントの概要」をご参照ください。

システムアドオン

システムアドオンは、ACKクラスターの実行に必要な基本的なアドオンです。 システムアドオンは、システムがACKクラスターを作成すると自動的にインストールされます。 たとえば、次のアドオンは、システムがクラスターを作成するときに自動的にインストールされます。

  • Kube-apiserver

  • kube-controller-manager

  • cloud-controller-manager

  • kube-proxy

  • CoreDNS

オプションのアドオン

オプションのアドオンをデプロイして、オンデマンドでクラスターの機能を拡張できます。 オプションのアドオンは、アプリケーション管理アドオン、ロギングおよびモニタリングアドオン、ボリュームアドオン、ネットワークアドオン、およびセキュリティアドオンに分類されます。

アドオン管理のベストプラクティス

Terraformを使用して、クラスターの作成時にインストールするアドオンを指定できます。 クラスターの作成後、クラスター内のアドオンのライフサイクルを管理できます。 次のセクションでは、クラスターにインストールされているアドオンのライフサイクルを管理する方法と、さまざまなシナリオに適用されるベストプラクティスについて説明します。

クラスターの作成時にインストールするアドオンの指定

クラスターの作成時にインストールするアドオンを指定できます。 さまざまなタイプのクラスターを作成する場合、次のリソースが含まれます。

  • ACK管理クラスター: alicloud_cs_managed_kubernetes

  • ACK専用クラスター: alicloud_cs_kubernetes

  • ACKエッジクラスター: alicloud_cs_edge_kubernetes

  • ACKサーバーレスクラスター: alicloud_cs_serverless_kubernetes

addonsオブジェクトを設定して、上記のいずれかのリソースを作成するときにインストールするアドオンを指定できます。 次のコードブロックは、addonsオブジェクトの属性を示しています。

# 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
  }
}
重要

リソース内のアドオンオブジェクトを設定して、クラスターを作成するときにのみインストールするアドオンを指定できます。 クラスターの作成後、アドオンのライフサイクルを管理するためにアドオンオブジェクトを変更することはできません。 たとえば、このメソッドを使用してアドオンを更新、アンインストール、または変更することはできません。 クラスター作成後のアドオンのライフサイクルを管理する方法の詳細については、「クラスター作成後のアドオンのライフサイクルの管理」をご参照ください。

ACKクラスターでTerraformを使用してアドオンを設定する方法を次の表に示します。

アドオン

アドオンタイプ

説明

Terraformを使用して設定する方法

appcenter

アプリケーション管理

さまざまなクラスター内のアプリケーションのデプロイとライフサイクルを一元管理できます。

アドオン {name = "appcenter" }

プログレッシブ配信ツール

アプリケーション管理

アプリケーションの段階的リリースを許可します。

アドオン {name = "progressive-delivery-tool" }

alicloud-monitor-controller

ログとモニタリング

CloudMonitorとの統合を可能にします。

アドオン {name = "alicloud-monitor-controller" }

metrics-server

ログとモニタリング

このアドオンは、オープンソースのアドオンMetrics Serverに基づいて開発され、リソースメトリックを収集できます。 このアドオンは、データ消費用のMetrics APIも提供し、Horizontal Pod Autoscaler (HPA) をサポートします。

アドオン {name = "metrics-server" }

ack-node-problem-detector

ログとモニタリング

このアドオンは、オープンソースのアドオンNode Problem Detector (NPD) に基づいて開発されており、ノードのヘルスステータスを監視し、サードパーティの監視プラットフォームに接続できます。

アドオン {name = "ack-node-problem-detector" }

ags-metrics-collector

ログとモニタリング

Alibaba Cloud Genomics Service (AGS) ユーザーが、AGSワークフローの各ノードで使用されるリソースを監視できるようにします。

アドオン {name = "ags-metrics-collector" }

ack-arms-プロメテウス

ログとモニタリング

Prometheusのマネージドサービスを使用してACKクラスターを監視します。

アドオン {name = "arms-prometheus" }

logtail-ds

ログとモニタリング

Log Serviceを使用してコンテナログを収集します。

アドオン {name = "logtail-ds" }

csi-plugin

ボリューム

ボリュームをマウントおよびマウント解除できます。 このアドオンは、ACKクラスターの作成時にCSIアドオンを選択すると自動的にインストールされます。

アドオン {name = "csi-plugin" }

csi-provisioner

ボリューム

ボリュームのプロビジョニングを自動化できます。 このアドオンは、ACKクラスターの作成時にCSIアドオンを選択すると自動的にインストールされます。

アドオン {name = "csi-plugin" }

storage-operator

ボリューム

ボリュームアドオンのライフサイクルを管理します。

アドオン {name = "storage-operator" }

alicloud-disk-controller

ボリューム

ディスクボリュームのプロビジョニングを自動化できます。

アドオン {name = "alicloud-disk-controller" }

flexvolume

ボリューム

ボリューム拡張を可能にするために初期段階で開発されたオープンソースのアドオン。 FlexVolumeアドオンは、ボリュームのマウントとアンマウントに使用されます。 このアドオンは、ACKクラスターの作成時にFlexVolumeアドオンを選択すると自動的にインストールされます。

アドオン {name = "flexvolume" }

nginx-ingress-controller

ネットワーク

ACKクラスター内のIngressのルーティングルールを解析します。 Ingressコントローラーが転送ルールに一致するリクエストを受信すると、リクエストはバックエンドサービスにルーティングされます。

アドオン {name = "nginx-ingress-controller" }

terway-eniip

ネットワーク

Alibaba Cloudによって開発されたオープンソースのContainer Network Interface (CNI) アドオン。 このアドオンはVirtual Private Cloud (VPC) と一緒に使用され、標準のKubernetesネットワークポリシーを使用して、コンテナー間の通信方法を調整できます。 Terwayを使用して、Kubernetesクラスター内のネットワーク接続を設定できます。 このアドオンは、ACKクラスターの作成時にTerwayアドオンを選択すると自動的にインストールされます。

アドオン {name = "terway-eniip" }

ack-node-local-dns

ネットワーク

オープンソースのNodeLocal DNSCacheプロジェクトに基づいて開発されたローカルDNSキャッシングソリューション。

アドオン {name = "ack-node-local-dns" }

aliyun-acr-credential-helper

セキュリティ

Container Registry Enterprise EditionおよびPersonal Editionのインスタンスからパスワードなしでプライベートイメージをプルできます。

アドオン {name = "aliyun-acr-credential-helper" }

ゲートキーパー

セキュリティ

ACKクラスターでOpen Policy Agent (OPA) によって実行されるポリシーを管理および適用し、名前空間のラベルを管理できます。

アドオン {name = "gatekeeper" }

kritis-validation-hook

セキュリティ

イメージ署名を検証するために使用されるキーアドオン。

アドオン {name = "kritis-validation-hook" }

security-inspector

セキュリティ

セキュリティ検査を実行するために使用される重要なアドオン。

アドオン {name = "security-inspector" }

ack-kubernetes-webhook-injector

セキュリティ

さまざまなAlibaba CloudサービスのホワイトリストにポッドIPアドレスを動的に追加または削除できます。 これにより、手動操作から解放されます。

アドオン {name = "ack-kubernetes-webhook-injector" }

ack-アリーナ

その他

オープンソースのArenaをACKコンソールに効率的にインストールできます。

アドオン {name = "ack-arena" }

ack-cost-exporter

その他

コスト分析機能を使用してデータを処理できます。

アドオン {name = "ack-cost-exporter" }

ack-kubernetes-cronhpa-controller

その他

スケジュールに基づいてワークロードをスケールできます。

アドオン {name = "ack-kubernetes-cronhpa-controller" }

ack-仮想ノード

その他

このアドオンは、オープンソースのVirtual Kubeletプロジェクトに基づいて開発され、Aliyun Providerのサポートを追加します。 このアドオンが改善され、KubernetesとElastic Container Instanceのシームレスな統合が可能になりました。

アドオン {name = "ack-virtual-node" }

aesm

その他

Intel (R) Software Guard Extensions (SGX) Architectural Enclave Service Manager (AESM) は、Intel SGXのシステムアドオンです。 このアドオンは、SGX Enclaveの起動サポートを提供し、キーのプロビジョニングやリモート証明などのサービスを提供します。

アドオン {name = "aesm" }

aliyun-acr-acceleration-suite

その他

オンデマンド画像の読み込みを可能にするクライアントアドオン。 このアドオンは、ワーカーノードにDaemonSetとしてデプロイされます。

アドオン {name = "aliyun-acr-acceleration-suite" }

migrate-controller

その他

このアドオンは、オープンソースのVeleroプロジェクトに基づいて開発されており、Kubernetesアプリケーションを移行できます。

アドオン {name = "migrate-controller" }

リソースコントローラ

その他

ポッドを動的にスケジュールするために使用されるキーアドオン。 ACK Proクラスターのトポロジ対応CPUスケジューリングを有効にする場合は、このアドオンが必要です。

アドオン {name = "resource-controller" }

sandboxed-container-controller

その他

サンドボックスコンテナーの基本機能を強化および拡張するために、サンドボックスコンテナーランタイムによって提供されるコントローラーアドオン。

アドオン {name = "sandboxed-container-controller" }

sandboxed-container-helper

その他

サンドボックス化されたコンテナに対してヘルスチェックとO&M操作を実行できます。

アドオン {name = "sandboxed-container-helper" }

sgx-device-plugin

その他

ACKチームとAntグループによって開発されたKubernetesデバイスアドオン。 このアドオンは、コンテナでのIntel (R) Software Guard Extensions (SGX) の使用を簡素化します。

アドオン {name = "sgx-device-plugin" }

クラスター作成後のアドオンのライフサイクルの管理

アドオンのライフサイクルを管理するには、ACKクラスターがあることを確認します。 ACKクラスターがない場合は、最初に作成します。

クラスターリソースでalicloud_cs_kubernetes_addonオブジェクトを設定して、クラスターにインストールされているアドオンのライフサイクルを管理できます。 アドオンをインストール、更新、アンインストールしたり、アドオンの構成をカスタマイズしたりできます。 次のコードブロックは、alicloud_cs_kubernetes_addonオブジェクトの属性を示しています。

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(
    {
      ....
    }
  )
}

カスタムパラメーターはJSON文字列で直接指定できます。 この方法を使用するときは、キャラクターのエスケープに注意してください。 たとえば、次のいずれかの方法を使用して、nginx-ingress-controllerを設定できます。

  • jsonencodeを使用してカスタムパラメーターを設定します。

    config = jsonencode(   
      {       
        IngressSlbNetworkType="internet"       
        IngressSlbSpec="slb.s2.small"     
      }  
    )
  • JSON文字列でカスタムパラメータを直接指定します。

    config = "{\"IngressSlbNetworkType\":\"internet\",\"IngressSlbSpec\":\"slb.s2.small\"}"

インストールされたアドオンをTerraformにインポートして管理する

terraform importメソッドを使用して、クラスターにインストールされているアドオンをTerraformにインポートし、Terraformを使用してこれらのアドオンを管理できます。 このセクションでは、例としてnginx-ingress-controllerを使用して、インストールされたアドオンをTerraformにインポートする方法を示します。

  1. サフィックスが. tfリソースを定義します。 サフィックスがであるファイルが既にある場合. tfファイルにリソースを定義します。

    Resource内のalicloud_cs_kubernetes_addonオブジェクトは、クラスター内のアドオンを管理するために使用されます。 オブジェクトにコンテンツを追加する必要はありません。

    resource "alicloud_cs_kubernetes_addon" "nginx-ingress-controller" {
    }
  2. 次のコマンドを実行して、nginx-ingress-controllerをインポートします。

    Terraformは自動的にクラスターからnginx-ingress-controllerの構成を取得し、サフィックスがであるファイルに構成を追加します。. 状態.

    terraform import alicloud_cs_kubernetes_addon.nginx-ingress-controller <cluster_id>:nginx-ingress-controller
  3. terraform planコマンドを実行します。 コマンド出力は、nginx-ingress-controllerとResourceの設定の違いを示しています。

    で定義されたリソースの変更ステップ1構成の違いとサフィックスがであるファイルの内容に基づいて. 状態. terraform planコマンドの出力でnginx-ingress-controllerとResourceの設定に違いがない場合、アドオンはTerraformにインポートされます。

    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"
        }
      )
    }

クラスターアドオンのインストール

リソース内のalicloud_cs_kubernetes_addonオブジェクトを使用して、クラスターにアドオンをインストールできます。 このセクションでは、ゲートキーパーアドオンを例として使用します。

  1. サフィックスがであるファイルにインストールするアドオンについて、次の情報を指定します。. tf:

    • クラスターの ID。

    • アドオンの名前とバージョン:

      Data Sourceのalicloud_cs_kubernetes_addonsを使用して、インストールできるアドオンの名前とバージョンを照会できます。 結果には、インストール可能な各アドオンの最新バージョンのみが表示されます。 以前のバージョンをインストールする場合は、アドオンのリリースノートを確認し、対応するバージョン番号を指定します。

    • (オプション) カスタムアドオン設定:

      Terraformのjsonencodeメソッドを使用して、configフィールドを変更してアドオン設定をカスタマイズできます。 データソースのalicloud_cs_kubernetes_addon_metadataを使用して、アドオンのカスタムパラメーターを照会できます。 詳細については、「クラスターアドオンのカスタムパラメーターの変更」をご参照ください。

    クリックして詳細を表示

    resource "alicloud_cs_kubernetes_addon" "gatekeeper" {
      cluster_id = "ce36b7c61e126430b8b245730ca6d****"
      name = "gatekeeper"
      version = "v3.8.1.113-geb7947ef-aliyun"
      config = jsonencode(
        {
          AdmissionPodCpuLimit      = "1000m"
          AdmissionPodCpuRequest    = "100m"
          AdmissionPodMemoryLimit   = "512Mi"
          AdmissionPodMemoryRequest = "256Mi"
          AdmissionPodNumber        = 3
          AuditInterval             = 1800
          AuditPodCpuLimit          = "1000m"
          AuditPodCpuRequest        = "100m"
          AuditPodMemoryLimit       = "512Mi"
          AuditPodMemoryRequest     = "256Mi"
          EnableAuditPod            = false
          EnableMutatingWebhook     = false
        }
      )
    }
  2. 次のコマンドを実行して、クラスターにアドオンをインストールします。

    terraform apply

    期待される出力:

    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.

    申請完了! が表示されると、アドオンがインストールされます。

クラスターアドオンの更新

Data Sourceのalicloud_cs_kubernetes_addonsを使用して、更新可能なアドオンのバージョンを照会できます。 新しいバージョンが利用可能な場合は、バージョン番号を変更してアドオンを更新できます。 このセクションでは、ゲートキーパーアドオンを例として使用します。

クリックして詳細を表示

resource "alicloud_cs_kubernetes_addon" "gatekeeper" {
  cluster_id = "ce36b7c61e126430b8b245730ca6d****"
  name = "gatekeeper"

  # Change version to the version number that you want to use. 
  version = "XXXXXXXXX"
  config = jsonencode(
    {
      AdmissionPodCpuLimit      = "1000m"
      AdmissionPodCpuRequest    = "100m"
      AdmissionPodMemoryLimit   = "512Mi"
      AdmissionPodMemoryRequest = "256Mi"
      AdmissionPodNumber        = 3
      AuditInterval             = 1800
      AuditPodCpuLimit          = "1000m"
      AuditPodCpuRequest        = "100m"
      AuditPodMemoryLimit       = "512Mi"
      AuditPodMemoryRequest     = "256Mi"
      EnableAuditPod            = false
      EnableMutatingWebhook     = false
    }
  )
}

terraform applyコマンドを実行して、アドオンを更新します。 適用する場合は完了! が表示されると、アドオンが更新されます。

クラスターアドオンのカスタムパラメーターの変更

アドオンがカスタムパラメーターをサポートしている場合は、リソースでalicloud_cs_kubernetes_addonsを使用してアドオンの設定を変更できます。 このセクションでは、Gatekeeperアドオンを例として、configフィールドを変更してアドオン構成をカスタマイズする方法を示します。

クリックして詳細を表示

resource "alicloud_cs_kubernetes_addon" "gatekeeper" {
  cluster_id = "ce36b7c61e126430b8b245730ca6d****"
  name = "gatekeeper"
  version = "v3.8.1.113-geb7947ef-aliyun"

  # You can modify and apply the attributes in Config to customize the configuration of a cluster add-on. 

}

アドオンでサポートされているカスタムパラメーターを照会するには、Data Sourceのalicloud_cs_kubernetes_addon_metadataを使用します。 結果はJSONスキーマで返されます。 たとえば、Gatekeeperアドオンの設定をカスタマイズするには、次の内容をファイルに追加します。. tf.

# 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_addons.default.config_schema
}

terraform applyコマンドを実行します。 結果はJSONスキーマで返されます。 properties属性は、アドオンでサポートされているすべてのカスタムパラメーターを示します。 スキーマで返されるカスタムパラメーターを指定できます。 次のリストに、カスタムパラメーターを示します。

  • default: パラメータのデフォルト値。

  • Description: パラメータの説明。

  • pattern: すべての有効な値を指定する正規表現。

  • type: パラメータのデータ型。

クリックして詳細を表示

addon_config_schema = <<EOT
{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "properties": {
    "AdmissionPodCpuLimit": {
      "default": "1000m",
      "description": "cpu limit for gatekeeper",
      "pattern": "^(|[1-9][0-9]*(m|\\.\\d+)?)$",
      "type": "string"
    },
    "AdmissionPodCpuRequest": {
      "default": "100m",
      "description": "cpu request for gatekeeper",
      "pattern": "^[1-9][0-9]*(m|\\.\\d+)?$",
      "type": "string"
    },
    "AdmissionPodMemoryLimit": {
      "default": "512Mi",
      "description": "memory limit for gatekeeper",
      "pattern": "^(|[1-9][0-9]*(\\.\\d+)?(K|Ki|M|Mi|G|Gi|T|Ti)?)$",
      "type": "string"
    },

    ......
  },
  "title": "Config",
  "type": "object"
}
EOT

ネットワークアドオンの設定

ACKクラスターでは、Terwayを使用して前述のコンテナネットワーク機能を実装できます。 詳細については、「概要」をご参照ください。

次の例は、Terraformを使用してネットワークアドオンを構成する方法を示しています。

クリックして詳細を表示

# Configure the Terway network add-on and enable the Assign One ENI to Each Pod mode. This is the default mode. 
# In this mode, the number of pods on a node is limited by the elastic network interface (ENI) quota of Elastic Compute Service (ECS) instances. 

resource "alicloud_cs_managed_kubernetes" "default" {
  # Other parameters. 
  # ...

  addons {
    name = "terway-eni"
  }
}

# Configure the Terway network add-on and enable the IPVLAN mode. 
# You can use only the Alibaba Cloud Linux 2 operating system because the One ENI for Multi-Pod mode uses the IPVLAN + eBPF virtualization technology. 
resource "alicloud_cs_managed_kubernetes" "default" {
  # Other parameters. 
  # ...

  addons {
    name   =  "terway-eniip",
    config = "{\"IPVlan\":\"true\",\"NetworkPolicy\":\"false\"}"
  }
}

# Configure the Terway network add-on and enable Kubernetes network policies in IPVLAN mode. 
# You can use only the Alibaba Cloud Linux 2 operating system because the One ENI for Multi-Pod mode uses the IPVLAN + eBPF virtualization technology. 
# The IPVLAN mode provides network access control based on Kubernetes network policies. 
resource "alicloud_cs_managed_kubernetes" "default" {
  # Other parameters. 
  # ...

  addons {
    name   =  "terway-eniip",
    config = "{\"IPVlan\":\"true\",\"NetworkPolicy\":\"true\"}"
  }
}

ボリュームアドオンの設定

ACKは、FlexVolumeおよびCSIボリュームアドオンを提供する。 FlexVolumeは中止されました。 ACKチームは、CSIを継続的に更新する。 Terraformを使用してクラスターを作成するときにボリュームアドオンを指定しないと、FlexVolumeがインストールされます。 次の例は、Terraformを使用してボリュームアドオンを設定する方法を示しています。

クリックして詳細を表示

# The CSI volume add-on consists of csi-plugin and csi-provisioner. If you use the CSI add-on and want ACK to create a default NAS file system and CNFS file system for dynamically provisioned volumes, you must also install the storage-operator add-on. 
resource "alicloud_cs_managed_kubernetes" "default" {
  # Other parameters. 
  # ...

  addons {
    name = "csi-plugin"
  }
  addons {
    name = "csi-provisioner"
  }
  addons {
    name   = "storage-operator"
    config = "{\"CnfsOssEnable\":\"false\",\"CnfsNasEnable\":\"true\"}"
  }
}

ロギングアドオンの設定

ACKは、ログデータをlog Serviceに収集するために使用できるログアドオンログテイル-dsを提供します。 logtail-dsアドオンでは、次のいずれかの方法を使用してイベントを保存できます。

  • イベントを保存する既存のLog Serviceプロジェクトを指定します。

  • ACKがクラスターを作成するときにイベントを保存するLog Serviceプロジェクトを自動的に作成するようにACKを設定します。

次の例は、選択したLog Serviceプロジェクトに基づいてTerraformを使用してlogtail-dsを設定する方法を示しています。

クリックして詳細を表示

# Use the automatically created Simple Log Service project. 
resource "alicloud_cs_managed_kubernetes" "default" {
  # Other parameters. 
  # ...

  addons {
    name = "logtail-ds"
  }
}

# Use the automatically created Simple Log Service project. Enable the automatically created Ingress dashboard. 
resource "alicloud_cs_managed_kubernetes" "default" {
  # Other parameters. 
  # ...

  addons {
    name = "logtail-ds"
    config = "{\"IngressDashboardEnabled\":\"true\"}
  }
}


# Use an existing Simple Log Service project. Enable the automatically created Ingress dashboard. 
resource "alicloud_cs_managed_kubernetes" "default" {
  # Other parameters. 
  # ...

  addons {
    name = "logtail-ds"
    config = "{\"IngressDashboardEnabled\":\"true\",\"sls_project_name\":\"k8s-log-c55c35ff493df47b88783bea48827****\"}"
  }
}

# Install and configure node-problem-detector. 
# Configure node-problem-detector to use the automatically created Simple Log Service project to store events. 
resource "alicloud_cs_managed_kubernetes" "default" {
  # Other parameters. 
  # ...

  addons {
    name   = "ack-node-problem-detector"
    config = "{\"sls_project_name\":\"\"}"
  }
}

# Install and configure node-problem-detector. 
# Configure node-problem-detector to use an existing Simple Log Service project to store events. node-problem-detector can share the Logstore that is used by logtail-ds. 
resource "alicloud_cs_managed_kubernetes" "default" {
  # Other parameters. 
  # ...

  addons {
    name   = "ack-node-problem-detector"
    config = "{\"sls_project_name\":\"k8s-log-c55c35ff493df47b88783bea48827****\"}"
  }
}

モニタリングアドオンの設定

ACKは、ECSインスタンスで実行されるCloudMonitorエージェントとPrometheusアドオンのマネージドサービスを提供します。 Terraformを使用してinstall_cloud_monitorパラメーターを設定し、ECSノードにCloudMonitorエージェントをインストールできます。

クリックして詳細を表示

# Install the CloudMonitor agent on ECS nodes. 
resource "alicloud_cs_managed_kubernetes" "default" {
  # Other parameters. 
  # ...
  install_cloud_monitor = true
}

# Install Managed Service for Prometheus add-on. 
resource "alicloud_cs_managed_kubernetes" "default" {
  # Other parameters. 
  # ...

  addons {
    name = "arms-prometheus"
  }
}

# Install the CloudMonitor agent and Managed Service for Prometheus add-on at the same time. 

# Install the Managed Service for Prometheus add-on. We recommend that you install the add-on and then enable Managed Service for Prometheus. 
resource "alicloud_cs_managed_kubernetes" "default" {
  # Other parameters. 
  # ...
  install_cloud_monitor = true
  addons {
    name = "arms-prometheus"
  }
}

Ingressアドオンの設定

ACKは、トラフィックをアプリケーションにルーティングするために使用できるnginx-ingress-controllerおよびalb-ingress-controllerアドオンを提供します。

  • nginx-ingress-controller: このアドオンは、オープンソースのingress-nginxアドオンに基づいて開発され、柔軟で信頼性の高いルーティングサービスを提供します。 詳細については、「NGINX Ingressの概要」をご参照ください。

  • alb-ingress-controller: このアドオンはACKで管理され、柔軟で信頼性の高いルーティングサービスを提供します。 詳細については、「ALB Ingressを使用したサービスへのアクセス」をご参照ください。

次の例は、Terraformを使用してIngressアドオンを構成する方法を示しています。

クリックして詳細を表示

# Configure nginx-ingress-controller. 
# If you use an Internet-facing Server Load Balancer (SLB) instance, you must set the IngressSlbNetworkType parameter to internet in the Config. 
# If you use an internal-facing SLB instance, you must set the IngressSlbNetworkType parameter to intranet in the Config. 
resource "alicloud_cs_managed_kubernetes" "default" {
  # Other parameters. 
  # ...

  addons {
    name   =  "nginx-ingress-controller",
    config = "{\"IngressSlbNetworkType\":\"internet\",\"IngressSlbSpec\":\"slb.s2.small\"}"
  }
}

# Configure alb-ingress-controller. 
resource "alicloud_cs_managed_kubernetes" "default" {
  # Other parameters. 
  # ...

  addons {
    name   = "alb-ingress-controller",
    config = "{\"albIngress\":{\"CreateDefaultALBConfig\":false}}"  # Not created right now.
#   config = "{\"albIngress\":{\"LoadBalancerId\":\"alb-vl8uiXXXXXxdr\",\"CreateDefaultALBConfig\":true}}" # Specify an existing ALB instance.
#   config = "{\"albIngress\":{\"AddressType\":\"Internet\",\"ZoneMappings\":{\"cn-hangzhou-l\":[\"vsw-uf6XXXXXoyb4qe\"],\"cn-hangzhou-m\":[\"vsw-uf6XXXX0rlkiq\"]},\"CreateDefaultALBConfig\":true}}" # 新建,至少需要选择两个及以上的可用区。
 
  }
}

システムを無効にしてデフォルトのアドオンをインストールする

ACKはデフォルトのアドオンを自動的にインストールし、クラスター管理を簡素化します。 システムがクラスターを作成するときにシステムを無効にして特定のアドオンをインストールする場合は、disabled = true設定を使用できます。 次の例は、システムを無効にして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
  }
}

アドオンオブジェクトにアドオンが指定されていない場合に自動的にインストールされるアドオン

アドオンオブジェクトにアドオンを指定しないと、次のアドオンが自動的にインストールされます。

クラスターのタイプ

アドオンタイプ

インストールされているデフォルトのアドオンの名前

説明

ACKクラスター

システムアドオン

kube-scheduler

クラスターリソースをスケジュールします。

cloud-controller-manager

アプリケーション用のSLBインスタンスを作成し、ノードのルートエントリを管理します。

Kube-apiserver

ACKクラスターのバスとIngressゲートウェイ。

kube-controller-manager

クラスター内部リソースマネージャー。

アドオンのロギングと監視

alicloud-monitor-controller

コンテナのライフサイクルとステータスを監視します。

metrics-server

自動スケーリングメカニズムのコンテナリソース使用量メトリックを収集します。

ボリュームアドオン

csi-plugin

ボリュームのライフサイクルを管理します。 このアドオンをお勧めします。

csi-provisioner

ボリュームを作成および削除します。 このアドオンをお勧めします。

storage-operator

ストレージアドオンのライフサイクルを管理します。 このアドオンをお勧めします。

ネットワークアドオン

CoreDNS

KubernetesクラスターのDNSサーバーとして機能します。

ゲートウェイAPI

ゲートウェイリソースモデル。

terway-eniip

Terwayネットワークアドオン。

nginx-ingress-controller (Proエディションはデフォルトでインストールされています)

NGINX Ingressで設定されているトラフィック転送ルールを解析します。

ACKサーバーレスクラスタ

システムアドオン

kube-scheduler

クラスターリソースをスケジュールします。

ack-仮想ノード

仮想ノードとelasticコンテナインスタンスに基づいてリソースをスケーリングします。

cloud-controller-manager

アプリケーション用のSLBインスタンスを作成し、ノードのルートエントリを管理します。

Kube-apiserver

ACKクラスターのバスとIngressゲートウェイ。

kube-controller-manager

クラスター内部リソースマネージャー。

ネットワークアドオン

CoreDNS

KubernetesクラスターのDNSサーバーとして機能します。

ACK Edgeクラスター

システムアドオン

kube-scheduler

クラスターリソースをスケジュールします。

cloud-controller-manager

アプリケーション用のSLBインスタンスを作成し、ノードのルートエントリを管理します。

Kube-apiserver

ACKクラスターのバスとIngressゲートウェイ。

kube-controller-manager

クラスター内部リソースマネージャー。

アドオンのロギングと監視

alicloud-monitor-controller

コンテナのライフサイクルとステータスを監視します。

metrics-server

自動スケーリングメカニズムのコンテナリソース使用量メトリックを収集します。

ネットワークアドオン

CoreDNS

KubernetesクラスターのDNSサーバーとして機能します。

terway-eniip

Terwayネットワークアドオン。

その他

edge-controller-manager

-

edge-tunnel-agent

C/Sアーキテクチャを採用して、クラウドエッジコラボレーション用のリバースO&Mトンネルを作成します。

edge-tunnel-server

C/Sアーキテクチャを採用して、クラウドエッジコラボレーション用のリバースO&Mトンネルを作成します。

yurt-app-manager

ACK Edgeクラスターのノードプールとセルベースの展開を提供します。

一般的に使用される設定の例

このセクションでは、参照用によく使用される設定の例を示します。

  • ネットワークアドオンとしてTerwayを使用します。

  • ビジネス要件に基づいてCSIまたはFlexVolumeを選択します。 FlexVolumeは廃止されているため、CSIを選択することを推奨します。

  • 要件に基づいて、nginx-ingress-controllerまたはalb-ingress-controllerを選択します。

  • ビジネス要件に基づいて他のアドオンを選択できます。

例1: アドオンをインストールしない

# Do not install any add-ons when you create the cluster. In this scenario, only the default add-ons are installed. 
# A simple template. Replace the variables with the desired values. 
resource "alicloud_cs_managed_kubernetes" "default" {
  name                         = var.name
  cluster_spec                 = "ack.pro.small"
  is_enterprise_security_group = true
  pod_cidr                     = "172.20.0.0/16"
  service_cidr                 = "172.21.0.0/20"
  worker_vswitch_ids           = ["var.vswitch_id"]
}

例2: Terwayのインストール

# Create a cluster that has Terway installed. 
# Enable the Assign One ENI to Each Pod mode. 

resource "alicloud_cs_managed_kubernetes" "default" {
  name                         = var.name
  cluster_spec                 = "ack.pro.small"
  is_enterprise_security_group = true
  pod_vswitch_ids              = [var.vswitch_id]
  service_cidr                 = "172.21.0.0/20"
  worker_vswitch_ids           = ["var.vswitch_id"]

  addons {
    name = "terway-eni"
  }
}

# Create a cluster that has Terway installed. 
# Enable the IPVLAN mode and enable Kubernetes network policies. 
resource "alicloud_cs_managed_kubernetes" "default" {
  name                         = var.name
  cluster_spec                 = "ack.pro.small"
  is_enterprise_security_group = true
  service_cidr                 = "172.21.0.0/20"
  pod_vswitch_ids              = ["var.vswitch_id"]
  worker_vswitch_ids           = ["var.vswitch_id"]

  addons {
    name   =  "terway-eniip"
    config = "{\"IPVlan\":\"true\",\"NetworkPolicy\":\"true\"}"
  }
}

例3: Terway、CSI、およびnginx-ingress-controllerアドオンのインストール

# A template for installing the Terway, CSI, and nginx-ingress-controller add-ons. 

resource "alicloud_cs_managed_kubernetes" "default" {
  name                         = var.name
  cluster_spec                 = "ack.pro.small"
  is_enterprise_security_group = true
  service_cidr                 = "172.21.0.0/20"
  pod_vswitch_ids              = ["var.vswitch_id"]
  worker_vswitch_ids           = ["var.vswitch_id"]

  addons {
    name = "terway-eniip",
    config = "{\"IPVlan\":\"true\",\"NetworkPolicy\":\"false\"}"
  }
  addons {
    name = "csi-plugin"
  }
  addons {
    name = "csi-provisioner"
  }
  addons {
    name = "storage-operator"
    config = "{\"CnfsOssEnable\":\"false\",\"CnfsNasEnable\":\"true\"}"
  }
  addons {
    name = "logtail-ds"
    config = "{\"IngressDashboardEnabled\":\"true\"}"
  }
  addons {
    name = "ack-node-problem-detector"
    config = "{\"sls_project_name\":\"\"}"
  }
  addons {
    name = "nginx-ingress-controller"
    config = "{\"IngressSlbNetworkType\":\"internet\",\"IngressSlbSpec\":\"slb.s2.small\"}"
  }
  addons {
    name = "ack-node-local-dns"
  }
  addons {
    name = "arms-prometheus"
  }
  addons {
    name = "alicloud-monitor-controller"
    config = "{\"group_contact_ids\":\"[10619]\"}"
  }
}