aboutsummaryrefslogtreecommitdiff
path: root/deploy/lib/catinator.libsonnet
blob: b4144fe3f46c905b1cd857cd0808fe50e905f428 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
{
  _config+:: {
    catinator: {
      name: "catinator",
      image: {
        repo: "kube.cat/cocainefarm/catinator",
        tag: "1.0.0"
      },
      config: "",
      secret: "catinator-password"
    },
  },

  local k = import "ksonnet-util/kausal.libsonnet",
  local statefulset = k.apps.v1.statefulSet,
  local container = k.core.v1.container,
  local env = k.core.v1.envVar,
  local port = k.core.v1.containerPort,
  local service = k.core.v1.service,

  local withEnv(name, value) = container.withEnv(
    env.new(name=name, value=value)),

  catinator: {
    deployment: statefulset.new(
      name=$._config.catinator.name
      , replicas=1
      , containers=[
        container.new(
          "catinator"
          , $._config.catinator.image.repo + ":" + $._config.catinator.image.tag)
        + container.withEnvMap({
          "CATINATOR_CONFIG": "/etc/catinator/config.toml",
        })
        + container.withEnvFrom(k.core.v1.envFromSource.secretRef.withName($._config.catinator.secret))
      ]
    )
    + k.util.configMapVolumeMount($.catinator.configmap, "/etc/catinator")
    + statefulset.spec.withServiceName($.catinator.service.metadata.name),
    service: k.util.serviceFor(self.deployment) + service.spec.withClusterIP("None"),
    configmap: k.core.v1.configMap.new(name="%s-config" % $._config.catinator.name, data={
      "config.toml": $._config.catinator.config,
    })

  }
}