diff --git a/templates/components/grafana.jsonnet b/templates/components/grafana.jsonnet index 1346e105..133e49c1 100644 --- a/templates/components/grafana.jsonnet +++ b/templates/components/grafana.jsonnet @@ -12,7 +12,7 @@ local images = import "values/images.jsonnet"; local cfgVol = engine.configVolume( "prometheus-cfg", "./prometheus", { - "prometheus.cfg": importstr "prometheus/prometheus.yml", + "prometheus.yml": importstr "prometheus/prometheus.yml", } ); @@ -21,8 +21,9 @@ local images = import "values/images.jsonnet"; .with_image(images.prometheus) .with_limits("0.5", "128M") .with_reservations("0.1", "128M") +// .with_command(["/bin/sh", "-c", "sleep 9999999"]) .with_port(9090, 9090, "http") - .with_volume_mount(cfgVol, "/etc/prometheus") + .with_volume_mount(cfgVol, "/etc/prometheus/") .with_volume_mount(vol, "/prometheus"); local containerSet = engine.containers( @@ -48,16 +49,24 @@ local images = import "values/images.jsonnet"; local vol = engine.volume("grafana-storage").with_size("20G"); - local provVol = engine.configVolume( - "provisioning", "./grafana/provisioning/", + local provDashVol = engine.configVolume( + "prov-dash", "./grafana/provisioning/", { "dashboard.yml": importstr "grafana/provisioning/dashboard.yml", + } + + ); + + local provDataVol = engine.configVolume( + "prov-data", "./grafana/provisioning/", + { "datasource.yml": importstr "grafana/provisioning/datasource.yml", } ); + local dashVol = engine.configVolume( "dashboards", "./grafana/dashboards/", { @@ -82,7 +91,10 @@ local images = import "values/images.jsonnet"; .with_port(3000, 3000, "cassandra") .with_volume_mount(vol, "/var/lib/grafana") .with_volume_mount( - provVol, "/etc/grafana/provisioning/dashboards/" + provDashVol, "/etc/grafana/provisioning/dashboards/" + ) + .with_volume_mount( + provDataVol, "/etc/grafana/provisioning/datasources/" ) .with_volume_mount( dashVol, "/var/lib/grafana/dashboards/" @@ -98,9 +110,11 @@ local images = import "values/images.jsonnet"; engine.resources([ vol, - provVol, + provDashVol, + provDataVol, dashVol, containerSet, + service, ]) }, diff --git a/templates/components/pulsar.jsonnet b/templates/components/pulsar.jsonnet index eb1b894e..8f90238f 100644 --- a/templates/components/pulsar.jsonnet +++ b/templates/components/pulsar.jsonnet @@ -13,13 +13,13 @@ local images = import "values/images.jsonnet"; local container = engine.container("pulsar") .with_image(images.pulsar) -// .with_command(["bin/pulsar", "standalone"]) - .with_command(["bin/sh", "-c", "sleep 1000000"]) + .with_command(["bin/pulsar", "standalone"]) +// .with_command(["/bin/sh", "-c", "sleep 9999999"]) .with_environment({ "PULSAR_MEM": "-Xms700M -Xmx700M" }) - .with_limits("1.0", "900M") - .with_reservations("0.5", "900M") + .with_limits("1.0", "1500M") + .with_reservations("0.5", "1500M") // .with_volume_mount(confVolume, "/pulsar/conf") .with_volume_mount(dataVolume, "/pulsar/data") .with_port(6650, 6650, "bookie") @@ -33,8 +33,8 @@ local images = import "values/images.jsonnet"; "-c", "pulsar-admin --admin-url http://pulsar:8080 tenants create tg && pulsar-admin --admin-url http://pulsar:8080 namespaces create tg/flow && pulsar-admin --admin-url http://pulsar:8080 namespaces create tg/request && pulsar-admin --admin-url http://pulsar:8080 namespaces create tg/response && pulsar-admin --admin-url http://pulsar:8080 namespaces set-retention --size -1 --time 3m tg/response", ]) - .with_limits("0.5", "128M") - .with_reservations("0.1", "128M"); + .with_limits("0.1", "256M") + .with_reservations("0.1", "256M"); local containerSet = engine.containers( "pulsar", @@ -59,5 +59,3 @@ local images = import "values/images.jsonnet"; } - - diff --git a/templates/components/vertexai.jsonnet b/templates/components/vertexai.jsonnet index 4420f2e2..294c35c8 100644 --- a/templates/components/vertexai.jsonnet +++ b/templates/components/vertexai.jsonnet @@ -41,8 +41,8 @@ local prompts = import "prompts/mixtral.jsonnet"; "-m", $["vertexai-model"], ]) - .with_limits("0.5", "128M") - .with_reservations("0.1", "128M") + .with_limits("0.5", "256M") + .with_reservations("0.1", "256M") .with_volume_mount(cfgVol, "/vertexai"); local containerSet = engine.containers( @@ -90,8 +90,8 @@ local prompts = import "prompts/mixtral.jsonnet"; "-o", "non-persistent://tg/response/text-completion-rag-response", ]) - .with_limits("0.5", "128M") - .with_reservations("0.1", "128M") + .with_limits("0.5", "256M") + .with_reservations("0.1", "256M") .with_volume_mount(cfgVol, "/vertexai"); local containerSet = engine.containers( diff --git a/templates/config-to-k8s.jsonnet b/templates/config-to-k8s.jsonnet index 560ea5c0..94ede36d 100644 --- a/templates/config-to-k8s.jsonnet +++ b/templates/config-to-k8s.jsonnet @@ -30,17 +30,21 @@ local sc = { volumeBindingMode: "Immediate", }; +//patterns["pulsar"].create(engine) + // Extract resources usnig the engine -local resources = std.foldl( - function(state, p) state + p.create(engine), - std.objectValues(patterns), - {} -); +local resources = std.flattenArrays([ + p.create(engine) for p in std.objectValues(patterns) +]); local resourceList = { apiVersion: "v1", kind: "List", - items: [ns, sc] + std.objectValues(resources.resources), + items: [ns, sc] + resources, }; -std.manifestYamlDoc(resourceList, quote_keys=false) + +resourceList + + + diff --git a/templates/k8s.jsonnet b/templates/k8s.jsonnet index ea8f5179..52025720 100644 --- a/templates/k8s.jsonnet +++ b/templates/k8s.jsonnet @@ -10,16 +10,6 @@ reservations: {}, ports: [], volumes: [], - securityContext: { - fsGroup: 1234 -// runAsUser: 65534 -// runAsGroup: 65534 -// runAsNonRoot: true -// runAsUser: 0, -// runAsGroup: 0, -// runAsNonRoot: true, -// readOnlyRootFilesystem: true, - }, with_image:: function(x) self + { image: x }, @@ -47,10 +37,9 @@ ] }, - add:: function() { + add:: function() [ - resources +: { - [container.name]: { + { apiVersion: "apps/v1", kind: "Deployment", metadata: { @@ -78,6 +67,16 @@ { name: container.name, image: container.image, + securityContext: { + // fsGroup: 1234 + // runAsUser: 65534 + // runAsGroup: 65534 + // runAsNonRoot: true + runAsUser: 0, + runAsGroup: 0, + // runAsNonRoot: true, + // readOnlyRootFilesystem: true, + }, resources: { requests: container.reservations, limits: container.limits @@ -136,8 +135,7 @@ } - } - } + ] }, @@ -157,9 +155,10 @@ ] }, - add:: function() { - resources +: { - [service.name + "-service"]: { + add:: function() [ + + { + apiVersion: "v1", kind: "Service", metadata: { @@ -180,8 +179,7 @@ ], } } - } - } + ], }, @@ -194,9 +192,10 @@ with_size:: function(size) self + { size: size }, - add:: function() { - resources +: { - [volume.name + "-pv"]: { + add:: function() [ + + { + apiVersion: "v1", kind: "PersistentVolume", metadata: { @@ -211,12 +210,13 @@ storage: volume.size, }, accessModes: [ "ReadWriteOnce" ], + persistentVolumeReclaimPolicy: "Delete", hostPath: { path: "/data/k8s/" + volume.name, } } }, - [volume.name + "-pvc"]: { + { apiVersion: "v1", kind: "PersistentVolumeClaim", metadata: { @@ -234,8 +234,7 @@ volumeName: volume.name, } } - } - }, + ], volRef:: function() { name: volume.name, @@ -253,9 +252,8 @@ with_size:: function(size) self + { size: size }, - add:: function() { - resources +: { - [volume.name + "-cm"]: { + add:: function() [ + { apiVersion: "v1", kind: "ConfigMap", metadata: { @@ -264,12 +262,12 @@ }, data: parts }, - } - }, + ], + volRef:: function() { name: volume.name, - configMap: { name: volume.name + "-cm" }, + configMap: { name: volume.name }, } }, @@ -283,9 +281,8 @@ with_size:: function(size) self + { size: size }, - add:: function() { - resources +: { - [volume.name + "-cm"]: { + add:: function() [ + { apiVersion: "v1", kind: "Secret", metadata: { @@ -297,12 +294,11 @@ for item in std.objectKeysValues(parts) } }, - } - }, + ], volRef:: function() { name: volume.name, - secret: { secretName: volume.name + "-cm" }, + secret: { secretName: volume.name }, } }, @@ -315,20 +311,16 @@ name: name, containers: containers, - add:: function() std.foldl( - function(state, c) state + c.add(), - cont.containers, - {} + add:: function() std.flattenArrays( + [ c.add() for c in cont.containers ] ), }, resources:: function(res) - std.foldl( - function(state, c) state + c.add(), - res, - {} + std.flattenArrays( + [ c.add() for c in res ] ), }