Skip to content

Commit

Permalink
Add kubeProxyMode and taints params
Browse files Browse the repository at this point in the history
  • Loading branch information
yangshuai committed Jul 28, 2020
1 parent 4160b09 commit 3ee0538
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 4 deletions.
13 changes: 11 additions & 2 deletions huaweicloud/resource_huaweicloud_cce_cluster_v3.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,10 @@ func resourceCCEClusterV3() *schema.Resource {
ForceNew: true,
ValidateFunc: validateIP,
},
"kube_proxy_mode": {
Type: schema.TypeString,
Optional: true,
},
"status": {
Type: schema.TypeString,
Computed: true,
Expand Down Expand Up @@ -200,6 +204,9 @@ func resourceClusterExtendParamV3(d *schema.ResourceData) map[string]string {
if multi_az, ok := d.GetOk("multi_az"); ok && multi_az == true {
m["clusterAZ"] = "multi_az"
}
if kube_proxy_mode, ok := d.GetOk("kube_proxy_mode"); ok{
m["kubeProxyMode"] = kube_proxy_mode.(string)
}
if eip, ok := d.GetOk("eip"); ok {
m["clusterExternalIP"] = eip.(string)
}
Expand All @@ -214,6 +221,7 @@ func resourceCCEClusterV3Create(d *schema.ResourceData, meta interface{}) error
return fmt.Errorf("Unable to create HuaweiCloud CCE client : %s", err)
}


authenticating_proxy := make(map[string]string)
if hasFilledOpt(d, "authenticating_proxy_ca") {
authenticating_proxy["ca"] = d.Get("authenticating_proxy_ca").(string)
Expand All @@ -236,8 +244,9 @@ func resourceCCEClusterV3Create(d *schema.ResourceData, meta interface{}) error
Cidr: d.Get("container_network_cidr").(string)},
Authentication: clusters.AuthenticationSpec{Mode: d.Get("authentication_mode").(string),
AuthenticatingProxy: authenticating_proxy},
BillingMode: d.Get("billing_mode").(int),
ExtendParam: resourceClusterExtendParamV3(d),
BillingMode: d.Get("billing_mode").(int),
ExtendParam: resourceClusterExtendParamV3(d),
//KubeProxyMode: d.Get("kube_proxy_mode").(string),
},
}

Expand Down
47 changes: 46 additions & 1 deletion huaweicloud/resource_huaweicloud_cce_node_v3.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,26 @@ func resourceCCENodeV3() *schema.Resource {
},
}},
},
"taints": {
Type: schema.TypeList,
Optional: true,
ForceNew: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"key": {
Type: schema.TypeString,
Required: true,
},
"value": {
Type: schema.TypeString,
Required: true,
},
"effect": {
Type: schema.TypeString,
Required: true,
},
}},
},
"eip_ids": {
Type: schema.TypeSet,
Optional: true,
Expand Down Expand Up @@ -277,6 +297,19 @@ func resourceCCEDataVolume(d *schema.ResourceData) []nodes.VolumeSpec {
}
return volumes
}
func resourceCCETaint(d *schema.ResourceData) []nodes.TaintSpec {
taintRaw := d.Get("taints").([]interface{})
taints := make([]nodes.TaintSpec, len(taintRaw))
for i, raw := range taintRaw {
rawMap := raw.(map[string]interface{})
taints[i] = nodes.TaintSpec{
Key: rawMap["key"].(string),
Value: rawMap["value"].(string),
Effect: rawMap["effect"].(string),
}
}
return taints
}
func resourceCCERootVolume(d *schema.ResourceData) nodes.VolumeSpec {
var nics nodes.VolumeSpec
nicsRaw := d.Get("root_volume").([]interface{})
Expand Down Expand Up @@ -378,6 +411,7 @@ func resourceCCENodeV3Create(d *schema.ResourceData, meta interface{}) error {
PreInstall: base64PreInstall,
PostInstall: base64PostInstall,
},
Taints: resourceCCETaint(d),
},
}

Expand Down Expand Up @@ -490,11 +524,22 @@ func resourceCCENodeV3Read(d *schema.ResourceData, meta interface{}) error {
"extend_param": s.Spec.RootVolume.ExtendParam,
},
}
d.Set("root_volume", rootVolume)
if err := d.Set("root_volume", rootVolume); err != nil {
return fmt.Errorf("[DEBUG] Error saving root Volume to state for HuaweiCloud Node (%s): %s", d.Id(), err)
}

var tains []map[string]interface{}
for _, pairObject := range s.Spec.Taints {
tain := make(map[string]interface{})
tain["key"] = pairObject.Key
tain["value"] = pairObject.Value
tain["effect"] = pairObject.Effect
tains = append(tains, tain)
}
if err := d.Set("tains", tains); err != nil {
return fmt.Errorf("[DEBUG] Error saving root Volume to state for HuaweiCloud Node (%s): %s", d.Id(), err)
}

// set computed attributes
d.Set("private_ip", s.Status.PrivateIP)
d.Set("public_ip", s.Status.PublicIP)
Expand Down
7 changes: 6 additions & 1 deletion website/docs/r/cce_cluster_v3.html.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ versions are available, choose Dashboard > Buy Cluster on the CCE console. Chang

* `subnet_id` - (Required) The ID of the subnet used to create the node. Changing this parameter will create a new cluster resource.

* `highway_subnet_id` - (Optional) The ID of the high speed network used to create bare metal nodes. Changing this parameter will create a new cluster resource.
* `highway_subnet_id` - (Optional) The ID of the high speed network used to create bare metal nodes. Changing this parameter will create a new cluster resource.

* `container_network_type` - (Required) Container network parameters. Possible values:

Expand All @@ -84,6 +84,11 @@ versions are available, choose Dashboard > Buy Cluster on the CCE console. Chang

* `eip` - (Optional) EIP address of the cluster. Changing this parameter will create a new cluster resource.

* `kube_proxy_mode` - (Optional) Service forwarding mode. Two modes are available:

- iptables: Traditional kube-proxy uses iptables rules to implement service load balancing. In this mode, too many iptables rules will be generated when many services are deployed. In addition, non-incremental updates will cause a latency and even obvious performance issues in the case of heavy service traffic.
- ipvs: Optimized kube-proxy mode with higher throughput and faster speed. This mode supports incremental updates and can keep connections uninterrupted during service updates. It is suitable for large-sized clusters.

## Attributes Reference

All above argument parameters can be exported as attribute parameters along with attribute reference.
Expand Down
15 changes: 15 additions & 0 deletions website/docs/r/cce_node_v3.html.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ resource "huaweicloud_cce_node_v3" "node_1" {
size = 100
volumetype = "SATA"
}
taints {
key = "looks"
value = "bad"
effect = "NoSchedule"
}
iptype = "5_bgp"
sharetype = "PER"
Expand Down Expand Up @@ -99,6 +104,16 @@ If the eip_id parameter is configured, you do not need to configure the bandwidt
* `volumetype` - (Required) Disk type.

* `extend_param` - (Optional) Disk expansion parameters.

**taints** **- (Optional)** Represents the data disk to be created. Changing this parameter will create a new resource.

* `key` - (Required) A key must contain 1 to 63 characters starting with a letter or digit. Only letters, digits, hyphens (-),
underscores (_), and periods (.) are allowed. A DNS subdomain name can be used as the prefix of a key.

* `value` - (Required) A value must start with a letter or digit and can contain a maximum of 63 characters, including letters,
digits, hyphens (-), underscores (_), and periods (.).

* `effect` - (Required) Available options are NoSchedule, PreferNoSchedule, and NoExecute.

## Attributes Reference

Expand Down

0 comments on commit 3ee0538

Please sign in to comment.