135. 如何通过 Rancher2 Terraform Provider 升级由 Rancher 管理的 k3s 集群
How to use the Rancher2 Terraform Provider to update an existing downstream cluster managed by Rancher.如何使用 Rancher2 Terraform Provider 来更新由 Rancher 管理的现有下游集群。Resolution 结局To do this import the k3s cluster into the Terraform configuration, then upgrade the cluster via Terraform.要做到这一点可以将 k3s 集群导入 Terraform 配置然后通过 Terraform 升级集群。Firstly, with the Rancher2 Terraform Provider configured (https://registry.terraform.io/providers/rancher/rancher2/latest/docs), define a rancher2_cluster resource for your k3s cluster, per the following example:首先在配置好 Rancher2 Terraform Providerhttps://registry.terraform.io/providers/rancher/rancher2/latest/docs后 按照以下示例为你的 k3s 集群定义一个 rancher2_cluster 资源span stylecolor:#000000span stylebackground-color:#ffffffspan stylebackground-color:#f3f3f3resource rancher2_cluster k3s { name k3s }/span/span/spanThen use the terraform import command to import the k3s cluster into your Terraform configuration (https://registry.terraform.io/providers/rancher/rancher2/latest/docs/resources/cluster#import), e.g.:然后使用“terraform import”命令将 k3s 集群导入你的 Terraform 配置https://registry.terraform.io/providers/rancher/rancher2/latest/docs/resources/cluster#import例如span stylecolor:#000000span stylebackground-color:#ffffffspan stylebackground-color:#f3f3f3terraform import rancher2_cluster.k3s c-m-h6xkkkvs/span/span/spanFinally with the cluster imported, set the Kubernetes version in the k3s_config block to upgrade the cluster via a terraform apply operation, e.g.:最后在导入集群后在 k3s_config 块中设置 Kubernetes 版本通过“terraform 应用”操作升级集群例如span stylecolor:#000000span stylebackground-color:#ffffffspan stylebackground-color:#f3f3f3resource rancher2_cluster k3s { name k3s k3s_config { version v1.23.7k3s1 } }/span/span/span访问Rancher-K8S解决方案博主企业合作伙伴 https://blog.csdn.net/lidw2009