Skip to content

Commit

Permalink
Merge pull request #88 from volcengine/feat/vkeUpdate
Browse files Browse the repository at this point in the history
Feat/vke update
  • Loading branch information
xuyaming0800 authored May 12, 2023
2 parents 33cd2b1 + 4b8f214 commit 10f06fb
Show file tree
Hide file tree
Showing 16 changed files with 349 additions and 37 deletions.
2 changes: 1 addition & 1 deletion common/common_volcengine_version.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ package common

const (
TerraformProviderName = "terraform-provider-volcengine"
TerraformProviderVersion = "0.0.72"
TerraformProviderVersion = "0.0.73"
)
24 changes: 16 additions & 8 deletions example/vkeCluster/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ resource "volcengine_vke_cluster" "foo" {
description = "created by terraform"
delete_protection_enabled = false
cluster_config {
subnet_ids = ["subnet-2bzud0pbor8qo2dx0ee884y6h"]
subnet_ids = ["subnet-rrqvkt2nq1hcv0x57ccqf3x"]
api_server_public_access_enabled = true
api_server_public_access_config {
public_access_network_config {
Expand All @@ -14,20 +14,28 @@ resource "volcengine_vke_cluster" "foo" {
resource_public_access_default_enabled = true
}
pods_config {
pod_network_mode = "Flannel"
flannel_config {
pod_cidrs = ["172.27.224.0/19"]
max_pods_per_node = 64
}
pod_network_mode = "VpcCniShared"
# flannel_config {
# pod_cidrs = ["172.27.224.0/19"]
# max_pods_per_node = 64
# }
vpc_cni_config {
subnet_ids = ["subnet-2bzud0pbor8qo2dx0ee884y6h"]
subnet_ids = ["subnet-rrqvkt2nq1hcv0x57ccqf3x", "subnet-miklcqh75vcw5smt1amo4ik5", "subnet-13g0x0ytpm0hs3n6nu5j591lv"]
}
}
services_config {
service_cidrsv4 = ["192.168.0.0/16"]
service_cidrsv4 = ["172.30.0.0/18"]
}
tags {
key = "k1"
value = "v1"
}
logging_config {
//log_project_id = "3189316d-a1ee-4892-a8fc-9a566489d590"
log_setups {
enabled = false
log_ttl = 30
log_type = "Audit"
}
}
}
14 changes: 9 additions & 5 deletions example/vkeNodePool/main.tf
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
resource "volcengine_vke_node_pool" "vke_test" {
cluster_id = "ccc2umdnqtoflv91lqtq0"
cluster_id = "ccgd6066rsfegs2dkhlog"
name = "tf-test"
node_config {
instance_type_ids = ["ecs.r1.large"]
subnet_ids = ["subnet-3reyr9ld3obnk5zsk2iqb1kk3"]
instance_type_ids = ["ecs.g1ie.xlarge"]
subnet_ids = ["subnet-mj1e9jgu96v45smt1a674x3h"]
security {
login {
# ssh_key_pair_name = "ssh-6fbl66fxqm"
password = "UHdkMTIzNDU2"
}
security_group_ids = ["sg-2bz8cga08u48w2dx0eeym1fzy", "sg-2d6t6djr2wge858ozfczv41xq"]
security_group_ids = ["sg-13fbyz0sok3y83n6nu4hv1q10", "sg-mj1e9tbztgqo5smt1ah8l4bh"]
}
data_volumes {
type = "ESSD_PL0"
size = "60"
}
instance_charge_type = "PrePaid"
instance_charge_type = "PostPaid"
period = 1
ecs_tags {
key = "ecs_k1"
Expand All @@ -37,4 +37,8 @@ resource "volcengine_vke_node_pool" "vke_test" {
key = "k1"
value = "v1"
}
auto_scaling {
enabled = true
subnet_policy = "ZoneBalance"
}
}
20 changes: 20 additions & 0 deletions volcengine/tos/bucket/resource_volcengine_tos_bucket.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,26 @@ func ResourceVolcengineTosBucket() *schema.Resource {
},
Set: ve.TosAccountAclHash,
},
"creation_date": {
Type: schema.TypeString,
Computed: true,
Description: "The create date of the TOS bucket.",
},
"location": {
Type: schema.TypeString,
Computed: true,
Description: "The location of the TOS bucket.",
},
"extranet_endpoint": {
Type: schema.TypeString,
Computed: true,
Description: "The extranet endpoint of the TOS bucket.",
},
"intranet_endpoint": {
Type: schema.TypeString,
Computed: true,
Description: "The intranet endpoint the TOS bucket.",
},
},
}
return resource
Expand Down
27 changes: 26 additions & 1 deletion volcengine/tos/bucket/service_volcengine_tos_bucket.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ func (s *VolcengineTosBucketService) ReadResource(resourceData *schema.ResourceD
header http.Header
acl map[string]interface{}
version map[string]interface{}
buckets []interface{}
)

if instanceId == "" {
Expand All @@ -76,7 +77,31 @@ func (s *VolcengineTosBucketService) ReadResource(resourceData *schema.ResourceD
if err != nil {
return data, err
}
data = make(map[string]interface{})

buckets, err = s.ReadResources(nil)
if err != nil {
return data, err
}
var (
local interface{}
name interface{}
)
for _, bucket := range buckets {
local, err = ve.ObtainSdkValue("Location", bucket)
if err != nil {
return data, err
}
name, err = ve.ObtainSdkValue("Name", bucket)
if err != nil {
return data, err
}
if local.(string) == s.Client.Region && name.(string) == instanceId {
data = bucket.(map[string]interface{})
}
}
if data == nil {
data = make(map[string]interface{})
}

if header, ok = (*resp)[ve.TosHeader].(http.Header); ok {
if header.Get("X-Tos-Storage-Class") != "" {
Expand Down
38 changes: 38 additions & 0 deletions volcengine/vke/cluster/data_source_volcengine_vke_clusters.go
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,44 @@ func DataSourceVolcengineVkeVkeClusters() *schema.Resource {
},
},
},
"logging_config": {
Type: schema.TypeList,
Computed: true,
Description: "Cluster log configuration information.",
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"log_project_id": {
Type: schema.TypeString,
Computed: true,
Description: "The TLS log item ID of the collection target.",
},
"log_setups": {
Type: schema.TypeList,
Computed: true,
Description: "Cluster logging options.",
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"log_type": {
Type: schema.TypeString,
Computed: true,
Description: "The currently enabled log type, optional values: `Audit`.",
},
"log_ttl": {
Type: schema.TypeInt,
Computed: true,
Description: "The storage time of logs in Log Service. After the specified log storage time is exceeded, the expired logs in this log topic will be automatically cleared. The unit is days, and the default is 30 days. The value range is 1 to 3650, specifying 3650 days means permanent storage.",
},
"enabled": {
Type: schema.TypeBool,
Computed: true,
Description: "Whether to enable the log option, true means enable, false means not enable, the default is false. When Enabled is changed from false to true, a new Topic will be created.",
},
},
},
},
},
},
},
},
},
},
Expand Down
63 changes: 59 additions & 4 deletions volcengine/vke/cluster/resource_volcengine_vke_cluster.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package cluster

