blob: d833fc39b1a83f03fee0171c33f2b939f3072e84 [file] [log] [blame]
Sergiusz Bazanskicb5c3212019-05-19 03:10:17 +02001local factorio = import "factorio.libsonnet";
Serge Bazanskie7f4cc12021-06-12 21:55:40 +00002local kube = import "../../../kube/kube.libsonnet";
Sergiusz Bazanskicb5c3212019-05-19 03:10:17 +02003
Serge Bazanskie7f4cc12021-06-12 21:55:40 +00004// This deploys factorio instances and the modproxy in the `factorio`
5// Kubernetes namespace.
6//
7// Available factorio versions:
Serge Bazanski970b7682020-08-04 20:33:17 +02008// - 0.18.40-1
Serge Bazanski791ab6d2020-08-14 10:34:29 +00009// - 1.0.0-1
Serge Bazanskie7f4cc12021-06-12 21:55:40 +000010// See: //third_party/factorio.
Sergiusz Bazanskicb5c3212019-05-19 03:10:17 +020011
12{
13 local prod = self,
14
Sergiusz Bazanski0581bbf2020-05-11 03:21:32 +020015 proxyImage:: "registry.k0.hswaw.net/games/factorio/modproxy:1589157915-eafe7be328477e8a6590c4210466ef12901f1b9a",
16
Sergiusz Bazanskicb5c3212019-05-19 03:10:17 +020017 namespace: kube.Namespace("factorio"),
18 instance(name, tag):: factorio {
19 cfg+: {
20 namespace: "factorio",
21 prefix: name + "-",
22 tag: tag,
Sergiusz Bazanski0581bbf2020-05-11 03:21:32 +020023 proxyImage: prod.proxyImage,
Sergiusz Bazanskicb5c3212019-05-19 03:10:17 +020024 }
25 },
26
Sergiusz Bazanski0581bbf2020-05-11 03:21:32 +020027 proxy: {
28 pvc: kube.PersistentVolumeClaim("proxy-cas") {
29 metadata+: {
30 namespace: "factorio",
31 },
32 spec+: {
33 storageClassName: "waw-hdd-redundant-3",
34 accessModes: [ "ReadWriteOnce" ],
35 resources: {
36 requests: {
37 storage: "32Gi",
38 },
39 },
40 },
41 },
42 deploy: kube.Deployment("proxy") {
43 metadata+: {
44 namespace: "factorio",
45 },
46 spec+: {
47 template+: {
48 spec+: {
49 volumes_: {
50 cas: kube.PersistentVolumeClaimVolume(prod.proxy.pvc),
51 },
52 containers_: {
53 proxy: kube.Container("proxy") {
54 image:prod.proxyImage,
55 command: [
56 "/games/factorio/modproxy/modproxy",
57 "-hspki_disable",
58 "-cas_directory", "/mnt/cas",
59 "-listen_address", "0.0.0.0:4200",
60 ],
61 volumeMounts_: {
62 cas: { mountPath: "/mnt/cas" },
63 },
64 ports_: {
65 client: { containerPort: 4200 },
66 },
67 },
68 },
69 },
70 },
71 },
72 },
73 svc: kube.Service("proxy") {
74 metadata+: {
75 namespace: "factorio",
76 },
77 target_pod:: prod.proxy.deploy.spec.template,
78 spec+: {
79 ports: [
80 { name: "client", port: 4200, targetPort: 4200, protocol: "TCP" },
81 ],
82 },
83 },
84 },
85
86 local mod = function(name, version) { name: name, version: version },
Sergiusz Bazanskicb5c3212019-05-19 03:10:17 +020087}