blob: 2e68381de7e54e919ddc8872a3d0ad9a36a167fd [file] [log] [blame]
Sergiusz Bazanskic315aac2020-01-02 16:43:39 +01001local mirko = import "../../kube/mirko.libsonnet";
2local kube = import "../../kube/kube.libsonnet";
3
4{
5 cfg:: {
6 secret: {
7 telegram_token: error "telegram_token must be set",
8 },
Sergiusz Bazanskia8854882020-01-05 00:34:38 +01009 image: {
Sergiusz Bazanskieffafe92020-01-05 22:31:39 +010010 teleimg: "registry.k0.hswaw.net/q3k/teleimg:1578259776-a07688fe74efe1e190d58092a9f50d4275a15e3d",
Sergiusz Bazanskie0483312020-02-02 16:58:57 +010011 lelegram: "registry.k0.hswaw.net/q3k/lelegram:1579786610-83e26900700814ea67f46aabd5c5077382186022",
Sergiusz Bazanskia8854882020-01-05 00:34:38 +010012 },
13 bridge: {
14 telegram: "-1001345766954",
15 irc: "#hackerspace-krk",
16 },
Sergiusz Bazanskic315aac2020-01-02 16:43:39 +010017 webFQDN: error "webFQDN must be set!",
18 },
19
Sergiusz Bazanskia8854882020-01-05 00:34:38 +010020 teleimg(cfg, env):: mirko.Component(env, "teleimg") {
Sergiusz Bazanskic315aac2020-01-02 16:43:39 +010021 local teleimg = self,
22 cfg+: {
Sergiusz Bazanskia8854882020-01-05 00:34:38 +010023 image: cfg.image.teleimg,
Sergiusz Bazanskic315aac2020-01-02 16:43:39 +010024 container: teleimg.GoContainer("main", "/teleimg/teleimg") {
25 env_: {
26 TELEGRAM_TOKEN: kube.SecretKeyRef(teleimg.secret, "telegram_token"),
27 },
28 command+: [
29 "-public_listen", "0.0.0.0:5000",
30 "-telegram_token", "$(TELEGRAM_TOKEN)",
31 ],
32 },
33 ports+: {
34 publicHTTP: {
35 public: {
36 port: 5000,
37 dns: cfg.webFQDN,
38 },
39 },
40 },
41 },
42
43 secret: kube.Secret("teleimg") {
44 metadata+: teleimg.metadata,
45 data: cfg.secret,
46 },
47 },
Sergiusz Bazanskia8854882020-01-05 00:34:38 +010048
49 lelegram(cfg, env):: mirko.Component(env, "lelegram") {
50 local lelegram = self,
51 cfg+: {
52 image: cfg.image.lelegram,
Sergiusz Bazanski92b48d62020-01-08 13:59:04 +010053 nodeSelector: {
54 "kubernetes.io/hostname": "bc01n01.hswaw.net",
55 },
Sergiusz Bazanskia8854882020-01-05 00:34:38 +010056 container: lelegram.GoContainer("main", "/lelegram/lelegram") {
57 env_: {
58 TELEGRAM_TOKEN: kube.SecretKeyRef(lelegram.secret, "telegram_token"),
59 },
60 command+: [
61 "-telegram_token", "$(TELEGRAM_TOKEN)",
62 "-telegram_chat", cfg.bridge.telegram,
63 "-irc_channel", cfg.bridge.irc,
64 "-irc_max_connections", "10",
65 ],
66 },
67 },
68
Sergiusz Bazanskif15da822020-02-02 17:16:11 +010069 deployment+: {
70 spec+: {
71 replicas: 0,
72 },
73 },
74
Sergiusz Bazanskia8854882020-01-05 00:34:38 +010075 secret: kube.Secret("lelegram") {
76 metadata+: lelegram.metadata,
77 data: cfg.secret,
78 },
79 },
Sergiusz Bazanskic315aac2020-01-02 16:43:39 +010080}