mirror of
https://github.com/trustgraph-ai/trustgraph.git
synced 2026-07-23 20:21:03 +02:00
Added a config to create Minikube k8s, uses hostpath volumes
This commit is contained in:
parent
f661791bbf
commit
19625d1cde
4 changed files with 137 additions and 6 deletions
11
Makefile
11
Makefile
|
|
@ -70,9 +70,12 @@ update-templates: set-version
|
||||||
done; \
|
done; \
|
||||||
done
|
done
|
||||||
|
|
||||||
config.yaml: config.json FORCE
|
|
||||||
jsonnet -J . -J templates/ templates/config-to-k8s.jsonnet | \
|
|
||||||
python3 -c 'import sys, yaml, json; j=json.loads(sys.stdin.read()); print(yaml.safe_dump(j))' > $@
|
|
||||||
|
|
||||||
FORCE:
|
FORCE:
|
||||||
|
|
||||||
|
IGNOREconfig.yaml: config.json FORCE
|
||||||
|
jsonnet -J . -J templates/ templates/config-to-gcp-k8s.jsonnet | \
|
||||||
|
python3 -c 'import sys, yaml, json; j=json.loads(sys.stdin.read()); print(yaml.safe_dump(j))' > $@
|
||||||
|
|
||||||
|
config.yaml: config.json FORCE
|
||||||
|
jsonnet -J . -J templates/ templates/config-to-minikube-k8s.jsonnet | \
|
||||||
|
python3 -c 'import sys, yaml, json; j=json.loads(sys.stdin.read()); print(yaml.safe_dump(j))' > $@
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ default_pulsar_host = os.getenv("PULSAR_HOST", 'pulsar://pulsar:6650')
|
||||||
|
|
||||||
def show_graph(pulsar):
|
def show_graph(pulsar):
|
||||||
|
|
||||||
tq = TriplesQueryClient(pulsar_host="pulsar://localhost:6650")
|
tq = TriplesQueryClient(pulsar_host=pulsar)
|
||||||
|
|
||||||
rows = tq.request(None, None, None, limit=10_000_000)
|
rows = tq.request(None, None, None, limit=10_000_000)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ default_pulsar_host = os.getenv("PULSAR_HOST", 'pulsar://pulsar:6650')
|
||||||
|
|
||||||
def show_graph(pulsar):
|
def show_graph(pulsar):
|
||||||
|
|
||||||
tq = TriplesQueryClient(pulsar_host="pulsar://localhost:6650")
|
tq = TriplesQueryClient(pulsar_host=pulsar)
|
||||||
|
|
||||||
rows = tq.request(None, None, None, limit=10_000_000)
|
rows = tq.request(None, None, None, limit=10_000_000)
|
||||||
|
|
||||||
|
|
|
||||||
128
templates/config-to-minikube-k8s.jsonnet
Normal file
128
templates/config-to-minikube-k8s.jsonnet
Normal file
|
|
@ -0,0 +1,128 @@
|
||||||
|
|
||||||
|
local k8sEngine = import "k8s.jsonnet";
|
||||||
|
local decode = import "decode-config.jsonnet";
|
||||||
|
local components = import "components.jsonnet";
|
||||||
|
|
||||||
|
// Import config
|
||||||
|
local config = import "config.json";
|
||||||
|
|
||||||
|
// Produce patterns from config
|
||||||
|
local patterns = decode(config);
|
||||||
|
|
||||||
|
local ns = {
|
||||||
|
apiVersion: "v1",
|
||||||
|
kind: "Namespace",
|
||||||
|
metadata: {
|
||||||
|
name: "trustgraph",
|
||||||
|
},
|
||||||
|
"spec": {
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
local engine = k8sEngine + {
|
||||||
|
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
|
||||||
|
],
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
},
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
//patterns["pulsar"].create(engine)
|
||||||
|
|
||||||
|
// Extract resources using the engine
|
||||||
|
local resources = std.flattenArrays([
|
||||||
|
p.create(engine) for p in std.objectValues(patterns)
|
||||||
|
]);
|
||||||
|
|
||||||
|
local resourceList = {
|
||||||
|
apiVersion: "v1",
|
||||||
|
kind: "List",
|
||||||
|
items: [
|
||||||
|
ns,
|
||||||
|
] + resources,
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
resourceList
|
||||||
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue