mirror of
https://gitlab.com/TECHNOFAB/nixlets.git
synced 2025-12-11 17:40:07 +01:00
feat: add surrealdb nixlet
This commit is contained in:
parent
b343866134
commit
ba81fba6b2
5 changed files with 140 additions and 0 deletions
|
|
@ -25,6 +25,7 @@
|
|||
attic = utils.mkNixlet ./nixlets/attic;
|
||||
postgres = utils.mkNixlet ./nixlets/postgres;
|
||||
tikv = utils.mkNixlet ./nixlets/tikv;
|
||||
surrealdb = utils.mkNixlet ./nixlets/surrealdb;
|
||||
};
|
||||
};
|
||||
perSystem = {
|
||||
|
|
|
|||
6
nixlets/surrealdb/default.nix
Normal file
6
nixlets/surrealdb/default.nix
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
{...}: {
|
||||
imports = [
|
||||
./deployment.nix
|
||||
./service.nix
|
||||
];
|
||||
}
|
||||
56
nixlets/surrealdb/deployment.nix
Normal file
56
nixlets/surrealdb/deployment.nix
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
{
|
||||
values,
|
||||
lib,
|
||||
...
|
||||
}: {
|
||||
kubernetes.resources = {
|
||||
deployments."${values.uniqueName}" = {
|
||||
spec = {
|
||||
replicas = values.replicaCount;
|
||||
selector.matchLabels.app = "${values.uniqueName}";
|
||||
template = {
|
||||
metadata.labels.app = "${values.uniqueName}";
|
||||
spec = {
|
||||
securityContext = {
|
||||
fsGroup = 1000;
|
||||
runAsUser = 1000;
|
||||
runAsGroup = 1000;
|
||||
};
|
||||
containers."surrealdb" = rec {
|
||||
image = "${values.image.repository}:${values.image.tag}";
|
||||
imagePullPolicy = values.image.pullPolicy;
|
||||
args = ["start"];
|
||||
env = [
|
||||
{
|
||||
name = "SURREAL_NO_BANNER";
|
||||
value = "true";
|
||||
}
|
||||
{
|
||||
name = "SURREAL_PATH";
|
||||
value = values.surrealdb.path;
|
||||
}
|
||||
{
|
||||
name = "SURREAL_LOG";
|
||||
value = values.surrealdb.log;
|
||||
}
|
||||
{
|
||||
name = "SURREAL_BIND";
|
||||
value = "0.0.0.0:8000";
|
||||
}
|
||||
];
|
||||
envFrom = [
|
||||
{secretRef.name = "${values.uniqueName}-env";}
|
||||
];
|
||||
ports."http".containerPort = 8000;
|
||||
livenessProbe.httpGet = {
|
||||
path = "/health";
|
||||
port = "http";
|
||||
};
|
||||
readinessProbe = livenessProbe;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
17
nixlets/surrealdb/service.nix
Normal file
17
nixlets/surrealdb/service.nix
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
{values, ...}: {
|
||||
kubernetes.resources = {
|
||||
services."${values.uniqueName}" = {
|
||||
spec = {
|
||||
selector.app = "${values.uniqueName}";
|
||||
ports = [
|
||||
{
|
||||
name = "http";
|
||||
targetPort = "http";
|
||||
port = values.service.port;
|
||||
}
|
||||
];
|
||||
type = values.service.type;
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
60
nixlets/surrealdb/values.nix
Normal file
60
nixlets/surrealdb/values.nix
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
{
|
||||
lib,
|
||||
utils,
|
||||
project,
|
||||
...
|
||||
}:
|
||||
with lib; {
|
||||
# for some basic values see https://github.com/helm/examples/blob/4888ba8fb8180dd0c36d1e84c1fcafc6efd81532/charts/hello-world/values.yaml
|
||||
options = {
|
||||
replicaCount = mkOption {
|
||||
type = types.int;
|
||||
default = 1;
|
||||
};
|
||||
image = utils.mkNestedOption {
|
||||
repository = mkOption {
|
||||
type = types.str;
|
||||
default = "surrealdb/surrealdb";
|
||||
};
|
||||
pullPolicy = mkOption {
|
||||
type = types.str;
|
||||
default = "IfNotPresent";
|
||||
};
|
||||
tag = mkOption {
|
||||
type = types.str;
|
||||
default = "latest";
|
||||
};
|
||||
};
|
||||
service = utils.mkNestedOption {
|
||||
port = mkOption {
|
||||
type = types.int;
|
||||
default = 8000;
|
||||
};
|
||||
type = mkOption {
|
||||
type = types.str;
|
||||
default = "ClusterIP";
|
||||
};
|
||||
};
|
||||
surrealdb = utils.mkNestedOption {
|
||||
log = mkOption {
|
||||
type = types.str;
|
||||
default = "info";
|
||||
};
|
||||
path = mkOption {
|
||||
type = types.str;
|
||||
default = "memory";
|
||||
description = ''
|
||||
Path to database.
|
||||
Examples: "memory", "file://<path>", "tikv://<tikv-pd-service>:2379"
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
# internal
|
||||
uniqueName = mkOption {
|
||||
internal = true;
|
||||
type = types.str;
|
||||
default = "${project}-surrealdb";
|
||||
};
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue