Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
7400ecd
fix(clusters): keep the Flui network settings in the master boot script
dawit-io Oct 29, 2026
a1100da
feat(clusters): label nodes with their zone and region, and give flui…
dawit-io Oct 29, 2026
168235b
feat(storage): say what shared storage promises about confirmed writes
dawit-io Oct 29, 2026
6e0af39
feat(clusters): spread the cluster DNS across locations
dawit-io Oct 29, 2026
6548c70
feat(clusters): reach a cluster through any of its servers
dawit-io Oct 29, 2026
8a76143
feat(clusters): say what a cluster survives across three locations, a…
dawit-io Oct 29, 2026
a4d26b8
feat(databases): make a managed PostgreSQL highly available without s…
dawit-io Oct 29, 2026
291e296
feat(storage): replicated volumes that follow the application to anot…
dawit-io Oct 29, 2026
0b38d03
feat(applications): read replicated volumes from flui.yaml before the…
dawit-io Oct 29, 2026
5f6949d
feat(clusters): add the server or the node for data a cluster across …
dawit-io Oct 29, 2026
ab37638
feat(storage): show how much room is left on each node
dawit-io Oct 29, 2026
f3e2034
feat(clusters): resize nodes in the background, one at a time across …
dawit-io Oct 30, 2026
984d35c
feat(providers): find the bootstrap key another server registered a m…
dawit-io Nov 8, 2026
1e17ff8
feat(clusters): free the name of a cluster that was destroyed
dawit-io Nov 8, 2026
2a6d4a9
feat(storage): count the node that votes in replicated volumes
dawit-io Nov 8, 2026
5dad41e
feat(databases): finish the move to high availability once every copy…
dawit-io Nov 8, 2026
3aae265
feat(clusters): create a cluster across three locations in one step
dawit-io Nov 8, 2026
b8847a4
feat(providers): use @flui-cloud/infra 0.6.3
dawit-io Nov 8, 2026
dbcceeb
feat(clusters): offer high availability across the zones of OVH and S…
dawit-io Nov 8, 2026
6696c3a
feat(clusters): end a creation once Flui is installed or the cluster …
dawit-io Nov 8, 2026
4d1cf73
feat(databases): manage a highly available Postgres through its clust…
dawit-io Nov 8, 2026
a99b957
feat(databases): back up a highly available Postgres that started as …
dawit-io Nov 8, 2026
485a4a4
feat(clusters): say so when a creation stops because its cluster is d…
dawit-io Nov 8, 2026
d6ef8d8
feat(databases): keep a highly available Postgres failing over when a…
dawit-io Nov 19, 2026
9075b06
feat(providers): use @flui-cloud/infra 0.6.4 and @flui-cloud/spec 0.12.0
dawit-io Nov 19, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@
"dependencies": {
"@aws-sdk/client-s3": "^3.1041.0",
"@aws-sdk/s3-request-presigner": "^3.1041.0",
"@flui-cloud/infra": "^0.5.1",
"@flui-cloud/spec": "^0.11.0",
"@flui-cloud/infra": "^0.6.4",
"@flui-cloud/spec": "^0.12.0",
"@inquirer/prompts": "^7.10.1",
"@kubernetes/client-node": "^1.4.0",
"@nestjs/axios": "^4.0.0",
Expand Down
20 changes: 10 additions & 10 deletions cli/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

215 changes: 187 additions & 28 deletions cli/src/commands/cluster/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,70 @@ import { listClusters } from '../../lib/cluster-listing';
import { getRecommendedServerType } from '../../config/defaults';

const POLL_INTERVAL_MS = 5000;
const MAX_WAIT_MS = 1_800_000; // 30 min — matches the server-side estimate for master + N workers
// The API waits for the install to end too, and gives a creation up to an hour.
const MAX_WAIT_MS = 3_600_000;

/** The sizes asked for, in order; the node size alone when none were. */
function sizesOf(raw: string | undefined, nodeSize: string): string[] {
const sizes = (raw ?? '')
.split(',')
.map((s) => s.trim())
.filter(Boolean);
return sizes.length ? sizes : [nodeSize];
}

function nodeLines(plan: HaPlan | null, workerCount: number): string[] {
if (!plan) return [` ${chalk.bold('Worker nodes:')} ${workerCount}`];
const width = Math.max(
6,
...plan.servers.map((s) => s.zone.length),
...plan.later.map((zone) => zone.length),
);
return [
` ${chalk.bold('Availability:')} three locations (${plan.region})`,
...plan.servers.map((s) => {
const role = s.role === 'data' ? 'copies of data' : 'votes';
const first = s.first ? ', starts the cluster' : '';
return ` ${s.zone.padEnd(width)} ${s.shape.padEnd(8)} ${role}${first}`;
}),
...plan.later.map(
(zone) =>
` ${zone.padEnd(width)} ${chalk.yellow('none available now: add it later')}`,
),
...(plan.measured === false
? [
chalk.dim(
' The provider declares these as close zones of one region; Flui has not measured them yet.',
),
]
: []),
];
}

function haRequest(
ha: boolean,
sizes: string[],
completeLater: boolean,
): Record<string, unknown> {
if (!ha) return {};
return {
highAvailability: 'three-locations',
shapes: sizes,
...(completeLater ? { completeLater: true } : {}),
};
}

interface HaPlan {
region: string;
measured?: boolean;
servers: Array<{
zone: string;
shape: string;
role: 'data' | 'vote';
first: boolean;
}>;
later: string[];
}

export default class ClusterCreate extends Command {
static readonly description =
Expand All @@ -23,6 +86,7 @@ export default class ClusterCreate extends Command {
'<%= config.bin %> <%= command.id %> edge --provider hetzner --region hel1',
'<%= config.bin %> <%= command.id %> edge --provider byos --flui-network',
'<%= config.bin %> <%= command.id %> edge --vnet 3f2a… --subnet 9c1b…',
'<%= config.bin %> <%= command.id %> ha-hz --ha --region fsn1 --sizes cpx22,cx23',
];

static readonly args = {
Expand Down Expand Up @@ -76,8 +140,102 @@ export default class ClusterCreate extends Command {
description: 'Return immediately after queuing creation',
default: false,
}),
ha: Flags.boolean({
description:
'Highly available across three locations: one server in each location ' +
'the provider validated for this region, bought together and joined one ' +
"at a time. --region is the first server's location, one for data.",
default: false,
}),
sizes: Flags.string({
description:
'With --ha: the sizes each location may take, comma separated, in order ' +
'of preference. Each location gets the first one it has available. ' +
'Defaults to --node-size.',
dependsOn: ['ha'],
}),
'complete-later': Flags.boolean({
description:
'With --ha: when a location has none of the sizes available, create the ' +
'cluster in the others and add that server later. Off, nothing is bought.',
default: false,
dependsOn: ['ha'],
}),
};

private refuseWorkersWithHa(ha: boolean, workerCount: number): void {
if (!ha || workerCount === 0) return;
this.error(
'A cluster across three locations starts with its three servers; add workers once it is ready.',
{ exit: 1 },
);
}

private async ensureNameFree(
apiClient: ApiClient,
name: string,
provider: string,
): Promise<void> {
const spinner = ora(`Checking "${name}" is free on ${provider}...`).start();
let taken: string | null = null;
try {
const availability = await apiClient.get<{
available: boolean;
reason?: string;
}>(
`/infrastructure/clusters/name-availability?name=${encodeURIComponent(name)}&provider=${encodeURIComponent(provider)}`,
);
if (availability.available) spinner.succeed('Name available');
else taken = availability.reason ?? 'Name not available';
} catch (error: any) {
// Best-effort — the create call re-validates server-side regardless.
spinner.warn(
`Could not pre-check name availability: ${error.message} — continuing`,
);
}
if (taken) {
// Outside the try: oclif's exit is an exception the catch would swallow.
spinner.fail(taken);
this.exit(1);
}
}

private async haPlan(
apiClient: ApiClient,
ha: boolean,
query: {
provider: string;
region: string;
shapes: string[];
completeLater: boolean;
},
): Promise<HaPlan | null> {
if (!ha) return null;
const params = new URLSearchParams({
provider: query.provider,
region: query.region,
shapes: query.shapes.join(','),
completeLater: String(query.completeLater),
});
const plan = await apiClient.get<
HaPlan & {
layoutAvailable: boolean;
possible: boolean;
refusal: string | null;
}
>(`/infrastructure/clusters/high-availability/plan?${params}`);
if (!plan.possible) {
this.error(
plan.refusal ??
'This cluster cannot be created across three locations.',
{
exit: 1,
},
);
}
return plan;
}

async run(): Promise<void> {
const { args, flags } = await this.parse(ClusterCreate);

Expand Down Expand Up @@ -154,37 +312,28 @@ export default class ClusterCreate extends Command {
if (flags.subnet && !flags.vnet) {
this.error('--subnet needs the --vnet it belongs to.', { exit: 1 });
}
this.refuseWorkersWithHa(flags.ha, flags['worker-count']);
const sizes = sizesOf(flags.sizes, nodeSize);

const spinner = ora(
`Checking "${args.name}" is free on ${provider}...`,
).start();
try {
const availability = await apiClient.get<{
available: boolean;
reason?: string;
}>(
`/infrastructure/clusters/name-availability?name=${encodeURIComponent(args.name)}&provider=${encodeURIComponent(provider)}`,
);
if (!availability.available) {
spinner.fail(availability.reason ?? 'Name not available');
this.exit(1);
}
spinner.succeed('Name available');
} catch (error: any) {
// Best-effort — the create call re-validates server-side regardless.
spinner.warn(
`Could not pre-check name availability: ${error.message} — continuing`,
);
}
await this.ensureNameFree(apiClient, args.name, provider);

const haPlan = await this.haPlan(apiClient, flags.ha, {
provider,
region,
shapes: sizes,
completeLater: flags['complete-later'],
});

console.log('');
console.log(` ${chalk.bold('Name:')} ${args.name}`);
console.log(` ${chalk.bold('Provider:')} ${provider}`);
console.log(
` ${chalk.bold('Region:')} ${region || '(provider default)'}`,
);
console.log(` ${chalk.bold('Node size:')} ${nodeSize}`);
console.log(` ${chalk.bold('Worker nodes:')} ${flags['worker-count']}`);
console.log(` ${chalk.bold('Node size:')} ${sizes.join(', ')}`);
for (const line of nodeLines(haPlan, flags['worker-count'])) {
console.log(line);
}
if (fluiNetwork) {
console.log(
` ${chalk.bold('Network:')} built by Flui ` +
Expand All @@ -209,8 +358,9 @@ export default class ClusterCreate extends Command {
name: args.name,
provider,
region,
nodeSize,
nodeSize: sizes[0],
workerCount: flags['worker-count'],
...haRequest(flags.ha, sizes, flags['complete-later']),
...(fluiNetwork
? {
fluiManagedNetwork: flags['network-cidr']
Expand Down Expand Up @@ -253,23 +403,24 @@ export default class ClusterCreate extends Command {
return;
}

await this.waitForCreation(apiClient, operationId, args.name);
await this.waitForCreation(apiClient, operationId, args.name, MAX_WAIT_MS);
}

private async waitForCreation(
apiClient: ApiClient,
operationId: string,
clusterName: string,
maxWaitMs: number,
): Promise<void> {
console.log(
chalk.dim(
` Waiting for creation to complete (up to ${MAX_WAIT_MS / 60000} min)…`,
` Waiting for creation to complete (up to ${maxWaitMs / 60000} min)…`,
),
);
const waitSpinner = ora('Creating cluster…').start();
const started = Date.now();

while (Date.now() - started < MAX_WAIT_MS) {
while (Date.now() - started < maxWaitMs) {
await new Promise((r) => setTimeout(r, POLL_INTERVAL_MS));
const result = await this.pollOperation(
apiClient,
Expand Down Expand Up @@ -319,6 +470,14 @@ export default class ClusterCreate extends Command {
console.log(chalk.red(`\n Error: ${msg}\n`));
return 'failed';
}
if (op.status === 'CANCELLED') {
waitSpinner.warn('Creation stopped');
const msg =
op.metadata?.message ??
'The cluster was deleted while it was created';
console.log(chalk.yellow(`\n ${msg}\n`));
return 'failed';
}
} catch {
/* polling error — keep trying */
}
Expand Down
Loading
Loading