import (
"bytes"
"fmt"
"strings"
"time"

"github.com/hashicorp/terraform-plugin-sdk/helper/hashcode"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/helper/validation"
ve "github.com/volcengine/terraform-provider-volcengine/common"
Expand Down Expand Up @@ -137,7 +139,6 @@ func ResourceVolcengineVkeCluster() *schema.Resource {
Type: schema.TypeList,
MaxItems: 1,
Required: true,
ForceNew: true,
Description: "The config of the pods.",
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
Expand All @@ -151,8 +152,8 @@ func ResourceVolcengineVkeCluster() *schema.Resource {
"flannel_config": {
Type: schema.TypeList,
MaxItems: 1,
Optional: true,
ForceNew: true,
Optional: true,
Description: "Flannel network configuration.",
DiffSuppressFunc: FlannelFieldDiffSuppress,
Elem: &schema.Resource{
Expand Down Expand Up @@ -180,7 +181,6 @@ func ResourceVolcengineVkeCluster() *schema.Resource {
Type: schema.TypeList,
MaxItems: 1,
Optional: true,
ForceNew: true,
Description: "VPC-CNI network configuration.",
DiffSuppressFunc: VpcCniConfigFieldDiffSuppress,
Elem: &schema.Resource{
Expand All @@ -197,7 +197,6 @@ func ResourceVolcengineVkeCluster() *schema.Resource {
"subnet_ids": {
Type: schema.TypeSet,
Optional: true,
ForceNew: true,
Elem: &schema.Schema{
Type: schema.TypeString,
},
Expand Down Expand Up @@ -246,6 +245,50 @@ func ResourceVolcengineVkeCluster() *schema.Resource {
Computed: true,
Description: "Eip allocation Id.",
},
"logging_config": {
Type: schema.TypeList,
MaxItems: 1,
Optional: true,
Description: "Cluster log configuration information.",
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"log_project_id": {
Type: schema.TypeString,
Optional: true,
Computed: true,
Description: "The TLS log item ID of the collection target.",
},
"log_setups": {
Type: schema.TypeSet,
Optional: true,
Set: logSetupsHash,
Description: "Cluster logging options. This structure can only be modified and added, and cannot be deleted.",
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"log_type": {
Type: schema.TypeString,
Required: true,
Description: "The currently enabled log type.",
},
"log_ttl": {
Type: schema.TypeInt,
Optional: true,
Default: 30,
ValidateFunc: validation.IntBetween(1, 3650),
Description: "The storage time of logs in Log Service. After the specified log storage time is exceeded, the expired logs in this log topic will be automatically cleared. The unit is days, and the default is 30 days. The value range is 1 to 3650, specifying 3650 days means permanent storage.",
},
"enabled": {
Type: schema.TypeBool,
Optional: true,
Default: false,
Description: "Whether to enable the log option, true means enable, false means not enable, the default is false. When Enabled is changed from false to true, a new Topic will be created.",
},
},
},
},
},
},
},
},
}
}
Expand Down Expand Up @@ -285,3 +328,15 @@ func resourceVolcengineVkeClusterDelete(d *schema.ResourceData, meta interface{}
}
return err
}

func logSetupsHash(i interface{}) int {
if i == nil {
return hashcode.String("")
}
m := i.(map[string]interface{})
var (
buf bytes.Buffer
)
buf.WriteString(fmt.Sprintf("%v#%v#%v", m["log_type"], m["log_ttl"], m["enabled"]))
return hashcode.String(buf.String())
}
Loading

0 comments on commit 10f06fb

Please sign in to comment.