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)
72 lines
3.1 KiB
Ruby
72 lines
3.1 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
require_relative "../model"
|
|
|
|
class Location < Sequel::Model
|
|
include ResourceMethods
|
|
dataset_module Pagination
|
|
|
|
one_to_one :location_credential, key: :id
|
|
many_to_one :project
|
|
|
|
plugin :association_dependencies, location_credential: :destroy
|
|
|
|
HETZNER_FSN1_ID = "caa7a807-36c5-8420-a75c-f906839dad71"
|
|
HETZNER_HEL1_ID = "1f214853-0bc4-8020-b910-dffb867ef44f"
|
|
GITHUB_RUNNERS_ID = "6b9ef786-b842-8420-8c65-c25e3d4bdf3d"
|
|
LEASEWEB_WDC02_ID = "e0865080-9a3d-8020-a812-f5817c7afe7f"
|
|
|
|
dataset_module do
|
|
def for_project(project_id)
|
|
where(Sequel[project_id:] | {project_id: nil})
|
|
end
|
|
|
|
def visible_or_for_project(project_id)
|
|
where(Sequel[project_id:] | {project_id: nil, visible: true})
|
|
end
|
|
end
|
|
|
|
def visible_or_for_project?(proj_id)
|
|
(visible && project_id.nil?) || project_id == proj_id
|
|
end
|
|
|
|
def path
|
|
"/private-location/#{ui_name}"
|
|
end
|
|
|
|
# Private Locations only support Postgres resources for now
|
|
def has_resources
|
|
!project.postgres_resources_dataset.where(location_id: id).empty?
|
|
end
|
|
end
|
|
|
|
# Table: location
|
|
# Columns:
|
|
# id | uuid | PRIMARY KEY
|
|
# display_name | text | NOT NULL
|
|
# name | text | NOT NULL
|
|
# ui_name | text | NOT NULL
|
|
# visible | boolean | NOT NULL
|
|
# provider | text | NOT NULL
|
|
# project_id | uuid |
|
|
# Indexes:
|
|
# location_pkey | PRIMARY KEY btree (id)
|
|
# location_project_id_display_name_uidx | UNIQUE btree (project_id, display_name)
|
|
# location_project_id_ui_name_uidx | UNIQUE btree (project_id, ui_name)
|
|
# Foreign key constraints:
|
|
# location_project_id_fkey | (project_id) REFERENCES project(id)
|
|
# location_provider_fkey | (provider) REFERENCES provider(name)
|
|
# Referenced By:
|
|
# firewall | firewall_location_id_fkey | (location_id) REFERENCES location(id)
|
|
# inference_endpoint | inference_endpoint_location_id_fkey | (location_id) REFERENCES location(id)
|
|
# inference_router | inference_router_location_id_fkey | (location_id) REFERENCES location(id)
|
|
# kubernetes_cluster | kubernetes_cluster_location_id_fkey | (location_id) REFERENCES location(id)
|
|
# location_credential | location_credential_id_fkey | (id) REFERENCES location(id)
|
|
# minio_cluster | minio_cluster_location_id_fkey | (location_id) REFERENCES location(id)
|
|
# postgres_resource | postgres_resource_location_id_fkey | (location_id) REFERENCES location(id)
|
|
# private_subnet | private_subnet_location_id_fkey | (location_id) REFERENCES location(id)
|
|
# victoria_metrics_resource | victoria_metrics_resource_location_id_fkey | (location_id) REFERENCES location(id)
|
|
# vm | vm_location_id_fkey | (location_id) REFERENCES location(id)
|
|
# vm_host | vm_host_location_id_fkey | (location_id) REFERENCES location(id)
|
|
# vm_pool | vm_pool_location_id_fkey | (location_id) REFERENCES location(id)
|