Skip to content

Commit

Permalink
(Ocean/GKE) - Add initial_nodes option to GKE (#178)
Browse files Browse the repository at this point in the history
  • Loading branch information
ramrutha497 authored Jul 3, 2024
1 parent b472e46 commit 90a23d0
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 5 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).

## [3.10.0] - 2024-07-04
### Added
- Added `initialNodes` query parameter for Ocean GKE `create_virtual_node_group` API.

## [3.9.1] - 2024-06-28
### Fixed
- Made few parameter objects in `create_right_sizing_rule` to optional (For internal use only).
Expand Down
4 changes: 3 additions & 1 deletion docs/clients/ocean/ocean_gcp_client.md
Original file line number Diff line number Diff line change
Expand Up @@ -202,14 +202,16 @@ __Returns__
<h2 id="spotinst_sdk2.clients.ocean.OceanGcpClient.create_virtual_node_group">create_virtual_node_group</h2>

```python
OceanGcpClient.create_virtual_node_group(vng: VirtualNodeGroup)
OceanGcpClient.create_virtual_node_group(vng: VirtualNodeGroup,
initial_nodes: int = None)
```

Create a virtual node group.

__Arguments__

- __vng (VirtualNodeGroup)__: VirtualNodeGroup Object
- __initial_nodes__: When set to an integer greater than 0, a corresponding number of nodes will be launched from the virtual node group created.

__Returns__

Expand Down
14 changes: 11 additions & 3 deletions spotinst_sdk2/clients/ocean/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1820,6 +1820,8 @@ def get_aggregated_summary_costs(self, ocean_id: str, aggregated_cluster_costs:
# endregion

# region GCP


class OceanGcpClient(Client):
__base_ocean_url = "/ocean/k8s/cluster/"
__base_ocean_cluster_url = "/ocean/gcp/k8s/cluster"
Expand Down Expand Up @@ -2108,12 +2110,13 @@ def get_aggregated_summary_costs(self, ocean_id: str, aggregated_cluster_costs:

return formatted_response["response"]["items"][0]

def create_virtual_node_group(self, vng: gcp_ocean.VirtualNodeGroup):
def create_virtual_node_group(self, vng: gcp_ocean.VirtualNodeGroup, initial_nodes: int = None):
"""
Create a virtual node group.
# Arguments
vng (VirtualNodeGroup): VirtualNodeGroup Object
initial_nodes: When set to an integer greater than 0, a corresponding number of nodes will be launched from the virtual node group created.
# Returns
(Object): Ocean Launch Spec response
Expand All @@ -2128,10 +2131,13 @@ def create_virtual_node_group(self, vng: gcp_ocean.VirtualNodeGroup):

body_json = json.dumps(formatted_missing_dict)

response = self.send_post(
query_params = dict(initialNodes=initial_nodes)

response = self.send_post_with_params(
body=body_json,
url=self.__base_ocean_launchspec_url,
entity_name='ocean_gcp_vng')
entity_name='ocean_gcp_vng',
user_query_params=query_params)

formatted_response = self.convert_json(response,
self.camel_to_underscore)
Expand Down Expand Up @@ -2480,6 +2486,8 @@ def launch_nodes_in_vng(self, ocean_launch_spec_id: str, amount: int):
# endRegion

# region RightSizing


class OceanRightSizingClient(Client):

def create_right_sizing_rule(self, ocean_id: str, rule_name: str, restart_pods: bool,
Expand Down
2 changes: 1 addition & 1 deletion spotinst_sdk2/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '3.9.1'
__version__ = '3.10.0'

0 comments on commit 90a23d0

Please sign in to comment.