Skip to content

Commit

Permalink
feat: Configure envoy using a yaml file (#101)
Browse files Browse the repository at this point in the history
* Remove the config generation component that used a python package in 
  order to generate the envoy configuration file. Instead, render a simple `yaml` 
  file with the proper context. 
* Omit the usage of `upstream_service` value (which comes from `mlmd` charm and 
  by default has the value `metadata-grpc-service`) in naming the `cluster`. This does 
  not serve any purpose and also makes us diverge from upstream.

Closes #100
  • Loading branch information
orfeas-k authored May 29, 2024
1 parent eacf315 commit 2d4526b
Show file tree
Hide file tree
Showing 8 changed files with 75 additions and 312 deletions.
41 changes: 16 additions & 25 deletions requirements-integration.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ aiohttp==3.9.3
# via -r requirements-integration.in
aiosignal==1.3.1
# via aiohttp
annotated-types==0.6.0
# via
# -r requirements.txt
# pydantic
anyio==4.3.0
# via
# -r requirements.txt
Expand All @@ -27,10 +31,6 @@ backcall==0.2.0
# via ipython
bcrypt==4.1.2
# via paramiko
betterproto==2.0.0b6
# via
# -r requirements.txt
# envoy-data-plane
blinker==1.7.0
# via selenium-wire
brotli==1.1.0
Expand Down Expand Up @@ -70,8 +70,6 @@ deepdiff==6.2.1
# via
# -r requirements.txt
# charmed-kubeflow-chisme
envoy-data-plane==0.2.5
# via -r requirements.txt
exceptiongroup==1.2.0
# via
# -r requirements.txt
Expand All @@ -87,24 +85,15 @@ frozenlist==1.4.1
# aiosignal
google-auth==2.29.0
# via kubernetes
grpclib==0.4.7
# via
# -r requirements.txt
# betterproto
h11==0.14.0
# via
# -r requirements.txt
# httpcore
# wsproto
h2==4.1.0
# via
# -r requirements.txt
# grpclib
# selenium-wire
# via selenium-wire
hpack==4.0.0
# via
# -r requirements.txt
# h2
# via h2
httpcore==1.0.4
# via
# -r requirements.txt
Expand All @@ -117,7 +106,6 @@ hvac==2.1.0
# via juju
hyperframe==6.0.1
# via
# -r requirements.txt
# h2
# selenium-wire
idna==3.6
Expand Down Expand Up @@ -176,9 +164,7 @@ matplotlib-inline==0.1.6
# via ipython
multidict==6.0.5
# via
# -r requirements.txt
# aiohttp
# grpclib
# yarl
mypy-extensions==1.0.0
# via typing-inspect
Expand Down Expand Up @@ -236,6 +222,12 @@ pyasn1-modules==0.3.0
# via google-auth
pycparser==2.21
# via cffi
pydantic==2.6.4
# via -r requirements.txt
pydantic-core==2.16.3
# via
# -r requirements.txt
# pydantic
pygments==2.17.2
# via ipython
pymacaroons==0.13.0
Expand Down Expand Up @@ -270,10 +262,7 @@ pytest-asyncio==0.21.1
pytest-operator==0.34.0
# via -r requirements-integration.in
python-dateutil==2.9.0.post0
# via
# -r requirements.txt
# betterproto
# kubernetes
# via kubernetes
pytz==2024.1
# via pyrfc3339
pyyaml==6.0.1
Expand Down Expand Up @@ -318,7 +307,6 @@ serialized-data-interface==0.7.0
# charmed-kubeflow-chisme
six==1.16.0
# via
# -r requirements.txt
# asttokens
# kubernetes
# macaroonbakery
Expand Down Expand Up @@ -358,9 +346,12 @@ trio-websocket==0.11.1
typing-extensions==4.10.0
# via
# -r requirements.txt
# annotated-types
# anyio
# cosl
# ipython
# pydantic
# pydantic-core
# selenium
# typing-inspect
typing-inspect==0.9.0
Expand Down
34 changes: 0 additions & 34 deletions requirements-unit.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@ attrs==23.2.0
# via
# -r requirements.txt
# jsonschema
betterproto==2.0.0b6
# via
# -r requirements.txt
# envoy-data-plane
certifi==2024.2.2
# via
# -r requirements.txt
Expand All @@ -40,29 +36,15 @@ deepdiff==6.2.1
# via
# -r requirements.txt
# charmed-kubeflow-chisme
envoy-data-plane==0.2.5
# via -r requirements.txt
exceptiongroup==1.2.0
# via
# -r requirements.txt
# anyio
# pytest
grpclib==0.4.7
# via
# -r requirements.txt
# betterproto
h11==0.14.0
# via
# -r requirements.txt
# httpcore
h2==4.1.0
# via
# -r requirements.txt
# grpclib
hpack==4.0.0
# via
# -r requirements.txt
# h2
httpcore==1.0.4
# via
# -r requirements.txt
Expand All @@ -71,10 +53,6 @@ httpx==0.27.0
# via
# -r requirements.txt
# lightkube
hyperframe==6.0.1
# via
# -r requirements.txt
# h2
idna==3.6
# via
# -r requirements.txt
Expand Down Expand Up @@ -107,10 +85,6 @@ markupsafe==2.1.5
# via
# -r requirements.txt
# jinja2
multidict==6.0.5
# via
# -r requirements.txt
# grpclib
oci-image==1.0.0
# via -r requirements.txt
ops==2.11.0
Expand Down Expand Up @@ -150,10 +124,6 @@ pytest-lazy-fixture==0.6.3
# via -r requirements-unit.in
pytest-mock==3.12.0
# via -r requirements-unit.in
python-dateutil==2.9.0.post0
# via
# -r requirements.txt
# betterproto
pyyaml==6.0.1
# via
# -r requirements.txt
Expand All @@ -177,10 +147,6 @@ serialized-data-interface==0.7.0
# via
# -r requirements.txt
# charmed-kubeflow-chisme
six==1.16.0
# via
# -r requirements.txt
# python-dateutil
sniffio==1.3.1
# via
# -r requirements.txt
Expand Down
2 changes: 0 additions & 2 deletions requirements.in
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
charmed-kubeflow-chisme >= 0.3.0
# from prometheus_k8s.v0.prometheus_scrape.py
cosl
envoy_data_plane==0.2.5
# if unpinned causes problems with installation resulting in module 'platform' has no attribute 'dist'
oci-image
ops
# # pydantic>=2.7 requires rustc v1.76 or newer,
Expand Down
18 changes: 0 additions & 18 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ anyio==4.3.0
# via httpx
attrs==23.2.0
# via jsonschema
betterproto==2.0.0b6
# via envoy-data-plane
certifi==2024.2.2
# via
# httpcore
Expand All @@ -25,24 +23,14 @@ cosl==0.0.10
# via -r requirements.in
deepdiff==6.2.1
# via charmed-kubeflow-chisme
envoy-data-plane==0.2.5
# via -r requirements.in
exceptiongroup==1.2.0
# via anyio
grpclib==0.4.7
# via betterproto
h11==0.14.0
# via httpcore
h2==4.1.0
# via grpclib
hpack==4.0.0
# via h2
httpcore==1.0.4
# via httpx
httpx==0.27.0
# via lightkube
hyperframe==6.0.1
# via h2
idna==3.6
# via
# anyio
Expand All @@ -60,8 +48,6 @@ lightkube-models==1.29.0.7
# via lightkube
markupsafe==2.1.5
# via jinja2
multidict==6.0.5
# via grpclib
oci-image==1.0.0
# via -r requirements.in
ops==2.11.0
Expand All @@ -80,8 +66,6 @@ pydantic-core==2.16.3
# via pydantic
pyrsistent==0.20.0
# via jsonschema
python-dateutil==2.9.0.post0
# via betterproto
pyyaml==6.0.1
# via
# cosl
Expand All @@ -96,8 +80,6 @@ ruamel-yaml-clib==0.2.8
# via ruamel-yaml
serialized-data-interface==0.7.0
# via charmed-kubeflow-chisme
six==1.16.0
# via python-dateutil
sniffio==1.3.1
# via
# anyio
Expand Down
34 changes: 14 additions & 20 deletions src/charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@
from ops.charm import CharmBase
from ops.main import main

from components.config_generation import GenerateEnvoyConfig, GenerateEnvoyConfigInputs
from components.ingress import IngressRelationWarnIfMissing, IngressRelationWarnIfMissingInputs
from components.k8s_service_info_requirer_component import K8sServiceInfoRequirerComponent
from components.pebble import EnvoyPebbleService, EnvoyPebbleServiceInputs

ENVOY_CONFIG_FILE_PATH = "/envoy/envoy.json"
ENVOY_CONFIG_FILE_DESTINATION_PATH = "/envoy/envoy.yaml"
ENVOY_CONFIG_FILE_SOURCE_PATH = "src/templates/envoy.yaml.j2"
GRPC_RELATION_NAME = "grpc"
METRICS_PATH = "/stats/prometheus"

Expand Down Expand Up @@ -78,20 +78,6 @@ def __init__(self, *args):
depends_on=[self.ingress_relation],
)

