Skip to content

Commit

Permalink
Add a 16GB swap volume to VM's
Browse files Browse the repository at this point in the history
  • Loading branch information
drakon64 committed Dec 6, 2024
1 parent 7083160 commit f84782d
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
9 changes: 9 additions & 0 deletions EventProcessors/GitHubWebhookEventProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,11 @@ await GoogleClient.CreateInstance(
$"projects/ubuntu-os-cloud/global/images/ubuntu-minimal-2404-noble-{architecture}-v20241116", // TODO: Don't hardcode this
},
},
new Disk
{
DeviceName = "swap",
InitializeParams = new DiskInitializeParams { DiskSizeGb = "16" },
},
],
Metadata = new Metadata
{
Expand All @@ -121,6 +126,10 @@ await GoogleClient.CreateInstance(
Key = "startup-script",
Value = $"""
#!/bin/sh -ex
sysctl vm.swappiness=1
mkswap /dev/disk/by-id/google-swap
swapon /dev/disk/by-id/google-swap
curl -sSO https://dl.google.com/cloudagents/add-google-cloud-ops-agent-repo.sh
bash add-google-cloud-ops-agent-repo.sh --also-install
Expand Down
5 changes: 3 additions & 2 deletions Models/GoogleCloud/Compute/Instances/Disks/Disk.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ namespace Ktisis.Models.GoogleCloud.Compute.Instances.Disks;

internal class Disk
{
public bool AutoDelete = true;
public required bool Boot { get; init; }
public string? DeviceName { get; init; }
public bool? Boot { get; init; }
public required DiskInitializeParams InitializeParams { get; init; }
public bool AutoDelete = true;
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ namespace Ktisis.Models.GoogleCloud.Compute.Instances.Disks;

internal class DiskInitializeParams
{
public required string SourceImage { get; init; }
public string? SourceImage { get; init; }
public required string DiskSizeGb { get; init; }
public string DiskType =
$"projects/{Program.Project}/zones/{Program.Zone}/diskTypes/hyperdisk-balanced";
Expand Down

0 comments on commit f84782d

Please sign in to comment.