Skip to content

Commit

Permalink
GKE | Preferred instances and instance family types (#184)
Browse files Browse the repository at this point in the history
  • Loading branch information
ramrutha497 authored Oct 24, 2024
1 parent 0be2d44 commit 62b776d
Show file tree
Hide file tree
Showing 6 changed files with 268 additions and 16 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).

## [3.17.0] - 2024-10-24
### Added
- "Detach Instances", "Instance Types Filters Simulation" API support added in the GCP Ocean Client
- Added Create/Update Cluster 'Preferred Instance Type' model for the GCP Ocean

## [3.16.1] - 2024-10-22
### Added
- "Delete Volume in a Stateful Instance" API support added in the AWS Elastigroup Client.
Expand Down
37 changes: 37 additions & 0 deletions docs/clients/ocean/ocean_gcp_client.md
Original file line number Diff line number Diff line change
Expand Up @@ -445,3 +445,40 @@ __Returns__

`(Object)`: Ocean Virtual Node Group Launch API response

<h2 id="spotinst_sdk2.clients.ocean.OceanGcpClient.detach_instances">detach_instances</h2>

```python
OceanGcpClient.detach_instances(
ocean_id: str, detach_configuration: DetachInstancesConfig)
```

Detach instances from your Ocean cluster.

__Arguments__

- __ocean_id (String)__: ID of the Ocean Cluster
- __detach_configuration (DetachInstancesConfig)__: Detach instances request

__Returns__

`(Object)`: Detach Instance response

<h2 id="spotinst_sdk2.clients.ocean.OceanGcpClient.instance_types_filters_simulation">instance_types_filters_simulation</h2>

```python
OceanGcpClient.instance_types_filters_simulation(
ocean_id: str, filters: InstanceTypesFilters)
```

Returns all instances types that match the given filters.
These instance types will be used if the cluster is configured with these filters.

__Arguments__

- __ocean_id (String)__: Id of the Ocean Cluster
- __filters (InstanceTypesFilters)__: List of filters

__Returns__

`(Object)`: Ocean Instance Type Simultion response

72 changes: 64 additions & 8 deletions docs/models/ocean/gcp.md
Original file line number Diff line number Diff line change
Expand Up @@ -153,19 +153,46 @@ __Arguments__
- __named_ports__: NamedPorts
- __scheme__: Scheme

<h2 id="spotinst_sdk2.models.ocean.gcp.InstanceTypesFilters">InstanceTypesFilters</h2>

```python
InstanceTypesFilters(
self,
exclude_families: typing.List[str] = 'd3043820717d74d9a17694c176d39733',
include_families: typing.List[str] = 'd3043820717d74d9a17694c176d39733',
max_memory_gi_b: float = 'd3043820717d74d9a17694c176d39733',
max_vcpu: int = 'd3043820717d74d9a17694c176d39733',
min_memory_gi_b: float = 'd3043820717d74d9a17694c176d39733',
min_vcpu: int = 'd3043820717d74d9a17694c176d39733')
```

__Arguments__

- __exclude_families__: List[str]
- __include_families__: List[str]
- __max_memory_gi_b__: float
- __max_vcpu__: int
- __min_memory_gi_b__: float
- __min_vcpu__: int

<h2 id="spotinst_sdk2.models.ocean.gcp.InstanceTypes">InstanceTypes</h2>

```python
InstanceTypes(
self,
blacklist: typing.List[str] = 'd3043820717d74d9a17694c176d39733',
whitelist: typing.List[str] = 'd3043820717d74d9a17694c176d39733')
whitelist: typing.List[str] = 'd3043820717d74d9a17694c176d39733',
filters: InstanceTypesFilters = 'd3043820717d74d9a17694c176d39733',
preferred_types: typing.List[str] = 'd3043820717d74d9a17694c176d39733'
)
```

__Arguments__

- __blacklist__: List[str]
- __whitelist__: List[str]
- __filters__: InstanceTypesFilters
- __preferred_types__: List[str]

<h2 id="spotinst_sdk2.models.ocean.gcp.Labels">Labels</h2>