self.envoy_config_generator = self.charm_reconciler.add(
GenerateEnvoyConfig(
charm=self,
name="envoy_config_generator",
inputs_getter=lambda: GenerateEnvoyConfigInputs(
admin_port=int(self.config["admin-port"]),
http_port=int(self.config["http-port"]),
upstream_service=self.grpc.component.get_service_info().name,
upstream_port=self.grpc.component.get_service_info().port,
),
),
depends_on=[self.grpc],
)

self.envoy_pebble_container = self.charm_reconciler.add(
component=EnvoyPebbleService(
charm=self,
Expand All @@ -100,13 +86,21 @@ def __init__(self, *args):
container_name="envoy",
files_to_push=[
LazyContainerFileTemplate(
destination_path=ENVOY_CONFIG_FILE_PATH,
source_template=self.envoy_config_generator.component.get_config,
destination_path=ENVOY_CONFIG_FILE_DESTINATION_PATH,
source_template_path=ENVOY_CONFIG_FILE_SOURCE_PATH,
context=lambda: {
"admin_port": self.config["admin-port"],
"http_port": self.config["http-port"],
"upstream_service": self.grpc.component.get_service_info().name,
"upstream_port": self.grpc.component.get_service_info().port,
},
)
],
inputs_getter=lambda: EnvoyPebbleServiceInputs(config_path=ENVOY_CONFIG_FILE_PATH),
inputs_getter=lambda: EnvoyPebbleServiceInputs(
config_path=ENVOY_CONFIG_FILE_DESTINATION_PATH
),
),
depends_on=[self.envoy_config_generator],
depends_on=[self.grpc],
)

self.charm_reconciler.install_default_event_handlers()
Expand Down
Loading

0 comments on commit 2d4526b

Please sign in to comment.