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

GCP: Add support for bare metal instances #780

Merged
merged 3 commits into from
Oct 8, 2024
Merged

GCP: Add support for bare metal instances #780

merged 3 commits into from
Oct 8, 2024

Conversation

vitabaks
Copy link
Owner

@vitabaks vitabaks commented Oct 7, 2024

This PR adds support for bare metal instances in GCP.

For these instance types, the on_host_maintenance: "TERMINATE" option is automatically set, as required by GCP.
For all other standard instance types, the "MIGRATE" option is used, allowing instances to migrate during maintenance.

@vitabaks vitabaks self-assigned this Oct 7, 2024
@vitabaks
Copy link
Owner Author

vitabaks commented Oct 7, 2024

Test

result:

TASK [cloud-resources : GCP: Create or modify VM instance] *********************
failed: [localhost] (item=dedicated-test-1485184977-pgnode01) => {"ansible_index_var": "idx", "ansible_loop_var": "item", "attempts": 3, "changed": false, "idx": 0, "item": 0, "msg": "GCP returned error: {'error': {'code': 400, 'message': \"Invalid value for field 'resource.machineType': 'https://www.********/compute/v1/projects/712159250225/zones/us-east1-c/machineTypes/c3-standard-192-metal'. NetworkInterface NicType can only be set to IDPF on instances with IDPF GuestOsFeature.\", 'errors': [{'message': \"Invalid value for field 'resource.machineType': 'https://www.********/compute/v1/projects/712159250225/zones/us-east1-c/machineTypes/c3-standard-192-metal'. NetworkInterface NicType can only be set to IDPF on instances with IDPF GuestOsFeature.\", 'domain': 'global', 'reason': 'invalid'}]}}", "request": {"body": "{\"kind\": \"compute#instance\", \"disks\": [{\"autoDelete\": true, \"boot\": true, \"deviceName\": \"dedicated-test-1485184977-pgnode01-system\", \"initializeParams\": {\"diskName\": \"dedicated-test-1485184977-pgnode01-system\", \"diskSizeGb\": 100, \"diskType\": \"https://compute.********/compute/v1/projects/712159250225/zones/us-east1-c/diskTypes/hyperdisk-balanced\", \"sourceImage\": \"projects/********/global/images/ubuntu-2204-postgres-17rc1-164-158-1413-1316-1220\"}}, {\"autoDelete\": true, \"deviceName\": \"dedicated-test-1485184977-pgnode01-storage\", \"initializeParams\": {\"diskName\": \"dedicated-test-1485184977-pgnode01-storage\", \"diskSizeGb\": 100, \"diskType\": \"https://compute.********/compute/v1/projects/712159250225/zones/us-east1-c/diskTypes/hyperdisk-balanced\"}}], \"labels\": {\"cluster\": \"dedicated-test-1485184977\"}, \"metadata\": {\"items\": [{\"key\": \"ssh-keys\", \"value\": \"root:ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCtsd1XDOh45MDfl1Y03PV9AM4q0QqERY6bDOaJnmH6jOamp6g5Ogf9Zc+fFLheMTSXofuUmwWSoYWcVaqqx0Xar/UZjmE6j4zC90RgamLTlYogVLAfznMBtXxHmKHUqGmLOG72HB6v5QBpIv35zVX7pLaHKdBerbg0OO/3GJniQ+87B7RusdMRN5HIIYmMGkCY0EeC2J/YlRgMef/2K1mSrgI6xE1IimnZgVwY6qBOQuM91AsyK3wDVc5dBTytb1Lls2HR4klQ4ec8N1SxZnSbm8vKmxvmQEaUcX79Yg1gEmzJ64ADlAcGBvO0aX+RY3EUEwwukdeeKZ6oJOUJ5JPJ ssh_key_tmp_syijfhw\"}]}, \"machineType\": \"https://www.********/compute/v1/projects/712159250225/zones/us-east1-c/machineTypes/c3-standard-192-metal\", \"name\": \"dedicated-test-1485184977-pgnode01\", \"networkInterfaces\": [{\"accessConfigs\": [{\"name\": \"External NAT\", \"type\": \"ONE_TO_ONE_NAT\"}], \"network\": \"global/networks/default\"}], \"scheduling\": {\"onHostMaintenance\": \"TERMINATE\", \"preemptible\": false}, \"status\": \"RUNNING\", \"tags\": {\"items\": [\"dedicated-test-1485184977\"]}}", "method": "POST", "url": "https://compute.********/compute/v1/projects/712159250225/zones/us-east1-c/instances"}}
  • NetworkInterface NicType can only be set to IDPF on instances with IDPF GuestOsFeature.

