Fix k8s.jsonnet to compile to something kubernetes accepts

Add Service definitions to output
Correct apiVersion for Ingress definition
Output a v1 List, as kubectl doesn't parse JSON arrays
pull/173/head
HubbeKing 4 years ago
parent 28faff5c58
commit 9a95dc44eb

@ -5,8 +5,9 @@
// for the sake of simplicity. // for the sake of simplicity.
{ {
kind: "List",
config: { apiVersion: "v1",
config:: {
// These are the important top-level settings. // These are the important top-level settings.
// Change these to configure the services. // Change these to configure the services.
@ -70,16 +71,16 @@
// A few derived values. // A few derived values.
// The connection string for the database. Constructed from db_args. // The connection string for the database. Constructed from db_args.
db_connect: std.join(" ", [ db_connect:: std.join(" ", [
"%s='%s'" % [key, $.config.db_args[key]] "%s='%s'" % [key, $.config.db_args[key]]
for key in std.objectFields($.config.db_args) for key in std.objectFields($.config.db_args)
]), ]),
// Cleaned up version of $.channels without importance markers // Cleaned up version of $.channels without importance markers
clean_channels: [std.split(c, '!')[0] for c in $.config.channels], clean_channels:: [std.split(c, '!')[0] for c in $.config.channels],
// k8s-formatted version of env dict // k8s-formatted version of env dict
env_list: [ env_list:: [
{name: key, value: $.config.env[key]} {name: key, value: $.config.env[key]}
for key in std.objectFields($.config.env) for key in std.objectFields($.config.env)
], ],
@ -129,7 +130,7 @@
}, },
// This function generates a Service object for each service, since they're basically identical. // This function generates a Service object for each service, since they're basically identical.
service(name): { service(name):: {
kind: "Service", kind: "Service",
apiVersion: "v1", apiVersion: "v1",
metadata: { metadata: {
@ -145,7 +146,7 @@
// The actual manifests. // The actual manifests.
// These are all deployments. Note that all components work fine if multiple are running // These are all deployments. Note that all components work fine if multiple are running
// (they may duplicate work, but not cause errors by stepping on each others' toes). // (they may duplicate work, but not cause errors by stepping on each others' toes).
manifests: [ items: [
// The downloader watches the twitch stream and writes the HLS segments to disk // The downloader watches the twitch stream and writes the HLS segments to disk
$.deployment("downloader", args=$.config.channels + [ $.deployment("downloader", args=$.config.channels + [
"--base-dir", "/mnt", "--base-dir", "/mnt",
@ -187,10 +188,16 @@
{name: "THRIMBLETRIMMER", value: "true"}, {name: "THRIMBLETRIMMER", value: "true"},
{name: "SEGMENTS", value: "/mnt"}, {name: "SEGMENTS", value: "/mnt"},
]), ]),
// Services for all deployments
$.service("downloader"),
$.service("backfiller"),
$.service("nginx"),
$.service("restreamer"),
$.service("segment_coverage"),
// Ingress to direct requests to the correct services. // Ingress to direct requests to the correct services.
{ {
kind: "Ingress", kind: "Ingress",
apiVersion: "v1", apiVersion: "networking.k8s.io/v1beta1",
metadata: { metadata: {
name: "wubloader", name: "wubloader",
labels: {app: "wubloader"}, labels: {app: "wubloader"},
@ -228,4 +235,4 @@
}, },
], ],
}.manifests // final output is just the manifest list, none of the other fields }

Loading…
Cancel
Save