Skip to content

Commit 94f5023

Browse files
committed
[GCP Compute Engine] Update image build
1 parent 73e3966 commit 94f5023

14 files changed

Lines changed: 395 additions & 90 deletions

File tree

config/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ Storage Backends
6969
- [IBM Virtual Private Cloud](../docs/source/compute_config/ibm_vpc.md)
7070
- [AWS Elastic Compute Cloud (EC2)](../docs/source/compute_config/aws_ec2.md)
7171
- [Azure Virtual Machines](../docs/source/compute_config/azure_vms.md)
72+
- [Google Compute Engine](../docs/source/compute_config/gcp_compute_engine.md)
7273

7374
</td>
7475
<td valign="top">

config/config_template.yaml

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@
137137
# Google Cloud Platform – credentials shared by all gcp_* sections
138138
# =============================================================================
139139
#gcp:
140+
#project_name: <GCP_PROJECT_ID>
140141
#region: <REGION_NAME> # e.g. us-east1
141142
#credentials_path: <ABSOLUTE_PATH_TO_SERVICE_ACCOUNT_JSON>
142143

@@ -172,6 +173,26 @@
172173
#region: <REGION_NAME> # Falls back to gcp.region
173174
#storage_bucket: <BUCKET_NAME> # Auto-created if not provided
174175

176+
# Google Compute Engine – standalone compute
177+
#gcp_compute_engine:
178+
#project_name: <GCP_PROJECT_ID> # Falls back to gcp.project_name
179+
#zone: <ZONE_NAME> # e.g. us-east1-b. Mandatory
180+
#region: <REGION_NAME> # Falls back to gcp.region; derived from zone if omitted
181+
#service_account: <SERVICE_ACCOUNT_EMAIL>
182+
#network_name: <VPC_NETWORK_NAME> # Lithops creates a VPC if not provided
183+
#subnet_name: <SUBNET_NAME>
184+
#source_image: projects/ubuntu-os-cloud/global/images/family/ubuntu-2404-lts-amd64
185+
#instance_name: <INSTANCE_NAME> # Mandatory in consume mode
186+
#master_instance_type: e2-small
187+
#worker_instance_type: e2-standard-2
188+
#ssh_username: ubuntu
189+
#ssh_password: <RANDOM_IF_NOT_PROVIDED>
190+
#ssh_key_filename: ~/.ssh/id_rsa
191+
#request_spot_instances: False
192+
#delete_on_dismantle: True
193+
#max_workers: 100
194+
#worker_processes: AUTO # Default: number of CPUs of the worker VM
195+
175196

176197
# =============================================================================
177198
# Microsoft Azure – credentials shared by all azure_* sections
@@ -460,7 +481,7 @@
460481

461482

462483
# =============================================================================
463-
# Standalone shared settings (applies to ibm_vpc, aws_ec2, azure_vms, vm)
484+
# Standalone shared settings (applies to ibm_vpc, aws_ec2, azure_vms, gcp_compute_engine, vm)
464485
# =============================================================================
465486
#standalone:
466487
#runtime: python3

docs/source/compute_backends.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,4 @@ Compute Backends
4444
compute_config/ibm_vpc.md
4545
compute_config/aws_ec2.md
4646
compute_config/azure_vms.md
47-
compute_config/gcp_compute_engie.md
47+
compute_config/gcp_compute_engine.md

docs/source/compute_config/gcp_compute_engie.md renamed to docs/source/compute_config/gcp_compute_engine.md

Lines changed: 51 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,27 @@
22

33
The GCP Compute Engine backend of Lithops can provide a serverless user experience on top of GCE where Lithops creates new Virtual Machines (VMs) dynamically at runtime and scales Lithops jobs against them (create and reuse modes). Alternatively Lithops can start and stop an existing VM instance (consume mode).
44

5-
The backend key is `gcp_compute_engie` (matches the Lithops module name).
5+
The backend key is `gcp_compute_engine` (matches the Lithops module name).
66

77
## Choose an operating system image for the VM
88