UPD: It is necessary to use an image with IDPF support https://cloud.google.com/compute/docs/networking/using-idpf

@vitabaks vitabaks marked this pull request as draft October 7, 2024 19:02
@vitabaks vitabaks changed the title GCP: Added support for bare metal instances GCP: Add support for bare metal instances Oct 7, 2024
@vitabaks
Copy link
Owner Author

vitabaks commented Oct 7, 2024

Test 2: with IDPF support image

PLAY [Deploy PostgreSQL HA Cluster (based on "Patroni")] ***********************
TASK [Gathering Facts] *********************************************************
ok: [localhost]
TASK [Include main variables] **************************************************
ok: [localhost]
TASK [cloud-resources : Generate a unique temporary SSH key name] **************
ok: [localhost]
TASK [cloud-resources : Generate a new temporary SSH key to access the server for deployment] ***
changed: [localhost]
TASK [cloud-resources : Set variable: ssh_key_name and ssh_key_content] ********
ok: [localhost]
TASK [cloud-resources : Ensure that 'python3-pip' package is present on controlling host] ***
ok: [localhost -> 127.0.0.1]
TASK [cloud-resources : Ensure that 'google-auth' dependency is present on controlling host] ***
ok: [localhost -> 127.0.0.1]
TASK [cloud-resources : Lookup the GCP_SERVICE_ACCOUNT_CONTENTS environmental variable] ***
ok: [localhost]
TASK [cloud-resources : Set variable: gcp_service_account_contents (b64decode)] ***
ok: [localhost]
TASK [cloud-resources : GCP: Gather information about project] *****************
ok: [localhost]
TASK [cloud-resources : Set variable: gcp_network_name] ************************
ok: [localhost]
TASK [cloud-resources : GCP: Gather information about network] *****************
ok: [localhost]
TASK [cloud-resources : GCP: Extract ip_range for network 'default'] ***********
ok: [localhost]
TASK [cloud-resources : GCP: Create or modify SSH public firewall rule] ********
changed: [localhost]
TASK [cloud-resources : GCP: Create or modify Postgres cluster firewall rule] ***
changed: [localhost]
TASK [cloud-resources : GCP: Create or modify VM instance] *********************
changed: [localhost] => (item=dedicated-test-1485356189-pgnode01)
TASK [cloud-resources : Wait for host to be available via SSH] *****************
ok: [localhost] => (item=104.154.171.135)
TASK [cloud-resources : Server info] *******************************************
ok: [localhost] => (item=104.154.171.135) => {
    "msg": {
        "id": "8315221318562346144",
        "image": "ubuntu-2204-lts",
        "name": "dedicated-test-1485356189-pgnode01",
        "private_ip": "10.128.15.196",
        "public_ip": "104.154.171.135",
        "type": "c3-standard-192-metal",
        "volume_size": "1000 GB"
    }
}

passed

@vitabaks vitabaks marked this pull request as ready for review October 7, 2024 21:09
@vitabaks vitabaks merged commit c9c9f02 into master Oct 8, 2024
16 checks passed
@vitabaks vitabaks deleted the gcp-metal branch October 8, 2024 09:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant