Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Put babysitter configuration in ConfigMap. #82

Merged
merged 2 commits into from
Oct 23, 2023
Merged

Put babysitter configuration in ConfigMap. #82

merged 2 commits into from
Oct 23, 2023

Conversation

mwhittaker
Copy link
Member

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.

@mwhittaker mwhittaker self-assigned this Oct 20, 2023
Copy link
Collaborator

@rgrandl rgrandl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks much nicer. Thank you

cmd/weaver-kube/babysitter.go Show resolved Hide resolved
@mwhittaker mwhittaker force-pushed the no_proto branch 3 times, most recently from ac7cdb7 to 17e85de Compare October 23, 2023 19:45
Base automatically changed from no_proto to main October 23, 2023 19:49
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:

```yaml
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:

```yaml
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.
@mwhittaker mwhittaker merged commit 23311ed into main Oct 23, 2023
10 checks passed
@mwhittaker mwhittaker deleted the no_opaque branch October 23, 2023 20:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants