Files
ubicloud/migrate/20250425_victoria_metrics_resource.rb
shikharbhardwaj 895499939c Create VictoriaMetrics resource
This is the initial commit for the Victoriametrics resource. This is a
basic version which supports creating a single-node Victoriametrics
instance backed by a VM, creating and managing appropriate certs and
authentication configuration. This version:
- Installs victoriametrics and vmauth binaries on the VM
- Configures the systemd services for these two services
- Sets up the certificates and http basic authentication credentials

This implementation only supports a single-node version for simplicity,
as current read/write benchmarks show VictoriaMetrics can support
upto 4k write targets (PG instnaces, for eg.) and around 2k concurrent
read users on a single standard-8 VM.  In the future, we can add support
for cluster mode, migrations, backup etc as needed.

Here is an example command to create a VictoriaMetrics resource:
st = Prog::VictoriaMetrics::VictoriaMetricsResourceNexus.assemble(
Config.victoria_metrics_service_project_id,
"victoriametrics-test", Location::HETZNER_FSN1_ID, "vmuser",
"standard-8", 20)
2025-05-01 21:55:32 +05:30

33 lines
1.5 KiB
Ruby

# frozen_string_literal: true
Sequel.migration do
change do
create_table(:victoria_metrics_resource) do
column :id, :uuid, primary_key: true
column :name, :text, null: false
column :created_at, :timestamptz, null: false, default: Sequel.lit("now()")
column :admin_user, :text, collate: '"C"', null: false
column :admin_password, :text, collate: '"C"', null: false
column :target_vm_size, :text, collate: '"C"', null: false
column :target_storage_size_gib, :bigint, null: false
column :root_cert_1, :text, collate: '"C"'
column :root_cert_key_1, :text, collate: '"C"'
column :root_cert_2, :text, collate: '"C"'
column :root_cert_key_2, :text, collate: '"C"'
column :certificate_last_checked_at, :timestamptz, null: false, default: Sequel.lit("now()")
foreign_key :project_id, :project, type: :uuid, null: false
foreign_key :location_id, :location, type: :uuid, null: false
foreign_key :private_subnet_id, :private_subnet, type: :uuid, null: true
end
create_table(:victoria_metrics_server) do
column :id, :uuid, primary_key: true
column :created_at, :timestamptz, null: false, default: Sequel.lit("now()")
column :cert, :text, collate: '"C"'
column :cert_key, :text, collate: '"C"'
column :certificate_last_checked_at, :timestamptz, null: false, default: Sequel.lit("now()")
foreign_key :victoria_metrics_resource_id, :victoria_metrics_resource, type: :uuid, null: false
foreign_key :vm_id, :vm, type: :uuid, null: false
end
end
end