Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement FKE & FDE #15

Merged
merged 34 commits into from
Oct 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
43a26cb
Implement muxing & add DFKE support
ducvm29 Jul 31, 2024
0777307
Add managed FKE implementation
ducvm29 Aug 19, 2024
a24e0c8
Add dedicated FKE update routes
ducvm29 Aug 20, 2024
c65576c
Various managed FKE schema changes
ducvm29 Aug 20, 2024
67ef978
Merge branch 'develop' into dedicated-fke
ducvm29 Aug 21, 2024
2123eb7
Implement backoff, state check between updates & regionId checking
ducvm29 Sep 5, 2024
81b8405
Refactor DFKE & fix cluster creation
ducvm29 Sep 5, 2024
2e79156
Add DFKE examples
ducvm29 Sep 5, 2024
7edd991
Fix MFKE routing
ducvm29 Sep 6, 2024
5952bfe
Fix MFKE updating
ducvm29 Sep 9, 2024
34cccb3
Refactor subnet resolution
ducvm29 Sep 9, 2024
b3c9e30
Validate MFKE pool names
ducvm29 Sep 9, 2024
ed2b614
Rework logic
ducvm29 Sep 16, 2024
1248843
Merge upstream
ducvm29 Sep 16, 2024
f06769e
Add DFKE data source
ducvm29 Sep 17, 2024
91ab11c
Implement MFKE data source
ducvm29 Sep 17, 2024
c5ffc14
Add descriptions
ducvm29 Sep 26, 2024
8118bc5
Use subnet service for MFKE
ducvm29 Sep 26, 2024
0a891fe
Add docs
ducvm29 Sep 26, 2024
04de360
feat: add network id to subnet schema
ducdm49 Sep 30, 2024
1530dce
Merge branch 'master' of github.com:fpt-corp/terraform-provider-fptcl…
ducdm49 Sep 30, 2024
66ba65d
Merge remote-tracking branch 'github/feature/add_network_id_to_subnet…
ducvm29 Oct 1, 2024
1ac0591
Fix datasource
ducvm29 Oct 1, 2024
08f7873
feat: add edge gateway data source
thainh20 Oct 1, 2024
a8f1ff5
feat: add database and database status resource
thainh20 Oct 2, 2024
70bae72
Implement OSP support
ducvm29 Oct 2, 2024
3b1f9ff
Merge remote-tracking branch 'github/feat/fke' into dedicated-fke
ducvm29 Oct 2, 2024
fccf395
Custom network ID logic
ducvm29 Oct 3, 2024
c652736
fix: delete database and edge gateway helper service
thainh20 Oct 3, 2024
86b8755
Fix lint
ducvm29 Oct 3, 2024
4623478
Merge branch 'master' of https://github.com/fpt-corp/terraform-provid…
ducvm29 Oct 4, 2024
cd3d25c
Refactor code
ducvm29 Oct 7, 2024
c316d65
Remove TODOs & refactor MFKE
ducvm29 Oct 7, 2024
8c1d649
Refactor network & validation logic
ducvm29 Oct 7, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 80 additions & 0 deletions commons/api_path.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,26 @@ var ApiPath = struct {
FindSubnetByName func(vpcId string) string
FindSubnet func(vpcId string, subnetId string) string
ListSubnets func(vpcId string) string

Subnet func(vpcId string) string
EdgeGatewayList func(vpcId string) string

DatabaseGet func(databaseId string) string
DatabaseCreate func() string
DatabaseDelete func(databaseId string) string
DatabaseStop func() string
DatabaseStart func() string

DedicatedFKEList func(vpcId string, page, pageSize int) string
DedicatedFKEGet func(vpcId string, clusterId string) string
DedicatedFKEUpgradeVersion func(vpcId string, clusterId string) string
DedicatedFKEManagement func(vpcId string, clusterId string) string

ManagedFKEList func(vpcId string, page int, pageSize int, infraType string) string
ManagedFKEGet func(vpcId string, platform string, clusterId string) string
ManagedFKEDelete func(vpcId string, platform string, clusterName string) string
ManagedFKECreate func(vpcId string, platform string) string
GetFKEOSVersion func(vpcId string, platform string) string
}{
SSH: "/v1/user/sshs",
Storage: func(vpcId string) string {
Expand Down Expand Up @@ -139,4 +159,64 @@ var ApiPath = struct {
ListSubnets: func(vpcId string) string {
return fmt.Sprintf("/v2/vpc/%s/networks", vpcId)
},

Subnet: func(vpcId string) string { return fmt.Sprintf("/v1/vmware/vpc/%s/network/subnets", vpcId) },

EdgeGatewayList: func(vpcId string) string {
return fmt.Sprintf("/v1/vmware/vpc/%s/edge_gateway/list", vpcId)
},

DatabaseGet: func(databaseId string) string {
return fmt.Sprintf("/v1/xplat/database/management/cluster/detail/%s", databaseId)
},
DatabaseCreate: func() string {
return "/v1/xplat/database/provision/create"
},
DatabaseDelete: func(databaseId string) string {
return fmt.Sprintf("/v1/xplat/database/provision/delete/%s", databaseId)
},
DatabaseStop: func() string {
return "/v1/xplat/database/management/cluster/stop"
},
DatabaseStart: func() string {
return "/v1/xplat/database/management/cluster/start"
},

DedicatedFKEList: func(vpcId string, page, pageSize int) string {
return fmt.Sprintf("/v1/xplat/fke/vpc/%s/kubernetes?page=%d&page_size=%d", vpcId, page, pageSize)
},
DedicatedFKEGet: func(vpcId string, clusterId string) string {
return fmt.Sprintf("/v1/xplat/fke/vpc/%s/cluster/%s?page=1&page_size=25", vpcId, clusterId)
},
DedicatedFKEUpgradeVersion: func(vpcId string, clusterId string) string {
return fmt.Sprintf("/v1/xplat/fke/vpc/%s/cluster/%s/upgrade-version", vpcId, clusterId)
},
DedicatedFKEManagement: func(vpcId string, clusterId string) string {
return fmt.Sprintf("/v1/xplat/fke/vpc/%s/kubernetes/%s/management", vpcId, clusterId)
},

ManagedFKEList: func(vpcId string, page int, pageSize int, infraType string) string {
return fmt.Sprintf("/v1/xplat/fke/vpc/%s/m-fke/%s/get-shoot-cluster/shoots?page=%d&page_size=%d", vpcId, infraType, page, pageSize)
},
ManagedFKEDelete: func(vpcId string, platform string, clusterName string) string {
return fmt.Sprintf(
"/v1/xplat/fke/vpc/%s/m-fke/%s/delete-shoot-cluster/shoots/%s",
vpcId, platform, clusterName,
)
},
ManagedFKECreate: func(vpcId string, platform string) string {
return fmt.Sprintf(
"/v1/xplat/fke/vpc/%s/m-fke/%s/create-cluster",
vpcId, platform,
)
},
ManagedFKEGet: func(vpcId string, platform string, clusterId string) string {
return fmt.Sprintf(
"/v1/xplat/fke/vpc/%s/m-fke/%s/get-shoot-specific/shoots/%s",
vpcId, platform, clusterId,
)
},
GetFKEOSVersion: func(vpcId string, platform string) string {
return fmt.Sprintf("/v1/xplat/fke/vpc/%s/m-fke/%s/get_k8s_versions", vpcId, platform)
},
}
24 changes: 12 additions & 12 deletions commons/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,12 @@ func NewClientWithURL(apiKey, apiUrl, region string, tenantName string) (*Client
return client, nil
}

func (c *Client) prepareClientURL(requestURL string) *url.URL {
func (c *Client) PrepareClientURL(requestURL string) *url.URL {
u, _ := url.Parse(c.BaseURL.String() + requestURL)
return u
}

func (c *Client) sendRequest(req *http.Request) ([]byte, error) {
func (c *Client) SendRequest(req *http.Request) ([]byte, error) {
req.Header.Set("Accept", "application/json")
req.Header.Set("User-Agent", c.UserAgent)
req.Header.Set("Content-Type", "application/json")
Expand Down Expand Up @@ -122,18 +122,18 @@ func (c *Client) sendRequest(req *http.Request) ([]byte, error) {

// SendGetRequest sends a correctly authenticated get request to the API server
func (c *Client) SendGetRequest(requestURL string) ([]byte, error) {
u := c.prepareClientURL(requestURL)
u := c.PrepareClientURL(requestURL)
req, err := http.NewRequest("GET", u.String(), nil)
if err != nil {
return nil, err
}

return c.sendRequest(req)
return c.SendRequest(req)
}

// SendPostRequest sends a correctly authenticated post request to the API server
func (c *Client) SendPostRequest(requestURL string, params interface{}) ([]byte, error) {
u := c.prepareClientURL(requestURL)
u := c.PrepareClientURL(requestURL)

// we create a new buffer and encode everything to json to send it in the request
jsonValue, _ := json.Marshal(params)
Expand All @@ -142,12 +142,12 @@ func (c *Client) SendPostRequest(requestURL string, params interface{}) ([]byte,
if err != nil {
return nil, err
}
return c.sendRequest(req)
return c.SendRequest(req)
}

// SendPutRequest sends a correctly authenticated put request to the API server
func (c *Client) SendPutRequest(requestURL string, params interface{}) ([]byte, error) {
u := c.prepareClientURL(requestURL)
u := c.PrepareClientURL(requestURL)

// we create a new buffer and encode everything to json to send it in the request
jsonValue, _ := json.Marshal(params)
Expand All @@ -156,23 +156,23 @@ func (c *Client) SendPutRequest(requestURL string, params interface{}) ([]byte,
if err != nil {
return nil, err
}
return c.sendRequest(req)
return c.SendRequest(req)
}

// SendDeleteRequest sends a correctly authenticated delete request to the API server
func (c *Client) SendDeleteRequest(requestURL string) ([]byte, error) {
u := c.prepareClientURL(requestURL)
u := c.PrepareClientURL(requestURL)
req, err := http.NewRequest("DELETE", u.String(), nil)
if err != nil {
return nil, err
}

return c.sendRequest(req)
return c.SendRequest(req)
}

// SendDeleteRequestWithBody sends a correctly authenticated delete request to the API server
func (c *Client) SendDeleteRequestWithBody(requestURL string, params interface{}) ([]byte, error) {
u := c.prepareClientURL(requestURL)
u := c.PrepareClientURL(requestURL)

// we create a new buffer and encode everything to json to send it in the request
jsonValue, _ := json.Marshal(params)
Expand All @@ -182,7 +182,7 @@ func (c *Client) SendDeleteRequestWithBody(requestURL string, params interface{}
return nil, err
}

return c.sendRequest(req)
return c.SendRequest(req)
}

// SetUserAgent sets the user agent for the client
Expand Down
48 changes: 48 additions & 0 deletions docs/data-sources/dedicated_kubernetes_engine_v1.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "fptcloud_dedicated_kubernetes_engine_v1 Data Source - terraform-provider-fptcloud"
subcategory: ""
description: |-
Retrieves information about dedicated FKE clusters
---

# fptcloud_dedicated_kubernetes_engine_v1 (Data Source)

Retrieves information about dedicated FKE clusters



<!-- schema generated by tfplugindocs -->
## Schema

### Required

- `cluster_id` (String) Cluster ID, as shown on the dashboard, usually has a length of 8 characters
- `vpc_id` (String) VPC ID

### Read-Only

- `cluster_name` (String) Cluster name
- `edge_id` (String) Edge ID
- `id` (String) UUID of the cluster
- `ip_private_firewall` (String) IP private firewall
- `ip_public_firewall` (String) IP public firewall
- `k8s_version` (String) Kubernetes version
- `lb_size` (String) Load balancer size
- `master_count` (Number) Number of master node
- `master_disk_size` (Number) Master node disk capacity in GB
- `master_type` (String) ID of the flavor of master node
- `max_pod_per_node` (Number) Max pods per node
- `network_id` (String) Network UUID
- `network_node_prefix` (Number) Network node prefix
- `nfs_disk_size` (Number) NFS disk size
- `nfs_status` (String) NFS status
- `node_dns` (String) DNS server of nodes
- `pod_network` (String) Pod network in CIDR notation
- `region_id` (String) Region ID
- `scale_max` (Number) Maximum number of nodes for autoscaling
- `scale_min` (Number) Minimum number of nodes for autoscaling
- `service_network` (String) Service network in CIDR notation
- `storage_policy` (String) Storage policy
- `worker_disk_size` (Number) Worker node disk capacity in GB
- `worker_type` (String) ID of the flavor of worker node
26 changes: 26 additions & 0 deletions docs/data-sources/edge_gateway.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "fptcloud_edge_gateway Data Source - terraform-provider-fptcloud"
subcategory: ""
description: |-
Retrieves information about FPT Cloud edge gateway
---

# fptcloud_edge_gateway (Data Source)

Retrieves information about FPT Cloud edge gateway



<!-- schema generated by tfplugindocs -->
## Schema

### Required

- `name` (String) Name of the compute edge_gateway
- `vpc_id` (String) VPC id

### Read-Only

- `edge_gateway_id` (String) Edge gateway id
- `id` (String) Identifier of the edge_gateway
53 changes: 53 additions & 0 deletions docs/data-sources/managed_kubernetes_engine_v1.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "fptcloud_managed_kubernetes_engine_v1 Data Source - terraform-provider-fptcloud"
subcategory: ""
description: |-
Manage managed FKE clusters.
---

# fptcloud_managed_kubernetes_engine_v1 (Data Source)

Manage managed FKE clusters.



<!-- schema generated by tfplugindocs -->
## Schema

### Required

- `cluster_name` (String)
- `vpc_id` (String)

### Read-Only

- `id` (String) The ID of this resource.
- `k8s_max_pod` (Number)
- `k8s_version` (String)
- `load_balancer_type` (String)
- `network_node_prefix` (Number)
- `pod_network` (String)
- `pod_prefix` (String)
- `pools` (Block List) (see [below for nested schema](#nestedblock--pools))
- `purpose` (String)
- `range_ip_lb_end` (String)
- `range_ip_lb_start` (String)
- `service_network` (String)
- `service_prefix` (String)

<a id="nestedblock--pools"></a>
### Nested Schema for `pools`

Read-Only:

- `auto_scale` (Boolean)
- `is_enable_auto_repair` (Boolean)
- `name` (String)
- `network_id` (String)
- `network_name` (String)
- `scale_max` (Number)
- `scale_min` (Number)
- `storage_profile` (String)
- `worker_disk_size` (Number)
- `worker_type` (String)
1 change: 1 addition & 0 deletions docs/data-sources/subnet.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,5 +81,6 @@ Read-Only:
- `edge_gateway` (Map of String)
- `gateway` (String)
- `id` (String)
- `network_id` (String)
- `name` (String)
- `network_name` (String)
49 changes: 49 additions & 0 deletions docs/resources/database.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "fptcloud_database Resource - terraform-provider-fptcloud"
subcategory: ""
description: |-
Provides a Fpt database cluster which can be used to store data.
---

# fptcloud_database (Resource)

Provides a Fpt database cluster which can be used to store data.



<!-- schema generated by tfplugindocs -->
## Schema

### Required

- `admin_password` (String) The admin password of the database cluster.
- `cluster_name` (String) The name of the database cluster.
- `data_disk_size` (Number) The size of the data disk in each node of the database cluster.
- `database_name` (String) The name of the database in the database cluster.
- `domain_name` (String) The domain name of the database cluster.
- `edge_id` (String) The edge Id of the database cluster.
- `edition` (String) The edition of the database cluster.
- `flavor` (String) The flavor of the database cluster.
- `is_cluster` (String) The cluster status of the database cluster.
- `is_ops` (String) Whether the database is OpenStack or VMware
- `is_public` (String) Whether the database is public or not.
- `master_count` (Number) The number of master nodes in the database cluster.
- `network_id` (String) The network Id of the database cluster.
- `node_core` (Number) The number of cores in each node of the database cluster.
- `node_cpu` (Number) The number of CPUs in each node of the database cluster.
- `node_ram` (Number) The amount of RAM in each node of the database cluster.
- `number_of_node` (Number) The number of nodes in the database cluster.
- `storage_profile` (String) The storage profile of the database cluster.
- `type_config` (String) The type of configuration of the database cluster (short-config or custom-config).
- `type_db` (String) The type of database of the database cluster
- `vdc_name` (String) The VDC name of the database cluster.
- `version` (String) The version of the database cluster.
- `vhost_name` (String) The name of the RabbitMQ database.
- `vm_network` (String) The VM network of the database cluster.
- `vpc_id` (String) The VPC Id of the database cluster.
- `worker_count` (Number) The number of worker nodes in the database cluster.

### Read-Only

- `id` (String) The Id of the database cluster.
21 changes: 21 additions & 0 deletions docs/resources/database_status.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "fptcloud_database_status Resource - terraform-provider-fptcloud"
subcategory: ""
description: |-
Provides a Fpt database cluster status to temporarily stop or start a database.
---

# fptcloud_database_status (Resource)

Provides a Fpt database cluster status to temporarily stop or start a database.



<!-- schema generated by tfplugindocs -->
## Schema

### Required

- `id` (String) The Id of the database cluster.
- `status` (String) The status of the database cluster, must be 'running' or 'stopped'.
Loading
Loading