9-
Any VM needs an operating system image. By default Lithops uses Ubuntu 24.04 (`ubuntu-2404-lts-amd64`). Lithops installs required dependencies on the VM on first use (this can take a few minutes).
9+
Any VM needs an operating system image. By default Lithops uses Ubuntu 24.04 (`projects/ubuntu-os-cloud/global/images/family/ubuntu-2404-lts-amd64`). Lithops installs required dependencies on the VM on first use (this can take a few minutes).
10+
11+
For faster startups, build a pre-configured custom image (see [runtime/gcp_compute_engine](https://github.com/lithops-cloud/lithops/tree/master/runtime/gcp_compute_engine)):
12+
13+
```bash
14+
lithops image build -b gcp_compute_engine
15+
```
16+
17+
This creates `lithops-ubuntu-2404-lts-amd64-server` in your project; Lithops uses it automatically when present.
1018

1119
To list available images:
1220

1321
```bash
14-
lithops image list -b gcp_compute_engie
22+
lithops image list -b gcp_compute_engine
1523
```
1624

17-
Use the **Image ID** column as `source_image` in your config.
25+
Use the **Image ID** column as `source_image` in your config when using a custom image name.
1826

1927
## Installation
2028

@@ -54,12 +62,12 @@ gcloud projects add-iam-policy-binding <PROJECT_ID> \
5462

5563
```yaml
5664
lithops:
57-
backend: gcp_compute_engie
65+
backend: gcp_compute_engine
5866

5967
gcp:
6068
credentials_path: <FULL_PATH_TO_SERVICE_ACCOUNT_JSON>
6169

62-
gcp_compute_engie:
70+
gcp_compute_engine:
6371
project_name: <GCP_PROJECT_ID>
6472
zone: <ZONE>
6573
exec_mode: reuse
@@ -78,29 +86,29 @@ Lithops attaches the service account from `credentials_path` to master and worke
7886

7987
|Group|Key|Default|Mandatory|Additional info|
8088
|---|---|---|---|---|
81-
|gcp_compute_engie | project_name | |yes | GCP project ID |
82-
|gcp_compute_engie | zone | |yes | Compute Engine zone, for example `us-east1-b` |
83-
|gcp_compute_engie | region | derived from zone |no | Region used for subnet and NAT |
84-
|gcp_compute_engie | service_account | |no | Service account email attached to VMs. Default: `client_email` from `credentials_path` |
85-
|gcp_compute_engie | network_name | |no | Existing VPC name. If not provided, Lithops creates a new network |
86-
|gcp_compute_engie | subnet_name | |no | Existing subnet name when using a custom VPC |
87-
|gcp_compute_engie | source_image | ubuntu-2404-lts-amd64 |no | Boot image reference |
88-
|gcp_compute_engie | master_instance_type | e2-small |no | Master VM machine type |
89-
|gcp_compute_engie | worker_instance_type | e2-standard-2 |no | Worker VM machine type |
90-
|gcp_compute_engie | ssh_username | ubuntu |no | Username to access the VM |
91-
|gcp_compute_engie | ssh_password | |no | Password for worker VMs. If not provided, it is created randomly |
92-
|gcp_compute_engie | ssh_key_filename | ~/.ssh/id_rsa |no | SSH private key for the master VM. If not provided, Lithops creates one |
93-
|gcp_compute_engie | request_spot_instances | False |no | Use Spot VMs for workers |
94-
|gcp_compute_engie | delete_on_dismantle | True |no | Delete worker VMs when stopped. Master VM is never deleted when stopped |
95-
|gcp_compute_engie | max_workers | 100 |no | Max number of workers per `FunctionExecutor()` |
96-
|gcp_compute_engie | worker_processes | AUTO |no | Parallel Lithops processes per worker. Default: CPUs of `worker_instance_type` |
97-
|gcp_compute_engie | runtime | python3 |no | Runtime name. Default: python3 on the VM |
98-
|gcp_compute_engie | auto_dismantle | True |no | If False, VMs are not stopped automatically |
99-
|gcp_compute_engie | soft_dismantle_timeout | 300 |no | Seconds to stop the VM after a job **completed** |
100-
|gcp_compute_engie | hard_dismantle_timeout | 3600 |no | Seconds to stop the VM after a job **started** |
101-
|gcp_compute_engie | exec_mode | reuse |no | One of: **consume**, **create** or **reuse** |
102-
|gcp_compute_engie | extra_apt_packages | [] |no | Extra apt packages on master/worker VMs during setup |
103-
|gcp_compute_engie | extra_python_packages | [] |no | Extra pip packages on master/worker VMs after Lithops |
89+
|gcp_compute_engine | project_name | |yes | GCP project ID |
90+
|gcp_compute_engine | zone | |yes | Compute Engine zone, for example `us-east1-b` |
91+
|gcp_compute_engine | region | derived from zone |no | Region used for subnet and NAT |
92+
|gcp_compute_engine | service_account | |no | Service account email attached to VMs. Default: `client_email` from `credentials_path` |
93+
|gcp_compute_engine | network_name | |no | Existing VPC name. If not provided, Lithops creates a new network |
94+
|gcp_compute_engine | subnet_name | |no | Existing subnet name when using a custom VPC |
95+
|gcp_compute_engine | source_image | ubuntu-2404-lts-amd64 |no | Boot image reference |
96+
|gcp_compute_engine | master_instance_type | e2-small |no | Master VM machine type |
97+
|gcp_compute_engine | worker_instance_type | e2-standard-2 |no | Worker VM machine type |
98+
|gcp_compute_engine | ssh_username | ubuntu |no | Username to access the VM |
99+
|gcp_compute_engine | ssh_password | |no | Password for worker VMs. If not provided, it is created randomly |
100+
|gcp_compute_engine | ssh_key_filename | ~/.ssh/id_rsa |no | SSH private key for the master VM. If not provided, Lithops creates one |
101+
|gcp_compute_engine | request_spot_instances | False |no | Use Spot VMs for workers |
102+
|gcp_compute_engine | delete_on_dismantle | True |no | Delete worker VMs when stopped. Master VM is never deleted when stopped |
103+
|gcp_compute_engine | max_workers | 100 |no | Max number of workers per `FunctionExecutor()` |
104+
|gcp_compute_engine | worker_processes | AUTO |no | Parallel Lithops processes per worker. Default: CPUs of `worker_instance_type` |
105+
|gcp_compute_engine | runtime | python3 |no | Runtime name. Default: python3 on the VM |
106+
|gcp_compute_engine | auto_dismantle | True |no | If False, VMs are not stopped automatically |
107+
|gcp_compute_engine | soft_dismantle_timeout | 300 |no | Seconds to stop the VM after a job **completed** |
108+
|gcp_compute_engine | hard_dismantle_timeout | 3600 |no | Seconds to stop the VM after a job **started** |
109+
|gcp_compute_engine | exec_mode | reuse |no | One of: **consume**, **create** or **reuse** |
110+
|gcp_compute_engine | extra_apt_packages | [] |no | Extra apt packages on master/worker VMs during setup |
111+
|gcp_compute_engine | extra_python_packages | [] |no | Extra pip packages on master/worker VMs after Lithops |
104112

105113
## Consume mode
106114

@@ -110,12 +118,12 @@ In this mode, Lithops uses an existing VM. The VM must be reachable by SSH and h
110118

111119
```yaml
112120
lithops:
113-
backend: gcp_compute_engie
121+
backend: gcp_compute_engine
114122
115123
gcp:
116124
credentials_path: <FULL_PATH_TO_SERVICE_ACCOUNT_JSON>
117125
118-
gcp_compute_engie:
126+
gcp_compute_engine:
119127
exec_mode: consume
120128
project_name: <GCP_PROJECT_ID>
121129
zone: <ZONE>
@@ -126,19 +134,19 @@ gcp_compute_engie:
126134

127135
|Group|Key|Default|Mandatory|Additional info|
128136
|---|---|---|---|---|
129-
|gcp_compute_engie | instance_name | |yes | Existing VM instance name |
130-
|gcp_compute_engie | project_name | |yes | GCP project ID |
131-
|gcp_compute_engie | zone | |yes | Compute Engine zone |
132-
|gcp_compute_engie | ssh_username | ubuntu |no | Username to access the VM |
133-
|gcp_compute_engie | ssh_key_filename | ~/.ssh/id_rsa |no | Path to the SSH private key |
134-
|gcp_compute_engie | worker_processes | AUTO |no | Parallel Lithops processes per worker |
137+
|gcp_compute_engine | instance_name | |yes | Existing VM instance name |
138+
|gcp_compute_engine | project_name | |yes | GCP project ID |
139+
|gcp_compute_engine | zone | |yes | Compute Engine zone |
140+
|gcp_compute_engine | ssh_username | ubuntu |no | Username to access the VM |
141+
|gcp_compute_engine | ssh_key_filename | ~/.ssh/id_rsa |no | Path to the SSH private key |
142+
|gcp_compute_engine | worker_processes | AUTO |no | Parallel Lithops processes per worker |
135143

136144
## Test Lithops
137145

138146
Once you have your compute and storage backends configured, you can run a hello world function with:
139147

140148
```bash
141-
lithops hello -b gcp_compute_engie -s gcp_storage
149+
lithops hello -b gcp_compute_engine -s gcp_storage
142150
```
143151

144152
## Viewing the execution logs
@@ -158,33 +166,33 @@ All VMs, including the master, are automatically stopped after a configurable ti
158166
You can open an SSH session to the master VM with:
159167

160168
```bash
161-
lithops attach -b gcp_compute_engie
169+
lithops attach -b gcp_compute_engine
162170
```
163171

164172
The master and worker VMs store Lithops service logs in `/tmp/lithops-root/*-service.log`.
165173

166174
To list available workers:
167175

168176
```bash
169-
lithops worker list -b gcp_compute_engie
177+
lithops worker list -b gcp_compute_engine
170178
```
171179

172180
To list submitted jobs:
173181

174182
```bash
175-
lithops job list -b gcp_compute_engie
183+
lithops job list -b gcp_compute_engine
176184
```
177185

178186
To delete workers only:
179187

180188
```bash
181-
lithops clean -b gcp_compute_engie -s gcp_storage
189+
lithops clean -b gcp_compute_engine -s gcp_storage
182190
```
183191

184192
To delete workers, the master VM, and Lithops-created network resources:
185193

186194
```bash
187-
lithops clean -b gcp_compute_engie -s gcp_storage --all
195+
lithops clean -b gcp_compute_engine -s gcp_storage --all
188196
```
189197

190198
## Architecture diagram

docs/source/configuration.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ Choose your compute and storage engines from the table below:
3737
|| `IBM Virtual Private Cloud <compute_config/ibm_vpc.html>`_ || |
3838
|| `AWS Elastic Compute Cloud (EC2) <compute_config/aws_ec2.html>`_ || |
3939
|| `Azure Virtual Machines <compute_config/azure_vms.html>`_ || |
40-
|| `Google Compute Engine <compute_config/gcp_compute_engie.html>`_ || |
40+
|| `Google Compute Engine <compute_config/gcp_compute_engine.html>`_ || |
4141
+--------------------------------------------------------------------+--------------------------------------------------------------------+
4242

4343
Configuration File

docs/source/execution_modes.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,4 +83,4 @@ underlying infrastructure.
8383
8484
fexec = lithops.StandaloneExecutor()
8585
86-
- Available backends: `IBM Virtual Private Cloud <compute_config/ibm_vpc.html>`_, `AWS Elastic Compute Cloud (EC2) <compute_config/aws_ec2.html>`_, `Azure Virtual Machines <compute_config/azure_vms.html>`_, `Google Compute Engine <compute_config/gcp_compute_engie.html>`_, `Virtual Machine <compute_config/vm.html>`_
86+
- Available backends: `IBM Virtual Private Cloud <compute_config/ibm_vpc.html>`_, `AWS Elastic Compute Cloud (EC2) <compute_config/aws_ec2.html>`_, `Azure Virtual Machines <compute_config/azure_vms.html>`_, `Google Compute Engine <compute_config/gcp_compute_engine.html>`_, `Virtual Machine <compute_config/vm.html>`_

lithops/constants.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,6 @@
120120
'ibm_vpc',
121121
'aws_ec2',
122122
'azure_vms',
123-
'gcp_compute_engie',
123+
'gcp_compute_engine',
124124
'vm'
125125
]

lithops/standalone/backends/gcp_compute_engie/__init__.py

Lines changed: 0 additions & 3 deletions
This file was deleted.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from .gcp_compute_engine import GCPComputeEngineBackend as StandaloneBackend
2+
3+
__all__ = ['StandaloneBackend']

lithops/standalone/backends/gcp_compute_engie/config.py renamed to lithops/standalone/backends/gcp_compute_engine/config.py

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -43,48 +43,48 @@
4343

4444

4545
def load_config(config_data):
46-
if 'gcp_compute_engie' not in config_data or not config_data['gcp_compute_engie']:
47-
raise Exception("'gcp_compute_engie' section is mandatory in the configuration")
46+
if not config_data['gcp_compute_engine']:
47+
raise Exception("'gcp_compute_engine' section is mandatory in the configuration")
4848

4949
if 'gcp' not in config_data:
5050
config_data['gcp'] = {}
5151

52-
temp = copy.deepcopy(config_data['gcp_compute_engie'])
53-
config_data['gcp_compute_engie'].update(config_data['gcp'])
54-
config_data['gcp_compute_engie'].update(temp)
52+
temp = copy.deepcopy(config_data['gcp_compute_engine'])
53+
config_data['gcp_compute_engine'].update(config_data['gcp'])
54+
config_data['gcp_compute_engine'].update(temp)
5555

56-
if 'credentials_path' in config_data['gcp_compute_engie']:
57-
config_data['gcp_compute_engie']['credentials_path'] = os.path.expanduser(
58-
config_data['gcp_compute_engie']['credentials_path']
56+
if 'credentials_path' in config_data['gcp_compute_engine']:
57+
config_data['gcp_compute_engine']['credentials_path'] = os.path.expanduser(
58+
config_data['gcp_compute_engine']['credentials_path']
5959
)
6060

6161
for key in DEFAULT_CONFIG_KEYS:
62-
if key not in config_data['gcp_compute_engie']:
63-
config_data['gcp_compute_engie'][key] = DEFAULT_CONFIG_KEYS[key]
62+
if key not in config_data['gcp_compute_engine']:
63+
config_data['gcp_compute_engine'][key] = DEFAULT_CONFIG_KEYS[key]
6464

6565
if 'standalone' not in config_data or config_data['standalone'] is None:
6666
config_data['standalone'] = {}
6767

6868
for key in SA_DEFAULT_CONFIG_KEYS:
69-
if key in config_data['gcp_compute_engie']:
70-
config_data['standalone'][key] = config_data['gcp_compute_engie'].pop(key)
69+
if key in config_data['gcp_compute_engine']:
70+
config_data['standalone'][key] = config_data['gcp_compute_engine'].pop(key)
7171
elif key not in config_data['standalone']:
7272
config_data['standalone'][key] = SA_DEFAULT_CONFIG_KEYS[key]
7373

7474
if config_data['standalone']['exec_mode'] == 'consume':
7575
params_to_check = MANDATORY_PARAMETERS_1
76-
config_data['gcp_compute_engie']['max_workers'] = 1
76+
config_data['gcp_compute_engine']['max_workers'] = 1
7777
else:
7878
params_to_check = MANDATORY_PARAMETERS_2
7979

8080
for param in params_to_check:
81-
if param not in config_data['gcp_compute_engie']:
82-
msg = f"'{param}' is mandatory in the 'gcp_compute_engie' section of the configuration"
81+
if param not in config_data['gcp_compute_engine']:
82+
msg = f"'{param}' is mandatory in the 'gcp_compute_engine' or 'gcp' section of the configuration"
8383
raise Exception(msg)
8484

85-
if 'region' not in config_data['gcp_compute_engie']:
86-
zone = config_data['gcp_compute_engie']['zone']
87-
config_data['gcp_compute_engie']['region'] = '-'.join(zone.split('-')[:-1])
85+
if 'region' not in config_data['gcp_compute_engine']:
86+
zone = config_data['gcp_compute_engine']['zone']
87+
config_data['gcp_compute_engine']['region'] = '-'.join(zone.split('-')[:-1])
8888

89-
if 'region' not in config_data['gcp'] and 'region' in config_data['gcp_compute_engie']:
90-
config_data['gcp']['region'] = config_data['gcp_compute_engie']['region']
89+
if 'region' not in config_data['gcp'] and 'region' in config_data['gcp_compute_engine']:
90+
config_data['gcp']['region'] = config_data['gcp_compute_engine']['region']

0 commit comments

Comments
 (0)