@@ -112,6 +112,101 @@ import (
112112 "github.com/tencentcloudstack/terraform-provider-tencentcloud/tencentcloud/ratelimit"
113113)
114114
115+ func TKEGpuArgsSetting () map [string ]* schema.Schema {
116+ return map [string ]* schema.Schema {
117+ "mig_enable" : {
118+ Type : schema .TypeBool ,
119+ Optional : true ,
120+ Default : false ,
121+ Description : "Whether to enable MIG." ,
122+ },
123+ "driver" : {
124+ Type : schema .TypeMap ,
125+ Optional : true ,
126+ ValidateFunc : validateTkeGpuDriverVersion ,
127+ Elem : & schema.Resource {
128+ Schema : map [string ]* schema.Schema {
129+ "version" : {
130+ Type : schema .TypeString ,
131+ Required : true ,
132+ Description : "Version of GPU driver or CUDA." ,
133+ },
134+ "name" : {
135+ Type : schema .TypeString ,
136+ Required : true ,
137+ Description : "Name of GPU driver or CUDA." ,
138+ },
139+ },
140+ },
141+ Description : "GPU driver version." ,
142+ },
143+ "cuda" : {
144+ Type : schema .TypeMap ,
145+ Optional : true ,
146+ ValidateFunc : validateTkeGpuDriverVersion ,
147+ Elem : & schema.Resource {
148+ Schema : map [string ]* schema.Schema {
149+ "version" : {
150+ Type : schema .TypeString ,
151+ Required : true ,
152+ Description : "Version of GPU driver or CUDA." ,
153+ },
154+ "name" : {
155+ Type : schema .TypeString ,
156+ Required : true ,
157+ Description : "Name of GPU driver or CUDA." ,
158+ },
159+ },
160+ },
161+ Description : "CUDA version." ,
162+ },
163+ "cudnn" : {
164+ Type : schema .TypeMap ,
165+ Optional : true ,
166+ ValidateFunc : validateTkeGpuDriverVersion ,
167+ Elem : & schema.Resource {
168+ Schema : map [string ]* schema.Schema {
169+ "version" : {
170+ Type : schema .TypeString ,
171+ Required : true ,
172+ Description : "cuDNN version." ,
173+ },
174+ "name" : {
175+ Type : schema .TypeString ,
176+ Required : true ,
177+ Description : "cuDNN name." ,
178+ },
179+ "doc_name" : {
180+ Type : schema .TypeString ,
181+ Optional : true ,
182+ Description : "Doc name of cuDNN." ,
183+ },
184+ "dev_name" : {
185+ Type : schema .TypeString ,
186+ Optional : true ,
187+ Description : "Dev name of cuDNN." ,
188+ },
189+ },
190+ },
191+ Description : "cuDNN version." ,
192+ },
193+ "custom_driver" : {
194+ Type : schema .TypeMap ,
195+ Optional : true ,
196+ Elem : & schema.Resource {
197+ Schema : map [string ]* schema.Schema {
198+ "address" : {
199+ Type : schema .TypeString ,
200+ Optional : true ,
201+ Description : "URL of custom GPU driver address." ,
202+ },
203+ },
204+ },
205+ Description : "Custom GPU driver." ,
206+ },
207+ }
208+ }
209+
115210func TkeInstanceAdvancedSetting () map [string ]* schema.Schema {
116211 return map [string ]* schema.Schema {
117212 "mount_target" : {
@@ -206,6 +301,16 @@ func TkeInstanceAdvancedSetting() map[string]*schema.Schema {
206301 Optional : true ,
207302 Description : "Indicate to set desired pod number in node. valid when the cluster is podCIDR." ,
208303 },
304+ "gpu_args" : {
305+ Type : schema .TypeList ,
306+ Optional : true ,
307+ ForceNew : true ,
308+ MaxItems : 1 ,
309+ Elem : & schema.Resource {
310+ Schema : TKEGpuArgsSetting (),
311+ },
312+ Description : "GPU driver parameters." ,
313+ },
209314 }
210315}
211316
@@ -363,6 +468,47 @@ func tkeGetInstanceAdvancedPara(dMap map[string]interface{}, meta interface{}) (
363468 setting .ExtraArgs = & clusterExtraArgs
364469 }
365470
471+ // get gpu_args
472+ if v , ok := dMap ["gpu_args" ]; ok {
473+ gpuArgs := v .([]interface {})[0 ].(map [string ]interface {})
474+
475+ var (
476+ migEnable = gpuArgs ["mig_enable" ].(bool )
477+ driver = gpuArgs ["driver" ].(map [string ]interface {})
478+ cuda = gpuArgs ["cuda" ].(map [string ]interface {})
479+ cudnn = gpuArgs ["cudnn" ].(map [string ]interface {})
480+ customDriver = gpuArgs ["custom_driver" ].(map [string ]interface {})
481+ )
482+ tkeGpuArgs := tke.GPUArgs {}
483+ tkeGpuArgs .MIGEnable = & migEnable
484+ if driver != nil && len (driver ) > 0 {
485+ tkeGpuArgs .Driver = & tke.DriverVersion {
486+ Version : helper .String (driver ["version" ].(string )),
487+ Name : helper .String (driver ["name" ].(string )),
488+ }
489+ }
490+ if cuda != nil && len (cuda ) > 0 {
491+ tkeGpuArgs .CUDA = & tke.DriverVersion {
492+ Version : helper .String (cuda ["version" ].(string )),
493+ Name : helper .String (cuda ["name" ].(string )),
494+ }
495+ }
496+ if cudnn != nil && len (cudnn ) > 0 {
497+ tkeGpuArgs .CUDNN = & tke.CUDNN {
498+ Version : helper .String (cudnn ["version" ].(string )),
499+ Name : helper .String (cudnn ["name" ].(string )),
500+ DocName : helper .String (cudnn ["doc_name" ].(string )),
501+ DevName : helper .String (cudnn ["dev_name" ].(string )),
502+ }
503+ }
504+ if customDriver != nil && len (customDriver ) > 0 {
505+ tkeGpuArgs .CustomDriver = & tke.CustomDriver {
506+ Address : helper .String (customDriver ["address" ].(string )),
507+ }
508+ }
509+ setting .GPUArgs = & tkeGpuArgs
510+ }
511+
366512 return setting
367513}
368514func resourceTencentCloudTkeClusterAttachmentRead (d * schema.ResourceData , meta interface {}) error {
0 commit comments