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

Hetzner: Add shared vCPU instance types; EUR -> USD #835

Merged
merged 15 commits into from
Dec 12, 2024

Conversation

nelsonic
Copy link
Contributor

@nelsonic nelsonic commented Dec 9, 2024

This PR adds the lowest cost Shared vCPU instance to the list for Hetzner ☁️
as it allows people to test autobase for the lowest price e.g: while in development. 🧪

@vitabaks
Copy link
Owner

vitabaks commented Dec 9, 2024

Thank you for your contribution!

Please consider adding all shared CPU types, not just one.

You are currently using the migration file for version 2.0.0. Since we cannot modify it (details), please use the migration file for the next release, version 2.1.0.

Additionally, it would be helpful to include the ability to display in the UI that this is a shared vCPU. However, implementing this feature will require updates to both the API and UI.

@nelsonic
Copy link
Contributor Author

nelsonic commented Dec 9, 2024

Thanks for the quick feedback. 🏎️ 👌
Will update when back at my desk. ⏳

@vitabaks vitabaks mentioned this pull request Dec 9, 2024
@schonert
Copy link

schonert commented Dec 9, 2024

@nelsonic nice!
If you decide to add the new CPU types we might aswel prices to USD while we're at it (agree @vitabaks?).
Not trying to dig up more work for you @nelsonic - so let me know if I you're not planning on adding the CPU types 👍

@nelsonic
Copy link
Contributor Author

nelsonic commented Dec 9, 2024

@schonert good call. 👌 🇺🇸
I've switched the UI on Hetzner's Pricing page to USD:

https://www.hetzner.com/cloud/

image

Added all the Shared vCPU instance types in USD to facilitate comparison with other providers which are all in USD.

@vitabaks can I update the 2.0.0 migration to USD??

('hetzner', 'Small Size', 'CPX11', 2, 2, 0.007, 5.180, '', '2024-07-21'),
('hetzner', 'Small Size', 'CPX21', 3, 4, 0.010, 8.980, '', '2024-07-21'),
('hetzner', 'Small Size', 'CCX13', 2, 8, 0.024, 14.860, '', '2024-05-15'),
('hetzner', 'Small Size', 'CCX23', 4, 16, 0.047, 29.140, '', '2024-05-15'),
('hetzner', 'Medium Size', 'CCX33', 8, 32, 0.093, 57.700, '', '2024-05-15'),
('hetzner', 'Medium Size', 'CCX43', 16, 64, 0.184, 114.820, '', '2024-05-15'),
('hetzner', 'Medium Size', 'CCX53', 32, 128, 0.367, 229.060, '', '2024-05-15'),
('hetzner', 'Medium Size', 'CCX63', 48, 192, 0.550, 343.300, '', '2024-05-15');

Won't affect any existing instances of the console, but will help future people get a fair comparison between cloud providers. 💭

@nelsonic nelsonic changed the title PR: Add CX22 instance for Hetzner closes #834 PR: Add CX22 instance for Hetzner closes #834 EUR -> USD Dec 9, 2024
@vitabaks
Copy link
Owner

can I update the 2.0.0 migration

No, because this version has already been released. We need to prepare a migration file for the next version 2.1.0 in which we will perform an UPDATE for prices and an INSERT for new instance types.

@nelsonic
Copy link
Contributor Author

@vitabaks Thanks for your prompt reply. 👌
Happy to prepare an update statement for each item. ⏳
Is there an example of UPDATE I can follow? 👀
Or should I just Google for it? 🔍

@vitabaks
Copy link
Owner

vitabaks commented Dec 10, 2024

Is there an example of UPDATE I can follow?

example:

-- cloud_instances
-- Update prices and other relevant fields for Hetzner cloud instances
UPDATE public.cloud_instances SET price_hourly = 0.0082, price_monthly = 5.09, currency = '$', updated_at = '2024-12-10' WHERE cloud_provider = 'hetzner' AND instance_name = 'CPX11';
UPDATE public.cloud_instances SET price_hourly = 0.0138, price_monthly = 8.59, currency = '$', updated_at = '2024-12-10' WHERE cloud_provider = 'hetzner' AND instance_name = 'CPX21';
UPDATE public.cloud_instances SET price_hourly = 0.0226, price_monthly = 14.09, currency = '$', updated_at = '2024-12-10' WHERE cloud_provider = 'hetzner' AND instance_name = 'CCX13';
UPDATE public.cloud_instances SET price_hourly = 0.0435, price_monthly = 27.09, currency = '$', updated_at = '2024-12-10' WHERE cloud_provider = 'hetzner' AND instance_name = 'CCX23';
UPDATE public.cloud_instances SET price_hourly = 0.0867, price_monthly = 54.09, currency = '$', updated_at = '2024-12-10' WHERE cloud_provider = 'hetzner' AND instance_name = 'CCX33';
UPDATE public.cloud_instances SET price_hourly = 0.1725, price_monthly = 107.59, currency = '$', updated_at = '2024-12-10' WHERE cloud_provider = 'hetzner' AND instance_name = 'CCX43';
UPDATE public.cloud_instances SET price_hourly = 0.3431, price_monthly = 214.09, currency = '$', updated_at = '2024-12-10' WHERE cloud_provider = 'hetzner' AND instance_name = 'CCX53';
UPDATE public.cloud_instances SET price_hourly = 0.5138, price_monthly = 320.59, currency = '$', updated_at = '2024-12-10' WHERE cloud_provider = 'hetzner' AND instance_name = 'CCX63';

-- cloud_volumes
-- Update prices and other relevant fields for Hetzner cloud volume
UPDATE public.cloud_volumes SET price_monthly = 0.05, currency = '$', updated_at = '2024-12-10' WHERE cloud_provider = 'hetzner';

File 20241205103951_2.1.0.sql

@vitabaks
Copy link
Owner

vitabaks commented Dec 10, 2024

To ensure more accurate pricing, please enable IPv4 primary IP since we use it (by default).

image
image
image

Additionally, I suggest adding a comment to the migration file indicating that the prices for Hetzner are specific to the German region and exclude VAT.

@nelsonic
Copy link
Contributor Author

The IPv4 pricing is for externally addressable IPs.
My understanding was that the Postgres Cluster created by autobase
is only accessible from within the private network.
Do the instances created need to have public IPv4 ?
is it just for management from the autobase console?

Happy to include the extra $0.50/month per instance in the pricing. 👌

@vitabaks
Copy link
Owner

vitabaks commented Dec 10, 2024

Do the instances created need to have public IPv4 ?

By default, we create public IP addresses to enable SSH access to the instance over the Internet. This is particularly useful, for example, when deploying from your laptop. Later, you can delete the public IP addresses or modify the firewall rules to restrict access via SSH to specific IP addresses.

P.S. Access to the servers is only possible via SSH keys, ensuring a high level of security.

TODO: describe it in the documentation.

@vitabaks
Copy link
Owner

By default, we create public IP addresses to enable SSH access to the instance over the Internet.

This behavior can be controlled when deployed via the command line using variables

ssh_public_access: true  # Allow public ssh access (required for deployment from the public network).
ssh_public_allowed_ips: ""  # (comma-separated list of IP addresses in CIDR format) If empty, then public access is allowed for any IP address.
netdata_public_access: true  # Allow access to the Netdata monitoring from the public network (if 'netdata_install' is 'true').
netdata_public_allowed_ips: ""  # (comma-separated list of IP addresses in CIDR format) If empty, then public access is allowed for any IP address.
database_public_access: false  # Allow access to the database from the public network.
database_public_allowed_ips: ""  # (comma-separated list of IP addresses in CIDR format) If empty, then public access is allowed for any IP address.

We will try to add this to the UI when developing Expert Mode

@vitabaks vitabaks changed the title PR: Add CX22 instance for Hetzner closes #834 EUR -> USD PR: Add shared vCPU instance types for Hetzner; EUR -> USD Dec 10, 2024
@nelsonic
Copy link
Contributor Author

Cool. Perhaps a backlog item to use IPv6 for all admin (ssh) tasks to not rely on IPv4 which wastes address space. 💭
I'm fine to pay the extra €2.50/month (2 x LBs + 3 PG instances) but it definitely feels wasteful. 💸 😜 (€30/year ...)

Going to include the IPv4 Address in my update just to get this PR over the line. 🧑‍💻 ⏳

@vitabaks vitabaks changed the title PR: Add shared vCPU instance types for Hetzner; EUR -> USD PR: Add shared vCPU instance types for Hetzner; EUR -> USD Dec 10, 2024
@vitabaks vitabaks changed the title PR: Add shared vCPU instance types for Hetzner; EUR -> USD Hetzner: Add shared vCPU instance types; EUR -> USD Dec 10, 2024
@vitabaks
Copy link
Owner

until Expert Mode is implemented, you can simply delete public IP addresses after deployment.

@nelsonic
Copy link
Contributor Author

@vitabaks requested changes made. ✅
All AMD & Intel, Shared & Dedicated vCPU pricing with IPv4 included. 👌
Thanks again for your patience/help getting this PR over the line. 🏁

@vitabaks
Copy link
Owner

vitabaks commented Dec 10, 2024

Additionally, it would be helpful to include the ability to display in the UI that this is a shared vCPU. However, implementing this feature will require updates to both the API and UI.

I created a separate issue (#837) so that I don't forget about it in the future.
I will be grateful for the contribution in the implementation.

@nelsonic
Copy link
Contributor Author

@vitabaks happy to contribute further. Would you like it added in this PR or can it be a follow-up to keep changes separate? 💭

@vitabaks
Copy link
Owner

vitabaks commented Dec 10, 2024

Would you like it added in this PR or can it be a follow-up to keep changes separate?

We can create a separate PR for this.

@nelsonic
Copy link
Contributor Author

Curious why some of the checks are failing ... 🤷‍♂️

image

Anything I can do to help fix them? 🧑‍💻

Doesn't look like these errors have anything to do with the migration files ... 💭
https://github.com/vitabaks/autobase/actions/runs/12252845877/job/34198324505#step:6:261
image

@vitabaks
Copy link
Owner

These errors are not related to this PR, I am working on correcting the tests here #832

@nelsonic
Copy link
Contributor Author

@vitabaks LMK if this final commit is Ok. 👌
Don't want to keep moving the target as I know you're busy ... 🎯 ⏳
Thanks again. 🙏

@vitabaks
Copy link
Owner

Test

git clone --branch add-cx22-instance-issue-834 --single-branch https://github.com/nelsonic/autobase.git
cd autobase
make docker-build-console

Console image: console:local

docker run -d --name autobase-console \
  --publish 80:80 \
  --publish 8080:8080 \
  --env PG_CONSOLE_API_URL=http://localhost:8080/api/v1 \
  --env PG_CONSOLE_AUTHORIZATION_TOKEN=secret_token \
  --env PG_CONSOLE_DOCKER_IMAGE=autobase/automation:latest \
  --volume console_postgres:/var/lib/postgresql \
  --volume /var/run/docker.sock:/var/run/docker.sock \
  --volume /tmp/ansible:/tmp/ansible \
  --restart=unless-stopped \
  console:local

Result:

image

Adding a column requires changes to the Console API service to support the new field.

@vitabaks
Copy link
Owner

vitabaks commented Dec 12, 2024

Test 2

Commit: 45b5bdc

Result:

image
image

postgres=# \d cloud_instances
                             Table "public.cloud_instances"
     Column     |            Type             | Collation | Nullable |      Default      
----------------+-----------------------------+-----------+----------+-------------------
 cloud_provider | text                        |           | not null | 
 instance_group | text                        |           | not null | 
 instance_name  | text                        |           | not null | 
 arch           | text                        |           | not null | 'amd64'::text
 cpu            | integer                     |           | not null | 
 ram            | integer                     |           | not null | 
 price_hourly   | numeric                     |           | not null | 
 price_monthly  | numeric                     |           | not null | 
 currency       | character(1)                |           | not null | '$'::bpchar
 updated_at     | timestamp without time zone |           |          | CURRENT_TIMESTAMP
 shared_cpu     | boolean                     |           |          | false
Indexes:
    "cloud_instances_pkey" PRIMARY KEY, btree (cloud_provider, instance_group, instance_name)
Foreign-key constraints:
    "cloud_instances_cloud_provider_fkey" FOREIGN KEY (cloud_provider) REFERENCES cloud_providers(provider_name)
Triggers:
    handle_updated_at BEFORE UPDATE ON cloud_instances FOR EACH ROW EXECUTE FUNCTION extensions.moddatetime('updated_at')

postgres=# select * from cloud_instances where cloud_provider = 'hetzner' and shared_cpu order by cpu, ram;
 cloud_provider | instance_group | instance_name | arch  | cpu | ram | price_hourly | price_monthly | currency |        updated_at         | shared_cpu 
----------------+----------------+---------------+-------+-----+-----+--------------+---------------+----------+---------------------------+------------
 hetzner        | Small Size     | CPX11         | amd64 |   2 |   2 |       0.0082 |          5.09 | $        | 2024-12-12 08:50:08.61843 | t
 hetzner        | Small Size     | CX22          | amd64 |   2 |   4 |       0.0074 |          4.59 | $        | 2024-12-10 00:00:00       | t
 hetzner        | Small Size     | CPX21         | amd64 |   3 |   4 |       0.0138 |          8.59 | $        | 2024-12-12 08:50:08.61843 | t
 hetzner        | Small Size     | CPX31         | amd64 |   4 |   8 |        0.025 |         15.59 | $        | 2024-12-10 00:00:00       | t
 hetzner        | Small Size     | CX32          | amd64 |   4 |   8 |       0.0127 |          7.59 | $        | 2024-12-10 00:00:00       | t
 hetzner        | Medium Size    | CPX41         | amd64 |   8 |  16 |       0.0464 |         28.09 | $        | 2024-12-10 00:00:00       | t
 hetzner        | Medium Size    | CX42          | amd64 |   8 |  16 |       0.0304 |         18.59 | $        | 2024-12-10 00:00:00       | t
 hetzner        | Medium Size    | CX52          | amd64 |  16 |  32 |       0.0611 |         36.09 | $        | 2024-12-10 00:00:00       | t
 hetzner        | Medium Size    | CPX51         | amd64 |  16 |  32 |       0.0979 |         61.09 | $        | 2024-12-10 00:00:00       | t
(9 rows)

postgres=# select * from cloud_instances where shared_cpu and cloud_provider != 'hetzner';
 cloud_provider | instance_group | instance_name | arch  | cpu | ram | price_hourly | price_monthly | currency |        updated_at         | shared_cpu 
----------------+----------------+---------------+-------+-----+-----+--------------+---------------+----------+---------------------------+------------
 aws            | Small Size     | t3.medium     | amd64 |   2 |   4 |        0.042 |        29.952 | $        | 2024-12-12 08:50:08.61843 | t
 aws            | Small Size     | t3.small      | amd64 |   2 |   2 |        0.021 |        14.976 | $        | 2024-12-12 08:50:08.61843 | t
 gcp            | Small Size     | e2-medium     | amd64 |   2 |   4 |        0.034 |        24.457 | $        | 2024-12-12 08:50:08.61843 | t
 gcp            | Small Size     | e2-small      | amd64 |   2 |   2 |        0.017 |        12.228 | $        | 2024-12-12 08:50:08.61843 | t
 azure          | Small Size     | Standard_B1ms | amd64 |   1 |   2 |        0.021 |        15.111 | $        | 2024-12-12 08:50:08.61843 | t
 azure          | Small Size     | Standard_B2s  | amd64 |   2 |   4 |        0.042 |        30.368 | $        | 2024-12-12 08:50:08.61843 | t
 digitalocean   | Small Size     | s-2vcpu-2gb   | amd64 |   2 |   2 |        0.027 |        18.000 | $        | 2024-12-12 08:50:08.61843 | t
 digitalocean   | Small Size     | s-2vcpu-4gb   | amd64 |   2 |   4 |        0.036 |        24.000 | $        | 2024-12-12 08:50:08.61843 | t
(8 rows)

passed

@vitabaks vitabaks merged commit 647dee2 into vitabaks:master Dec 12, 2024
15 checks passed
@nelsonic
Copy link
Contributor Author

Awesome @vitabaks 🚀

@nelsonic nelsonic deleted the add-cx22-instance-issue-834 branch December 12, 2024 10:20
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.

Why is Hetzner default instance CPX11 instead of CX22? 💭
3 participants