mirror of
https://github.com/trustgraph-ai/trustgraph.git
synced 2026-07-06 11:52:10 +02:00
Squashed 'ai-context/trustgraph-templates/' content from commit 42a5fd1b
git-subtree-dir: ai-context/trustgraph-templates git-subtree-split: 42a5fd1b678f32be378062e30451e2052ccb95dd
This commit is contained in:
commit
74cc8a4685
1216 changed files with 116347 additions and 0 deletions
45
trustgraph_configurator/templates/2.2/engine/aks-k8s.jsonnet
Normal file
45
trustgraph_configurator/templates/2.2/engine/aks-k8s.jsonnet
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
|
||||
local k8s = import "k8s.jsonnet";
|
||||
|
||||
local ns = {
|
||||
apiVersion: "v1",
|
||||
kind: "Namespace",
|
||||
metadata: {
|
||||
name: "trustgraph",
|
||||
},
|
||||
"spec": {
|
||||
},
|
||||
};
|
||||
|
||||
local sc = {
|
||||
apiVersion: "storage.k8s.io/v1",
|
||||
kind: "StorageClass",
|
||||
metadata: {
|
||||
name: "tg",
|
||||
},
|
||||
provisioner: "disk.csi.azure.com",
|
||||
parameters: {
|
||||
// Standard disks (spinning magnetic), Locally Redundant Storage
|
||||
// Cheapest, basically
|
||||
skuName: "Standard_LRS",
|
||||
},
|
||||
reclaimPolicy: "Delete",
|
||||
volumeBindingMode: "WaitForFirstConsumer",
|
||||
};
|
||||
|
||||
k8s + {
|
||||
|
||||
// Extract resources usnig the engine
|
||||
package:: function(patterns)
|
||||
local resources = [sc, ns] + std.flattenArrays([
|
||||
p.create(self) for p in std.objectValues(patterns)
|
||||
]);
|
||||
local resourceList = {
|
||||
apiVersion: "v1",
|
||||
kind: "List",
|
||||
items: resources,
|
||||
};
|
||||
resourceList
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,260 @@
|
|||
{
|
||||
|
||||
// Extract resources using the engine
|
||||
package:: function(patterns)
|
||||
std.foldl(
|
||||
function(state, p) state + p.create(self),
|
||||
std.objectValues(patterns),
|
||||
{}
|
||||
),
|
||||
|
||||
container:: function(name)
|
||||
{
|
||||
|
||||
local container = self,
|
||||
|
||||
name:: name,
|
||||
|
||||
with_image:: function(x) self + { image: x },
|
||||
|
||||
with_user:: function(x) self + { user: x },
|
||||
|
||||
with_group:: function(x) self +
|
||||
if std.objectHas(container, "group_add") then
|
||||
{ group_add: container.group_add + [x] }
|
||||
else
|
||||
{ group_add: [x] },
|
||||
|
||||
with_command:: function(x) self + {
|
||||
command:
|
||||
if std.isString(x) then
|
||||
std.strReplace(x, "$", "$$")
|
||||
else if std.isArray(x) then
|
||||
std.map(function(s) std.strReplace(s, "$", "$$"), x)
|
||||
else
|
||||
x
|
||||
},
|
||||
|
||||
with_entrypoint:: function(x) self + { entrypoint: x },
|
||||
|
||||
with_runtime:: function(x) self + { runtime: x },
|
||||
|
||||
with_privileged:: function(x) self + { privileged: x },
|
||||
|
||||
with_ipc:: function(x) self + { ipc: x },
|
||||
|
||||
with_capability:: function(x) self +
|
||||
if std.objectHas(container, "capability") then
|
||||
{ cap_add: container.capability + x }
|
||||
else
|
||||
{ cap_add: [x], },
|
||||
|
||||
with_environment:: function(x) self +
|
||||
if std.objectHas(container, "environment") then
|
||||
{ environment: container.environment + x }
|
||||
else
|
||||
{ environment: x, },
|
||||
|
||||
with_device:: function(hdev, cdev) self +
|
||||
if std.objectHas(container, "devices") then
|
||||
{ devices: container.devices + [ "%s:%s" % [hdev, cdev] ] }
|
||||
else
|
||||
{ devices: [ "%s:%s" % [hdev, cdev] ], },
|
||||
|
||||
with_limits:: function(c, m) self + {
|
||||
deploy +: { resources +: {
|
||||
limits: { cpus: c, memory: m }
|
||||
} },
|
||||
},
|
||||
|
||||
with_reservations:: function(c, m) self + {
|
||||
deploy +: { resources +: {
|
||||
reservations: { cpus: c, memory: m }
|
||||
} },
|
||||
},
|
||||
|
||||
with_volume_mount::
|
||||
function(vol, mnt)
|
||||
self + {
|
||||
volumes:
|
||||
if std.objectHas(container, "volumes") then
|
||||
container.volumes + [
|
||||
"%s:%s" % [vol.volid, mnt]
|
||||
]
|
||||
else
|
||||
[
|
||||
"%s:%s" % [vol.volid, mnt]
|
||||
]
|
||||
},
|
||||
|
||||
with_bind_mount::
|
||||
function(src, dest)
|
||||
self + {
|
||||
volumes:
|
||||
if std.objectHas(container, "volumes") then
|
||||
container.volumes + [
|
||||
"%s:%s" % [src, dest]
|
||||
]
|
||||
else
|
||||
[
|
||||
"%s:%s" % [src, dest]
|
||||
]
|
||||
},
|
||||
|
||||
with_port::
|
||||
function(src, dest, name)
|
||||
self + {
|
||||
ports:
|
||||
if std.objectHas(container, "ports") then
|
||||
container.ports + [ "%d:%d" % [src, dest] ]
|
||||
else
|
||||
[ "%d:%d" % [src, dest] ]
|
||||
},
|
||||
|
||||
with_env_var_secrets::
|
||||
function(vars)
|
||||
std.foldl(
|
||||
function(obj, x) obj.with_environment(
|
||||
{ [x]: "${" + x + "}" }
|
||||
),
|
||||
vars.variables,
|
||||
self
|
||||
),
|
||||
|
||||
restart: "on-failure:100",
|
||||
|
||||
add:: function() {
|
||||
services +: {
|
||||
[container.name]: container,
|
||||
}
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
internalService:: function(containers)
|
||||
{
|
||||
|
||||
local service = self,
|
||||
|
||||
name: containers.name,
|
||||
|
||||
with_port:: function(src, dest, name)
|
||||
self + { port: [src, dest] },
|
||||
|
||||
add:: function() {
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
service:: function(containers)
|
||||
{
|
||||
|
||||
local service = self,
|
||||
|
||||
name: containers.name,
|
||||
|
||||
with_port:: function(src, dest, name)
|
||||
self + { port: [src, dest] },
|
||||
|
||||
add:: function() {
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
volume:: function(name)
|
||||
{
|
||||
|
||||
local volume = self,
|
||||
|
||||
name: name,
|
||||
|
||||
volid:: name,
|
||||
|
||||
with_size:: function(size) self + { size: size },
|
||||
|
||||
add:: function() {
|
||||
volumes +: {
|
||||
[volume.name]: {}
|
||||
}
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
configVolume:: function(name, dir, parts)
|
||||
{
|
||||
|
||||
local volume = self,
|
||||
|
||||
name: dir,
|
||||
|
||||
volid:: "./" + dir,
|
||||
|
||||
with_size:: function(size) self + { size: size },
|
||||
|
||||
add:: function() {
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
secretVolume:: function(name, dir, parts)
|
||||
{
|
||||
|
||||
local volume = self,
|
||||
|
||||
name: dir,
|
||||
|
||||
volid:: dir,
|
||||
|
||||
with_size:: function(size) self + { size: size },
|
||||
|
||||
add:: function() {
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
envSecrets:: function(name)
|
||||
{
|
||||
|
||||
local volume = self,
|
||||
|
||||
name: name,
|
||||
|
||||
volid:: name,
|
||||
|
||||
variables:: [],
|
||||
|
||||
with_env_var::
|
||||
function(name, key) self + {
|
||||
variables: super.variables + [name],
|
||||
},
|
||||
|
||||
add:: function() {
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
containers:: function(name, containers)
|
||||
{
|
||||
|
||||
local cont = self,
|
||||
|
||||
name: name,
|
||||
containers: containers,
|
||||
|
||||
add:: function() std.foldl(
|
||||
function(state, c) state + c.add(),
|
||||
cont.containers,
|
||||
{}
|
||||
),
|
||||
|
||||
},
|
||||
|
||||
resources:: function(res)
|
||||
std.foldl(
|
||||
function(state, c) state + c.add(),
|
||||
res,
|
||||
{}
|
||||
),
|
||||
|
||||
}
|
||||
|
||||
46
trustgraph_configurator/templates/2.2/engine/eks-k8s.jsonnet
Normal file
46
trustgraph_configurator/templates/2.2/engine/eks-k8s.jsonnet
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
|
||||
local k8s = import "k8s.jsonnet";
|
||||
|
||||
local ns = {
|
||||
apiVersion: "v1",
|
||||
kind: "Namespace",
|
||||
metadata: {
|
||||
name: "trustgraph",
|
||||
},
|
||||
"spec": {
|
||||
},
|
||||
};
|
||||
|
||||
local sc = {
|
||||
apiVersion: "storage.k8s.io/v1",
|
||||
kind: "StorageClass",
|
||||
metadata: {
|
||||
name: "tg",
|
||||
},
|
||||
provisioner: "ebs.csi.aws.com",
|
||||
parameters: {
|
||||
type: "gp3",
|
||||
encrypted: "true",
|
||||
iops: "6000",
|
||||
throughput: "400",
|
||||
},
|
||||
reclaimPolicy: "Delete",
|
||||
volumeBindingMode: "WaitForFirstConsumer",
|
||||
};
|
||||
|
||||
k8s + {
|
||||
|
||||
// Extract resources usnig the engine
|
||||
package:: function(patterns)
|
||||
local resources = [sc, ns] + std.flattenArrays([
|
||||
p.create(self) for p in std.objectValues(patterns)
|
||||
]);
|
||||
local resourceList = {
|
||||
apiVersion: "v1",
|
||||
kind: "List",
|
||||
items: resources,
|
||||
};
|
||||
resourceList
|
||||
|
||||
}
|
||||
|
||||
44
trustgraph_configurator/templates/2.2/engine/gcp-k8s.jsonnet
Normal file
44
trustgraph_configurator/templates/2.2/engine/gcp-k8s.jsonnet
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
|
||||
local k8s = import "k8s.jsonnet";
|
||||
|
||||
local ns = {
|
||||
apiVersion: "v1",
|
||||
kind: "Namespace",
|
||||
metadata: {
|
||||
name: "trustgraph",
|
||||
},
|
||||
"spec": {
|
||||
},
|
||||
};
|
||||
|
||||
local sc = {
|
||||
apiVersion: "storage.k8s.io/v1",
|
||||
kind: "StorageClass",
|
||||
metadata: {
|
||||
name: "tg",
|
||||
},
|
||||
provisioner: "pd.csi.storage.gke.io",
|
||||
parameters: {
|
||||
type: "pd-balanced",
|
||||
"csi.storage.k8s.io/fstype": "ext4",
|
||||
},
|
||||
reclaimPolicy: "Delete",
|
||||
volumeBindingMode: "WaitForFirstConsumer",
|
||||
};
|
||||
|
||||
k8s + {
|
||||
|
||||
// Extract resources usnig the engine
|
||||
package:: function(patterns)
|
||||
local resources = [sc, ns] + std.flattenArrays([
|
||||
p.create(self) for p in std.objectValues(patterns)
|
||||
]);
|
||||
local resourceList = {
|
||||
apiVersion: "v1",
|
||||
kind: "List",
|
||||
items: resources,
|
||||
};
|
||||
resourceList
|
||||
|
||||
}
|
||||
|
||||
393
trustgraph_configurator/templates/2.2/engine/k8s.jsonnet
Normal file
393
trustgraph_configurator/templates/2.2/engine/k8s.jsonnet
Normal file
|
|
@ -0,0 +1,393 @@
|
|||
{
|
||||
|
||||
container:: function(name)
|
||||
{
|
||||
|
||||
local container = self,
|
||||
|
||||
name: name,
|
||||
limits: {},
|
||||
reservations: {},
|
||||
ports: [],
|
||||
volumes: [],
|
||||
bindMounts: [],
|
||||
groups: [],
|
||||
environment: [],
|
||||
|
||||
with_image:: function(x) self + { image: x },
|
||||
|
||||
with_user:: function(x) self + { user: x },
|
||||
|
||||
with_group:: function(x) self + { groups: super.groups + [x] },
|
||||
|
||||
with_privileged:: function(x) self + { privileged: x },
|
||||
|
||||
with_command:: function(x) self + { command: x },
|
||||
|
||||
with_entrypoint:: function(x) self + { entrypoint: x },
|
||||
|
||||
with_environment:: function(x) self + {
|
||||
environment: super.environment + [
|
||||
{
|
||||
name: v.key, value: v.value
|
||||
}
|
||||
for v in std.objectKeysValues(x)
|
||||
],
|
||||
},
|
||||
|
||||
with_limits:: function(c, m) self + { limits: { cpu: c, memory: m } },
|
||||
|
||||
with_reservations::
|
||||
function(c, m) self + { reservations: { cpu: c, memory: m } },
|
||||
|
||||
with_volume_mount::
|
||||
function(vol, mnt)
|
||||
self + {
|
||||
volumes: super.volumes + [{
|
||||
volume: vol, mount: mnt
|
||||
}]
|
||||
},
|
||||
|
||||
with_bind_mount::
|
||||
function(src, dest)
|
||||
local name = "bind-" + std.strReplace(std.strReplace(src, "/", "-"), ".", "-");
|
||||
self + {
|
||||
bindMounts: super.bindMounts + [{
|
||||
name: name, src: src, dest: dest
|
||||
}]
|
||||
},
|
||||
|
||||
with_port::
|
||||
function(src, dest, name) self + {
|
||||
ports: super.ports + [
|
||||
{ src: src, dest: dest, name : name }
|
||||
]
|
||||
},
|
||||
|
||||
with_env_var_secrets::
|
||||
function(vars)
|
||||
std.foldl(
|
||||
function(obj, x) obj + {
|
||||
environment: super.environment + [{
|
||||
name: x,
|
||||
valueFrom: {
|
||||
secretKeyRef: {
|
||||
name: vars.name,
|
||||
key: vars.keyMap[x],
|
||||
}
|
||||
}
|
||||
}]
|
||||
},
|
||||
vars.variables,
|
||||
self
|
||||
),
|
||||
|
||||
add:: function() [
|
||||
|
||||
{
|
||||
apiVersion: "apps/v1",
|
||||
kind: "Deployment",
|
||||
metadata: {
|
||||
name: container.name,
|
||||
namespace: "trustgraph",
|
||||
labels: {
|
||||
app: container.name
|
||||
}
|
||||
},
|
||||
spec: {
|
||||
replicas: 1,
|
||||
selector: {
|
||||
matchLabels: {
|
||||
app: container.name,
|
||||
}
|
||||
},
|
||||
template: {
|
||||
metadata: {
|
||||
labels: {
|
||||
app: container.name,
|
||||
}
|
||||
},
|
||||
spec: {
|
||||
containers: [
|
||||
{
|
||||
name: container.name,
|
||||
image: container.image,
|
||||
|
||||
// FIXME: Make everything run as
|
||||
// root. Needed to get filesystems
|
||||
// to be accessible. There's a
|
||||
// better way of doing this?
|
||||
securityContext: {
|
||||
runAsUser: 0,
|
||||
runAsGroup: 0,
|
||||
} + (
|
||||
if std.objectHas(container, "privileged") && container.privileged then
|
||||
{ privileged: true }
|
||||
else {}
|
||||
),
|
||||
|
||||
resources: {
|
||||
requests: container.reservations,
|
||||
limits: container.limits
|
||||
},
|
||||
} + (
|
||||
if std.length(container.ports) > 0 then
|
||||
{
|
||||
ports: [
|
||||
{
|
||||
hostPort: port.src,
|
||||
containerPort: port.dest,
|
||||
}
|
||||
for port in container.ports
|
||||
]
|
||||
} else
|
||||
{}) +
|
||||
|
||||
(if std.objectHas(container, "entrypoint") then
|
||||
// Entrypoint is set - use command for entrypoint, args for command
|
||||
(if std.isString(container.entrypoint) && container.entrypoint == "" then
|
||||
{ command: [] }
|
||||
else if std.isArray(container.entrypoint) then
|
||||
{ command: container.entrypoint }
|
||||
else
|
||||
{ command: [container.entrypoint] }
|
||||
) + (if std.objectHas(container, "command") then
|
||||
{ args: container.command }
|
||||
else {})
|
||||
else if std.objectHas(container, "command") then
|
||||
{ command: container.command }
|
||||
else {}) +
|
||||
|
||||
(if std.length(container.environment) > 0 then
|
||||
{
|
||||
env: container.environment,
|
||||
}
|
||||
else {}) +
|
||||
|
||||
(if std.length(container.volumes) > 0 || std.length(container.bindMounts) > 0 then
|
||||
{
|
||||
volumeMounts: [
|
||||
{
|
||||
mountPath: vol.mount,
|
||||
name: vol.volume.name,
|
||||
}
|
||||
for vol in container.volumes
|
||||
] + [
|
||||
{
|
||||
mountPath: bm.dest,
|
||||
name: bm.name,
|
||||
}
|
||||
for bm in container.bindMounts
|
||||
]
|
||||
}
|
||||
|
||||
else
|
||||
{}
|
||||
)
|
||||
],
|
||||
volumes: [
|
||||
vol.volume.volRef()
|
||||
for vol in container.volumes
|
||||
] + [
|
||||
{
|
||||
name: bm.name,
|
||||
hostPath: { path: bm.src }
|
||||
}
|
||||
for bm in container.bindMounts
|
||||
]
|
||||
} + (
|
||||
if std.length(container.groups) > 0 then
|
||||
{ securityContext: { supplementalGroups: container.groups } }
|
||||
else {}
|
||||
)
|
||||
},
|
||||
} + {}
|
||||
|
||||
}
|
||||
|
||||
]
|
||||
|
||||
},
|
||||
|
||||
// Just an alias
|
||||
internalService:: self.service,
|
||||
|
||||
service:: function(containers)
|
||||
{
|
||||
|
||||
local service = self,
|
||||
|
||||
name: containers.name,
|
||||
|
||||
ports: [],
|
||||
|
||||
with_port::
|
||||
function(src, dest, name)
|
||||
self + {
|
||||
ports: super.ports + [
|
||||
{ src: src, dest: dest, name: name }
|
||||
]
|
||||
},
|
||||
|
||||
add:: function() [
|
||||
|
||||
{
|
||||
|
||||
apiVersion: "v1",
|
||||
kind: "Service",
|
||||
metadata: {
|
||||
name: service.name,
|
||||
namespace: "trustgraph",
|
||||
},
|
||||
spec: {
|
||||
selector: {
|
||||
app: service.name,
|
||||
},
|
||||
ports: [
|
||||
{
|
||||
port: port.src,
|
||||
targetPort: port.dest,
|
||||
name: port.name,
|
||||
}
|
||||
for port in service.ports
|
||||
],
|
||||
}
|
||||
}
|
||||
],
|
||||
|
||||
},
|
||||
|
||||
volume:: function(name)
|
||||
{
|
||||
|
||||
local volume = self,
|
||||
|
||||
name: name,
|
||||
|
||||
with_size:: function(size) self + { size: size },
|
||||
|
||||
add:: function() [
|
||||
{
|
||||
apiVersion: "v1",
|
||||
kind: "PersistentVolumeClaim",
|
||||
metadata: {
|
||||
name: volume.name,
|
||||
namespace: "trustgraph",
|
||||
},
|
||||
spec: {
|
||||
storageClassName: "tg",
|
||||
accessModes: [ "ReadWriteOnce" ],
|
||||
resources: {
|
||||
requests: {
|
||||
storage: volume.size,
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
],
|
||||
|
||||
volRef:: function() {
|
||||
name: volume.name,
|
||||
persistentVolumeClaim: { claimName: volume.name },
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
configVolume:: function(name, dir, parts)
|
||||
{
|
||||
|
||||
local volume = self,
|
||||
|
||||
name: name,
|
||||
|
||||
with_size:: function(size) self + { size: size },
|
||||
|
||||
add:: function() [
|
||||
{
|
||||
apiVersion: "v1",
|
||||
kind: "ConfigMap",
|
||||
metadata: {
|
||||
name: volume.name,
|
||||
namespace: "trustgraph",
|
||||
},
|
||||
data: parts
|
||||
},
|
||||
],
|
||||
|
||||
|
||||
volRef:: function() {
|
||||
name: volume.name,
|
||||
configMap: { name: volume.name },
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
secretVolume:: function(name, dir, parts)
|
||||
{
|
||||
|
||||
local volume = self,
|
||||
|
||||
name: name,
|
||||
|
||||
with_size:: function(size) self + { size: size },
|
||||
|
||||
add:: function() [
|
||||
],
|
||||
|
||||
volRef:: function() {
|
||||
name: volume.name,
|
||||
secret: { secretName: volume.name },
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
envSecrets:: function(name)
|
||||
{
|
||||
|
||||
local volume = self,
|
||||
|
||||
name: name,
|
||||
|
||||
variables: [],
|
||||
keyMap: {},
|
||||
|
||||
with_size:: function(size) self + { size: size },
|
||||
|
||||
add:: function() [
|
||||
],
|
||||
|
||||
volRef:: function() {
|
||||
name: volume.name,
|
||||
secret: { secretName: volume.name },
|
||||
},
|
||||
|
||||
with_env_var::
|
||||
function(name, key) self + {
|
||||
variables: super.variables + [name],
|
||||
keyMap: super.keyMap + { [name]: key },
|
||||
},
|
||||
|
||||
},
|
||||
|
||||
containers:: function(name, containers)
|
||||
{
|
||||
|
||||
local cont = self,
|
||||
|
||||
name: name,
|
||||
containers: containers,
|
||||
|
||||
add:: function() std.flattenArrays(
|
||||
[ c.add() for c in cont.containers ]
|
||||
),
|
||||
|
||||
},
|
||||
|
||||
resources:: function(res)
|
||||
|
||||
std.flattenArrays(
|
||||
[ c.add() for c in res ]
|
||||
),
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,115 @@
|
|||
|
||||
local k8s = import "k8s.jsonnet";
|
||||
|
||||
local ns = {
|
||||
apiVersion: "v1",
|
||||
kind: "Namespace",
|
||||
metadata: {
|
||||
name: "trustgraph",
|
||||
},
|
||||
"spec": {
|
||||
},
|
||||
};
|
||||
|
||||
k8s + {
|
||||
|
||||
// Extract resources usnig the engine
|
||||
package:: function(patterns)
|
||||
local resources = [ns] + std.flattenArrays([
|
||||
p.create(self) for p in std.objectValues(patterns)
|
||||
]);
|
||||
local resourceList = {
|
||||
apiVersion: "v1",
|
||||
kind: "List",
|
||||
items: resources,
|
||||
};
|
||||
resourceList,
|
||||
|
||||
volume:: function(name)
|
||||
{
|
||||
local volume = self,
|
||||
name: name,
|
||||
with_size:: function(size) self + { size: size },
|
||||
add:: function() [
|
||||
{
|
||||
apiVersion: "v1",
|
||||
kind: "PersistentVolume",
|
||||
metadata: {
|
||||
name: volume.name,
|
||||
},
|
||||
spec: {
|
||||
accessModes: [ "ReadWriteOnce" ],
|
||||
capacity: {
|
||||
storage: volume.size,
|
||||
},
|
||||
persistentVolumeReclaimPolicy: "Delete",
|
||||
hostPath: {
|
||||
path: "/data/pv-" + volume.name,
|
||||
},
|
||||
}
|
||||
},
|
||||
{
|
||||
apiVersion: "v1",
|
||||
kind: "PersistentVolumeClaim",
|
||||
metadata: {
|
||||
name: volume.name,
|
||||
namespace: "trustgraph",
|
||||
},
|
||||
spec: {
|
||||
accessModes: [ "ReadWriteOnce" ],
|
||||
resources: {
|
||||
requests: {
|
||||
storage: volume.size,
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
],
|
||||
|
||||
volRef:: function() {
|
||||
name: volume.name,
|
||||
persistentVolumeClaim: { claimName: volume.name },
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
service:: function(containers)
|
||||
{
|
||||
local service = self,
|
||||
name: containers.name,
|
||||
ports: [],
|
||||
with_port::
|
||||
function(src, dest, name)
|
||||
self + {
|
||||
ports: super.ports + [
|
||||
{ src: src, dest: dest, name: name }
|
||||
]
|
||||
},
|
||||
add:: function() [
|
||||
{
|
||||
apiVersion: "v1",
|
||||
kind: "Service",
|
||||
metadata: {
|
||||
name: service.name,
|
||||
namespace: "trustgraph",
|
||||
},
|
||||
spec: {
|
||||
selector: {
|
||||
app: service.name,
|
||||
},
|
||||
type: "LoadBalancer",
|
||||
ports: [
|
||||
{
|
||||
port: port.src,
|
||||
targetPort: port.dest,
|
||||
name: port.name,
|
||||
}
|
||||
for port in service.ports
|
||||
],
|
||||
}
|
||||
}
|
||||
],
|
||||
},
|
||||
|
||||
}
|
||||
|
||||
79
trustgraph_configurator/templates/2.2/engine/noop.jsonnet
Normal file
79
trustgraph_configurator/templates/2.2/engine/noop.jsonnet
Normal file
|
|
@ -0,0 +1,79 @@
|
|||
{
|
||||
|
||||
// Extract resources usnig the engine
|
||||
package:: function(patterns) {},
|
||||
|
||||
container:: function(name) {
|
||||
|
||||
with_image:: function(x) self + {},
|
||||
|
||||
with_user:: function(x) self + {},
|
||||
|
||||
with_command:: function(x) self + {},
|
||||
|
||||
with_runtime:: function(x) self + {},
|
||||
|
||||
with_privileged:: function(x) self + {},
|
||||
|
||||
with_ipc:: function(x) self + {},
|
||||
|
||||
with_capability:: function(x) self + {},
|
||||
|
||||
with_environment:: function(x) self + {},
|
||||
|
||||
with_device:: function(hdev, cdev) self + {},
|
||||
|
||||
with_limits:: function(c, m) self + {},
|
||||
|
||||
with_reservations:: function(c, m) self + {},
|
||||
|
||||
with_volume_mount:: self + {},
|
||||
|
||||
with_port:: function(src, dest, name) self + {},
|
||||
|
||||
with_env_var_secrets:: function(vars) self + {},
|
||||
|
||||
add:: function() {},
|
||||
},
|
||||
|
||||
internalService:: function(containers) {
|
||||
with_port:: function(src, dest, name) self + {},
|
||||
add:: function() {},
|
||||
},
|
||||
|
||||
service:: function(containers) {
|
||||
with_port:: function(src, dest, name) self + {},
|
||||
add:: function() {},
|
||||
},
|
||||
|
||||
volume:: function(name) {
|
||||
with_size:: function(size) self + {},
|
||||
add:: function() {},
|
||||
},
|
||||
|
||||
configVolume:: function(name, dir, parts) {
|
||||
add:: function() {},
|
||||
},
|
||||
|
||||
secretVolume:: function(name, dir, parts) {
|
||||
add:: function() {},
|
||||
},
|
||||
|
||||
envSecrets:: function(name) {
|
||||
with_env_var:: function(name, key) self + {},
|
||||
add:: function() {},
|
||||
},
|
||||
|
||||
containers:: function(name, containers) {
|
||||
add:: function() {},
|
||||
},
|
||||
|
||||
resources:: function(res)
|
||||
std.foldl(
|
||||
function(state, c) state + c.add(),
|
||||
res,
|
||||
{}
|
||||
),
|
||||
|
||||
}
|
||||
|
||||
45
trustgraph_configurator/templates/2.2/engine/ovh-k8s.jsonnet
Normal file
45
trustgraph_configurator/templates/2.2/engine/ovh-k8s.jsonnet
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
|
||||
local k8s = import "k8s.jsonnet";
|
||||
|
||||
local ns = {
|
||||
apiVersion: "v1",
|
||||
kind: "Namespace",
|
||||
metadata: {
|
||||
name: "trustgraph",
|
||||
},
|
||||
"spec": {
|
||||
},
|
||||
};
|
||||
|
||||
local sc = {
|
||||
apiVersion: "storage.k8s.io/v1",
|
||||
kind: "StorageClass",
|
||||
metadata: {
|
||||
name: "tg",
|
||||
},
|
||||
provisioner: "cinder.csi.openstack.org",
|
||||
reclaimPolicy: "Delete",
|
||||
volumeBindingMode: "WaitForFirstConsumer",
|
||||
parameters: {
|
||||
availability: "nova",
|
||||
fsType: "ext4",
|
||||
type: "high-speed",
|
||||
},
|
||||
};
|
||||
|
||||
k8s + {
|
||||
|
||||
// Extract resources usnig the engine
|
||||
package:: function(patterns)
|
||||
local resources = [sc, ns] + std.flattenArrays([
|
||||
p.create(self) for p in std.objectValues(patterns)
|
||||
]);
|
||||
local resourceList = {
|
||||
apiVersion: "v1",
|
||||
kind: "List",
|
||||
items: [ns, sc] + resources,
|
||||
};
|
||||
resourceList
|
||||
|
||||
}
|
||||
|
||||
40
trustgraph_configurator/templates/2.2/engine/scw-k8s.jsonnet
Normal file
40
trustgraph_configurator/templates/2.2/engine/scw-k8s.jsonnet
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
|
||||
local k8s = import "k8s.jsonnet";
|
||||
|
||||
local ns = {
|
||||
apiVersion: "v1",
|
||||
kind: "Namespace",
|
||||
metadata: {
|
||||
name: "trustgraph",
|
||||
},
|
||||
"spec": {
|
||||
},
|
||||
};
|
||||
|
||||
local sc = {
|
||||
apiVersion: "storage.k8s.io/v1",
|
||||
kind: "StorageClass",
|
||||
metadata: {
|
||||
name: "tg",
|
||||
},
|
||||
provisioner: "csi.scaleway.com",
|
||||
reclaimPolicy: "Delete",
|
||||
volumeBindingMode: "WaitForFirstConsumer",
|
||||
};
|
||||
|
||||
k8s + {
|
||||
|
||||
// Extract resources usnig the engine
|
||||
package:: function(patterns)
|
||||
local resources = [sc, ns] + std.flattenArrays([
|
||||
p.create(self) for p in std.objectValues(patterns)
|
||||
]);
|
||||
local resourceList = {
|
||||
apiVersion: "v1",
|
||||
kind: "List",
|
||||
items: [ns, sc] + resources,
|
||||
};
|
||||
resourceList
|
||||
|
||||
}
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue