Skip to content

Commit

Permalink
Support edge clusters which already have Flux (#353)
Browse files Browse the repository at this point in the history
Most obviously, we want to deploy an edge cluster onto the same cluster
as our central cluster, to support the F+ 'soft gateway' concept. Our
central cluster is already managed with Flux and Sealed Secrets, so the
edge cluster bootstrap script must not attempt to install them again.

Also:
* Deploy the cluster manager service entries from service-setup.
* Deploy the cluster manager account via krbkeys, meaning it no longer
has a fixed UUID.
* Make the cluster bootstrap script a little friendlier.
  • Loading branch information
amrc-benmorrow authored Oct 8, 2024
2 parents 469367e + 98421d1 commit c74efce
Show file tree
Hide file tree
Showing 16 changed files with 341 additions and 552 deletions.
45 changes: 0 additions & 45 deletions acs-cluster-manager/bin/convert-dumps.js

This file was deleted.

99 changes: 0 additions & 99 deletions acs-cluster-manager/dumps/clusters-auth.yaml

This file was deleted.

68 changes: 0 additions & 68 deletions acs-cluster-manager/dumps/clusters-configdb.yaml

This file was deleted.

7 changes: 6 additions & 1 deletion acs-cluster-manager/lib/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* Copyright 2023 AMRC
*/

import jmp from "json-merge-patch";
import rx from "rxjs";
import yaml from "yaml";

Expand Down Expand Up @@ -169,8 +170,9 @@ export class Update extends Action {

/* Build the cluster helm chart template */
const cluster = cluster_template({ uuid, name });
const values = jmp.merge(cluster.values, spec.values ?? {});
/* Build the cluster HelmRelease manifest */
const helm = template.helm({ uuid, ...cluster }).template;
const helm = template.helm({ ...cluster, uuid, values }).template;
helm.metadata.namespace = spec.namespace;
/* Build the initial repo contents */
const flux = template.flux({
Expand All @@ -182,6 +184,9 @@ export class Update extends Action {
},
});

if (spec.bare)
delete flux["flux-system.yaml"];

return flux;
}
}
Expand Down
9 changes: 6 additions & 3 deletions acs-cluster-manager/lib/clusters.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,14 @@ export class Clusters {
.subscribe(() => process.exit(0));

this.config = await cdb.get_config(
UUIDs.App.ServiceConfig, Edge.Service.EdgeDeployment);
UUIDs.App.ServiceConfig, Edge.Service.EdgeDeployment)
.catch(() => null);

/* If we have no SS config, wait 10 minutes and then exit */
/* If we have no SS config, wait 2 minutes and then exit */
if (!this.config) {
await timers.setTimeout(10*60*1000);
this.log("No SS config, restarting in 2 minutes...");
await timers.setTimeout(2*60*1000);
this.log("Restarting to reload SS config");
process.exit(0);
}
}
Expand Down
1 change: 0 additions & 1 deletion acs-cluster-manager/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
"type": "module",
"scripts": {
"start": "node bin/edge-deployment.js",
"convert-dumps": "node bin/convert-dumps.js",
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class CreateEdgeClusterAction
* This action creates a new edge cluster
**/

public function execute(string $name, string $chart)
public function execute(string $name, string $chart, bool $bare)
{
// =========================
// Validate User Permissions
Expand All @@ -42,12 +42,20 @@ public function execute(string $name, string $chart)
"name" => $name,
]);

// Create an entry in the Edge Cluster Configuration app
$configDB->putConfig(App::EdgeClusterConfiguration, $uuid, [
'chart' => $chart,
$cconf = [
"chart" => $chart,
"name" => $name,
"namespace" => 'fplus-edge',
]);
"namespace" => "fplus-edge",
];
if ($bare) {
$cconf["bare"] = true;
$cconf["values"] = [
"sealedSecrets" => ["enabled" => false],
];
}

// Create an entry in the Edge Cluster Configuration app
$configDB->putConfig(App::EdgeClusterConfiguration, $uuid, $cconf);

return action_success();
}
Expand Down
6 changes: 5 additions & 1 deletion acs-manager/app/Http/Controllers/EdgeClusterController.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@ public function create(CreateEdgeClusterRequest $request)
$validated = $request->validated();

return process_action(
(new CreateEdgeClusterAction())->execute(name: $validated['name'], chart: $validated['chart'])
(new CreateEdgeClusterAction())->execute(
name: $validated['name'],
chart: $validated['chart'],
bare: $validated['bare'],
)
);
}

Expand Down
11 changes: 11 additions & 0 deletions acs-manager/app/Http/Requests/CreateEdgeClusterRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,17 @@ public function rules()
'uuid',
'string',
],
'bare' => [
'boolean',
],
];
}

public function prepareForValidation(): void
{
$bare = $this->input("bare");
$this->merge([
"bare" => ($bare == "true"),
]);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,11 @@ export default {
dataType: 'static',
data: null,
},
bare: {
dataType: 'collected',
dataSource: ['clusterConfiguration', 'controls', 'bare', 'value'],
data: false,
},
},
},
clusterConfiguration: {
Expand Down Expand Up @@ -127,7 +132,18 @@ export default {
disabled: false,
initialValue: '',
value: '',
}
},
bare: {
name: 'Bare deployment',
description: 'We already have Flux and Sealed Secrets deployed.',
type: 'checkbox',
validations: {
required: helpers.withMessage('Please choose', required),
},
disabled: false,
initialValue: false,
value: false,
},
},
buttons: [
{
Expand Down
Loading

0 comments on commit c74efce

Please sign in to comment.