Skip to content

Commit

Permalink
add eni to cce
Browse files Browse the repository at this point in the history
  • Loading branch information
vladimirvshivkov committed Apr 12, 2022
1 parent 5660ddc commit bde4316
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 0 deletions.
4 changes: 4 additions & 0 deletions docs/data-sources/cce_cluster_v3.md
Expand Up @@ -49,6 +49,10 @@ All above argument parameters can be exported as attribute parameters along with

* `container_network_type` - The container network type: overlay_l2 , underlay_ipvlan or vpc-router.

* `eni_subnet_id` - ENI subnet ID. Specified when creating a CCE Turbo cluster.

* `eni_subnet_cidr` - ENI network segment. Specified when creating a CCE Turbo cluster.

* `authentication_mode` - (Optional) Authentication mode of the cluster, possible values are `rbac` and `authenticating_proxy`.

* `subnet_id` - The ID of the subnet used to create the node.
Expand Down
4 changes: 4 additions & 0 deletions docs/resources/cce_cluster_v3.md
Expand Up @@ -120,6 +120,10 @@ The following arguments are supported:

* `container_network_cidr` - (Optional) Container network segment. Changing this parameter will create a new cluster resource.

* `eni_subnet_id` - The ENI subnet ID.

* `eni_subnet_cidr` - The ENI network segment.

* `authentication_mode` - (Optional) Authentication mode of the cluster, possible values are `rbac` and `authenticating_proxy`.
Defaults to `rbac`. Changing this parameter will create a new cluster resource.

Expand Down
Expand Up @@ -68,6 +68,14 @@ func DataSourceCCEClusterV3() *schema.Resource {
Type: schema.TypeString,
Computed: true,
},
"eni_subnet_id": {
Type: schema.TypeString,
Computed: true,
},
"eni_subnet_cidr": {
Type: schema.TypeString,
Computed: true,
},
"authentication_mode": {
Type: schema.TypeString,
Computed: true,
Expand Down Expand Up @@ -182,6 +190,8 @@ func dataSourceCCEClusterV3Read(_ context.Context, d *schema.ResourceData, meta
d.Set("highway_subnet_id", cluster.Spec.HostNetwork.HighwaySubnet),
d.Set("container_network_cidr", cluster.Spec.ContainerNetwork.Cidr),
d.Set("container_network_type", cluster.Spec.ContainerNetwork.Mode),
d.Set("eni_subnet_id", cluster.Spec.EniNetwork.SubnetId),
d.Set("eni_subnet_cidr", cluster.Spec.EniNetwork.Cidr),
d.Set("authentication_mode", cluster.Spec.Authentication.Mode),
d.Set("status", cluster.Status.Phase),
d.Set("internal", cluster.Status.Endpoints[0].Internal),
Expand Down
Expand Up @@ -140,6 +140,20 @@ func ResourceCCEClusterV3() *schema.Resource {
Computed: true,
ForceNew: true,
},
"eni_subnet_id": {
Type: schema.TypeString,
Optional: true,
ForceNew: true,
Computed: true,
RequiredWith: []string{"eni_subnet_cidr"},
},
"eni_subnet_cidr": {
Type: schema.TypeString,
Optional: true,
ForceNew: true,
Computed: true,
RequiredWith: []string{"eni_subnet_id"},
},
"authentication_mode": {
Type: schema.TypeString,
Optional: true,
Expand Down Expand Up @@ -368,6 +382,14 @@ func resourceCCEClusterV3Create(ctx context.Context, d *schema.ResourceData, met
},
}

if _, ok := d.GetOk("eni_subnet_id"); ok {
eniNetwork := clusters.EniNetworkSpec{
SubnetId: d.Get("eni_subnet_id").(string),
Cidr: d.Get("eni_subnet_cidr").(string),
}
createOpts.Spec.EniNetwork = eniNetwork
}

create, err := clusters.Create(cceClient, createOpts).Extract()

if err != nil {
Expand Down Expand Up @@ -446,6 +468,8 @@ func resourceCCEClusterV3Read(_ context.Context, d *schema.ResourceData, meta in
d.Set("highway_subnet_id", cluster.Spec.HostNetwork.HighwaySubnet),
d.Set("container_network_type", cluster.Spec.ContainerNetwork.Mode),
d.Set("container_network_cidr", cluster.Spec.ContainerNetwork.Cidr),
d.Set("eni_subnet_id", cluster.Spec.EniNetwork.SubnetId),
d.Set("eni_subnet_cidr", cluster.Spec.EniNetwork.Cidr),
d.Set("authentication_mode", cluster.Spec.Authentication.Mode),
d.Set("kubernetes_svc_ip_range", cluster.Spec.KubernetesSvcIpRange),
d.Set("kube_proxy_mode", cluster.Spec.KubeProxyMode),
Expand Down

0 comments on commit bde4316

Please sign in to comment.