このトピックでは、Terraformで作成されたContainer Service for Kubernetes (ACK) クラスターを削除する方法と、必要なリソースを保持するためのオプションについて説明します。
前提条件
Terraformで次のいずれかのクラスターが作成されました。
ACK管理クラスター。 詳細については、「Terraformを使用したACK管理クラスターの作成」をご参照ください。
ACK専用クラスター。 詳細については、「Terraformを使用したACK専用クラスターの作成」をご参照ください。
ACKエッジクラスター。 詳細については、「Terraformを使用したACK Edgeクラスターの作成」をご参照ください。
ACKサーバーレスクラスタ。 詳細については、「Terraformを使用したACKサーバーレスクラスターの作成」をご参照ください。
使用上の注意
Terraformでクラスターを削除する場合、必要に応じてreturn_resourcesを使用してリソースを保持できます。また、delete_optionsを設定してリソースの削除と保持を管理することもできます。
カテゴリ | delete_options | retent_resources |
方法 | 特定のリソースを保持するか削除するかを指定します。 | 保持するリソースを指定します。 |
例: 説明
| 例: リソースインスタンスIDを | |
サポートされるリソース |
|
|
サポートされているクラスタータイプ |
|
|
手順1: リソースの追加管理パラメーター
リソースの削除または保持を制御するために、ACKクラスターに作成されたmain.tfファイルに次のパラメーターを追加します。
resource "alicloud_cs_managed_kubernetes" "default" { # Add location.
...
// Add the resource instance ID to [].
retain_resources = ["ngw-xxxx"]
// Delete SLB resources created by the cluster.
delete_options {
delete_mode = "delete"
resource_type = "SLB"
}
// Delete ALB resources created by the ALB Ingress Controller.
delete_options {
delete_mode = "delete"
resource_type = "ALB"
}
// Delete the Simple Log Service projects used by the cluster logging feature.
delete_options {
delete_mode = "delete"
resource_type = "SLS_Data"
}
// Delete the Simple Log Service projects used by the managed cluster control plane.
delete_options {
delete_mode = "delete"
resource_type = "SLS_ControlPlane"
}
}次のコマンドを実行して変更を適用します。
terraform apply手順2: クラスターの削除
Terraformが作成したクラスターを削除するには、次の手順を実行します。
terraform destroyコマンドは、Terraformによって管理されているすべてのリソースを削除します。 先に進む前に、重要なデータとリソースをバックアップすることが重要です。
次のコマンドを実行して、Terraformが作成したクラスターを削除します。
terraform destroy次の情報が返される場合は、yesと入力し、Enterキーを押します。 その後、クラスターは削除されます。
... Do you really want to destroy all resources? Terraform will destroy all your managed infrastructure, as shown above. There is no undo. Only 'yes' will be accepted to confirm. Enter a value: yes ... Destroy complete! Resources: 7 destroyed.