From 21b269c5f8c76ad8c51524031dad7ecc94b18096 Mon Sep 17 00:00:00 2001 From: Manuel Dewald Date: Fri, 13 Mar 2026 17:06:34 +0100 Subject: [PATCH] feat(bootstrap-gcp): Shrink footprint --- internal/bootstrap/gcp/gcp.go | 48 +++++++------------- internal/installer/config_manager_profile.go | 25 +++++++--- internal/installer/resource_profiles.go | 24 ++++++++++ 3 files changed, 59 insertions(+), 38 deletions(-) diff --git a/internal/bootstrap/gcp/gcp.go b/internal/bootstrap/gcp/gcp.go index 11a2ba5e..a02c340d 100644 --- a/internal/bootstrap/gcp/gcp.go +++ b/internal/bootstrap/gcp/gcp.go @@ -91,14 +91,13 @@ type VMDef struct { // Example VM definitions (expand as needed) var vmDefs = []VMDef{ {"jumpbox", "e2-medium", []string{"jumpbox", "ssh"}, []int64{}, true}, - {"postgres", "e2-standard-8", []string{"postgres"}, []int64{}, true}, - {"ceph-1", "e2-standard-8", []string{"ceph"}, []int64{20, 200}, false}, - {"ceph-2", "e2-standard-8", []string{"ceph"}, []int64{20, 200}, false}, - {"ceph-3", "e2-standard-8", []string{"ceph"}, []int64{20, 200}, false}, - {"ceph-4", "e2-standard-8", []string{"ceph"}, []int64{20, 200}, false}, - {"k0s-1", "e2-standard-16", []string{"k0s"}, []int64{}, false}, - {"k0s-2", "e2-standard-16", []string{"k0s"}, []int64{}, false}, - {"k0s-3", "e2-standard-16", []string{"k0s"}, []int64{}, false}, + {"postgres", "e2-standard-4", []string{"postgres"}, []int64{}, true}, + {"ceph-1", "e2-standard-4", []string{"ceph"}, []int64{10, 100}, false}, + {"ceph-2", "e2-standard-4", []string{"ceph"}, []int64{10, 100}, false}, + {"ceph-3", "e2-standard-4", []string{"ceph"}, []int64{10, 100}, false}, + {"k0s-1", "e2-standard-8", []string{"k0s"}, []int64{}, false}, + {"k0s-2", "e2-standard-8", []string{"k0s"}, []int64{}, false}, + {"k0s-3", "e2-standard-8", []string{"k0s"}, []int64{}, false}, } var DefaultExperiments []string = []string{ @@ -1177,11 +1176,11 @@ func (b *GCPBootstrapper) UpdateInstallConfig() error { HostPattern: "*", }, DataDevices: files.CephDataDevices{ - Size: "100G:", + Size: "50G:", Limit: 1, }, DBDevices: files.CephDBDevices{ - Size: "10G:500G", + Size: "10G:50G", Limit: 1, }, }, @@ -1208,26 +1207,13 @@ func (b *GCPBootstrapper) UpdateInstallConfig() error { }, }, } - b.Env.InstallConfig.Cluster.Monitoring = &files.MonitoringConfig{ - Prometheus: &files.PrometheusConfig{ - RemoteWrite: &files.RemoteWriteConfig{ - Enabled: false, - ClusterName: "GCP-test", - }, - }, + b.Env.InstallConfig.Cluster.Gateway.ServiceType = "LoadBalancer" + b.Env.InstallConfig.Cluster.Gateway.Annotations = map[string]string{ + "cloud.google.com/load-balancer-ipv4": b.Env.GatewayIP, } - b.Env.InstallConfig.Cluster.Gateway = files.GatewayConfig{ - ServiceType: "LoadBalancer", - //IPAddresses: []string{b.Env.ControlPlaneNodes[0].ExternalIP}, - Annotations: map[string]string{ - "cloud.google.com/load-balancer-ipv4": b.Env.GatewayIP, - }, - } - b.Env.InstallConfig.Cluster.PublicGateway = files.GatewayConfig{ - ServiceType: "LoadBalancer", - Annotations: map[string]string{ - "cloud.google.com/load-balancer-ipv4": b.Env.PublicGatewayIP, - }, + b.Env.InstallConfig.Cluster.PublicGateway.ServiceType = "LoadBalancer" + b.Env.InstallConfig.Cluster.PublicGateway.Annotations = map[string]string{ + "cloud.google.com/load-balancer-ipv4": b.Env.PublicGatewayIP, } dnsProject := b.Env.DNSProjectID @@ -1276,8 +1262,8 @@ func (b *GCPBootstrapper) UpdateInstallConfig() error { BomRef: "workspace-agent-24.04", }, Pool: map[int]int{ - 1: 1, - 2: 1, + 1: 0, + 2: 0, 3: 0, }, }, diff --git a/internal/installer/config_manager_profile.go b/internal/installer/config_manager_profile.go index dbd79791..d95fcb2b 100644 --- a/internal/installer/config_manager_profile.go +++ b/internal/installer/config_manager_profile.go @@ -142,20 +142,20 @@ func (g *InstallConfig) ApplyProfile(profile string) error { switch profile { case PROFILE_DEV, PROFILE_DEVELOPMENT: g.Config.Datacenter.Name = "dev" - if err := ApplyResourceProfile(g.Config, ResourceProfileNoRequests); err != nil { - return fmt.Errorf("applying resource profile: %w", err) - } g.Config.Cluster.Monitoring = &files.MonitoringConfig{ Prometheus: &files.PrometheusConfig{ RemoteWrite: &files.RemoteWriteConfig{ Enabled: false, - ClusterName: "local-test", + ClusterName: "dev", }, }, Loki: &files.LokiConfig{Enabled: false}, Grafana: &files.GrafanaConfig{Enabled: false}, GrafanaAlloy: &files.GrafanaAlloyConfig{Enabled: false}, } + if err := ApplyResourceProfile(g.Config, ResourceProfileNoRequests); err != nil { + return fmt.Errorf("applying resource profile: %w", err) + } case PROFILE_PROD, PROFILE_PRODUCTION: g.Config.Datacenter.Name = "production" @@ -169,9 +169,17 @@ func (g *InstallConfig) ApplyProfile(profile string) error { } case PROFILE_MINIMAL: - g.Config.Datacenter.Name = "minimal" - if err := ApplyResourceProfile(g.Config, ResourceProfileNoRequests); err != nil { - return fmt.Errorf("applying resource profile: %w", err) + g.Config.Datacenter.Name = "dev" + g.Config.Cluster.Monitoring = &files.MonitoringConfig{ + Prometheus: &files.PrometheusConfig{ + RemoteWrite: &files.RemoteWriteConfig{ + Enabled: false, + ClusterName: "dev", + }, + }, + Loki: &files.LokiConfig{Enabled: true}, + Grafana: &files.GrafanaConfig{Enabled: true}, + GrafanaAlloy: &files.GrafanaAlloyConfig{Enabled: true}, } g.Config.Codesphere.Plans.WorkspacePlans = map[int]files.WorkspacePlan{ 1: { @@ -181,6 +189,9 @@ func (g *InstallConfig) ApplyProfile(profile string) error { OnDemand: true, }, } + if err := ApplyResourceProfile(g.Config, ResourceProfileNoRequests); err != nil { + return fmt.Errorf("applying resource profile: %w", err) + } default: return fmt.Errorf("unknown profile: %s, available profiles: dev, prod, minimal", profile) diff --git a/internal/installer/resource_profiles.go b/internal/installer/resource_profiles.go index e6e1a7a1..e26925e4 100644 --- a/internal/installer/resource_profiles.go +++ b/internal/installer/resource_profiles.go @@ -105,6 +105,21 @@ func applyNoRequestsProfile(config *files.RootConfig) { }, }) + if config.Cluster.Monitoring.Loki == nil { + config.Cluster.Monitoring.Loki = &files.LokiConfig{} + } + config.Cluster.Monitoring.Loki.Override = util.DeepMergeMaps(config.Cluster.Monitoring.Loki.Override, map[string]any{ + "loki": map[string]any{ + "read": minimalResourceValues(), + "write": minimalResourceValues(), + "backend": minimalResourceValues(), + "resultsCache": minimalResourceValues(), + "chunksCache": minimalResourceValues(), + "canary": minimalResourceValues(), + "gateway": minimalResourceValues(), + }, + }) + if config.Cluster.Monitoring.PushGateway == nil { config.Cluster.Monitoring.PushGateway = &files.PushGatewayConfig{} } @@ -180,3 +195,12 @@ func zeroRequests() map[string]int { "memory": 0, } } + +func minimalResourceValues() map[string]any { + return map[string]any{ + "replicas": 1, + "resources": map[string]any{ + "requests": zeroRequests(), + }, + } +}