Expand Down Expand Up @@ -199,6 +226,9 @@ __Arguments__
RootVolumeType(cls, value, names=None, *, module, qualname, type, start)
```
An enumeration.
<h3 id="spotinst_sdk2.models.ocean.gcp.RootVolumeType.pd_balanced">pd_balanced</h3>


<h3 id="spotinst_sdk2.models.ocean.gcp.RootVolumeType.pd_ssd">pd_ssd</h3>


Expand Down Expand Up @@ -462,18 +492,20 @@ An enumeration.

```python
Strategy(
self,
draining_timeout: int = 'd3043820717d74d9a17694c176d39733',
preemptible_percentage: int = 'd3043820717d74d9a17694c176d39733',
provisioning_model: ProvisioningModel = 'd3043820717d74d9a17694c176d39733'
)
self,
draining_timeout: int = 'd3043820717d74d9a17694c176d39733',
preemptible_percentage: int = 'd3043820717d74d9a17694c176d39733',
provisioning_model:
ProvisioningModel = 'd3043820717d74d9a17694c176d39733',
should_utilize_commitments: bool = 'd3043820717d74d9a17694c176d39733')
```

__Arguments__

- __draining_timeout__: int
- __preemptible_percentage__: int
- __provisioning_model__: ProvisioningModel
- __should_utilize_commitments__: bool

<h2 id="spotinst_sdk2.models.ocean.gcp.Ocean">Ocean</h2>

Expand Down Expand Up @@ -772,6 +804,8 @@ VirtualNodeGroup(
auto_scale: AutoScale = 'd3043820717d74d9a17694c176d39733',
availability_zones: typing.List[str] = 'd3043820717d74d9a17694c176d39733',
instance_types: typing.List[str] = 'd3043820717d74d9a17694c176d39733',
filters: InstanceTypesFilters = 'd3043820717d74d9a17694c176d39733',
preferred_types: typing.List[str] = 'd3043820717d74d9a17694c176d39733',
labels:
typing.List[spotinst_sdk2.models.ocean.gcp.Labels] = 'd3043820717d74d9a17694c176d39733',
metadata:
Expand All @@ -783,7 +817,7 @@ VirtualNodeGroup(
resource_limits: VNGResourceLimits = 'd3043820717d74d9a17694c176d39733',
restrict_scale_down: bool = 'd3043820717d74d9a17694c176d39733',
root_volume_size_in_gb: int = 'd3043820717d74d9a17694c176d39733',
root_volume_type: str = 'd3043820717d74d9a17694c176d39733',
root_volume_type: RootVolumeType = 'd3043820717d74d9a17694c176d39733',
scheduling: VNGScheduling = 'd3043820717d74d9a17694c176d39733',
service_account: str = 'd3043820717d74d9a17694c176d39733',
shielded_instance_config:
Expand All @@ -801,7 +835,9 @@ __Arguments__

- __auto_scale__: AutoScale
- __availability_zones__: List[str]
- __filters__: InstanceTypesFilters
- __instance_types__: List[str]
- __preferred_types__: List[str]
- __labels__: List[Labels]
- __metadata__: List[Metadata]
- __name__: str
Expand All @@ -810,7 +846,7 @@ __Arguments__
- __resource_limits__: ResourceLimits
- __restrict_scale_down__: bool
- __root_volume_size_in_gb__: int
- __root_volume_type__: str
- __root_volume_type__: RootVolumeType
- __scheduling__: Scheduling
- __service_account__: str
- __shielded_instance_config__: ShieldedInstanceConfig
Expand Down Expand Up @@ -868,3 +904,23 @@ __Arguments__
- __instance_types__: InstanceTypes
- __name__: str

<h2 id="spotinst_sdk2.models.ocean.gcp.DetachInstancesConfig">DetachInstancesConfig</h2>

```python
DetachInstancesConfig(
self,
instances_to_detach:
typing.List[str] = 'd3043820717d74d9a17694c176d39733',
should_decrement_target_capacity:
bool = 'd3043820717d74d9a17694c176d39733',
should_terminate_instances: bool = 'd3043820717d74d9a17694c176d39733',
draining_timeout: int = 'd3043820717d74d9a17694c176d39733')
```

__Arguments__

- __instances_to_detach__: List[str]
- __should_decrement_target_capacity__: bool
- __should_terminate_instances__: bool
- __draining_timeout__: int

72 changes: 69 additions & 3 deletions spotinst_sdk2/clients/ocean/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2493,7 +2493,73 @@ def launch_nodes_in_vng(self, ocean_launch_spec_id: str, amount: int):
response, self.camel_to_underscore)

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

def detach_instances(self, ocean_id: str, detach_configuration: gcp_ocean.DetachInstancesConfig):
"""
Detach instances from your Ocean cluster.
# Arguments
ocean_id (String): ID of the Ocean Cluster
detach_configuration (DetachInstancesConfig): Detach instances request
# Returns
(Object): Detach Instance response
"""
request = gcp_ocean.DetachInstancesRequest(
detach_config=detach_configuration)

excluded_missing_dict = self.exclude_missing(
json.loads(request.toJSON()))

formatted_missing_dict = self.convert_json(
excluded_missing_dict, self.underscore_to_camel)

body_json = json.dumps(formatted_missing_dict)

response = self.send_put(
body=body_json,
url=self.__base_ocean_cluster_url + "/" + ocean_id + "/detachInstances",
entity_name='ocean gcp detach instances')

formatted_response = self.convert_json(
response, self.camel_to_underscore)

return formatted_response["response"]

def instance_types_filters_simulation(self, ocean_id: str, filters: gcp_ocean.InstanceTypesFilters):
"""
Returns all instances types that match the given filters.
These instance types will be used if the cluster is configured with these filters.
# Arguments
ocean_id (String): Id of the Ocean Cluster
filters (InstanceTypesFilters): List of filters
# Returns
(Object): Ocean Instance Type Simultion response
"""
request = gcp_ocean.InstanceTypesFilterRequest(filters)

excluded_missing_dict = self.exclude_missing(
json.loads(request.toJSON()))

formatted_missing_dict = self.convert_json(
excluded_missing_dict, self.underscore_to_camel)

body_json = json.dumps(formatted_missing_dict)

group_response = self.send_post(
body=body_json,
url=self.__base_ocean_cluster_url +
"/" + ocean_id + "/instanceTypeFiltersSimulation",
entity_name='ocean gcp')

formatted_response = self.convert_json(
group_response, self.camel_to_underscore)

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

# endregion

# region RightSizing

Expand Down Expand Up @@ -2774,7 +2840,7 @@ def get_ocean_right_sizing_recommendations(self, ocean_id: str, cluster_resource

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

# endRegion
# endregion

# region OceanEcs

Expand Down Expand Up @@ -3195,7 +3261,7 @@ def detach_instances(self, ocean_id: str, detach_configuration: ecs_ocean.Detach
formatted_response = self.convert_json(
response, self.camel_to_underscore)

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

def create_virtual_node_group(self, vng: ecs_ocean.VirtualNodeGroup):
"""
Expand Down
Loading

0 comments on commit 62b776d

Please sign in to comment.