ServiceWeaver / weaver-kube

Run Service Weaver applications on vanilla Kubernetes.
Apache License 2.0
61 stars 19 forks source link

Put babysitter configuration in ConfigMap. #82

Closed mwhittaker closed 11 months ago

mwhittaker commented 12 months ago

Previously, babysitter configuration was proto encoded, base64 encoded, and passed to the babysitter via environment variable. This PR instead puts the configuration in a ConfigMap:

apiVersion: v1
data:
  config.textpb: |
    namespace:  "default"
    deployment_id:  "e98a6946-49c2-4773-98c6-48b89a6c926f"
    trace_service_url:  "http://collatz-jaeger-60914c47:14268/api/traces"
    listeners:  {
      key:  "collatz"
      value:  20000
    }
  weaver.toml: |
    [serviceweaver]
    binary = "./collatz"
    rollout = "5m"
    colocate = [
      [
        "github.com/ServiceWeaver/weaver/examples/collatz/Even",
        "github.com/ServiceWeaver/weaver/examples/collatz/Odd"
      ]
    ]

    [kube]
    listeners.collatz = {public = true}
    repo = "docker.io/themwhittaker/"
kind: ConfigMap
metadata:
  creationTimestamp: null
  name: config-e98a6946
  namespace: default

The configuration includes the original weaver.toml file and a config.textpb file that includes a prototext encoded BabysitterConfig proto (which replaces ReplicaSetConfig). These files are mounted into the babysitter containers and passed to the babysitter as command line arguments:

containers:
- args:
  - babysitter
  - /weaver/weaver.toml
  - /weaver/config.textpb
  - github.com/ServiceWeaver/weaver/Main
  image: docker.io/themwhittaker/collatz:e98a6946
  name: serviceweaver
  volumeMounts:
  - mountPath: /weaver/weaver.toml
    name: config
    subPath: weaver.toml
  - mountPath: /weaver/config.textpb
    name: config
    subPath: config.textpb
volumes:
- configMap:
    name: config-e98a6946
  name: config

This change takes us a step closer to weaver kube exec, if that's something we end up doing. It also makes the generated YAML more readable and self-explanatory.