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

feat: Introduce ingress relation #62

Merged
merged 14 commits into from
Oct 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions .github/workflows/integrate.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ jobs:
provider: microk8s
channel: 1.25-strict/stable
juju-channel: 3.1/stable
microk8s-addons: "dns hostpath-storage rbac"
microk8s-addons: "dns hostpath-storage rbac metallb:10.64.140.43-10.64.140.49"

- name: Test
run: sg snap_microk8s -c "tox -vve integration -- --model testing"
Expand All @@ -71,19 +71,27 @@ jobs:
if: failure()

- name: Get envoy workload logs
run: kubectl logs --tail 100 -nci-test -ljuju-app=envoy
run: kubectl logs --tail 100 -ntesting -ljuju-app=envoy
if: failure()

- name: Get envoy operator logs
run: kubectl logs --tail 100 -nci-test -ljuju-operator=envoy
run: kubectl logs --tail 100 -ntesting -ljuju-operator=envoy
if: failure()

- name: Get mlmd workload logs
run: kubectl logs --tail 100 -nci-test -ljuju-app=mlmd
run: kubectl logs --tail 100 -ntesting -ljuju-app=mlmd
if: failure()

- name: Get mlmd operator logs
run: kubectl logs --tail 100 -nci-test -ljuju-operator=mlmd
run: kubectl logs --tail 100 -ntesting -ljuju-operator=mlmd
if: failure()

- name: Get istio-pilot workload logs
run: kubectl logs --tail 100 -ntesting -ljuju-app=istio-pilot
if: failure()

- name: Get istio-pilot operator logs
run: kubectl logs --tail 100 -ntesting -ljuju-operator=istio-pilot
if: failure()

- name: Collect charm debug artifacts
Expand Down
40 changes: 40 additions & 0 deletions metadata.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,43 @@ requires:
interface: grpc
schema: https://raw.githubusercontent.com/canonical/operator-schemas/master/grpc.yaml
versions: [v1]
ingress:
interface: ingress
schema:
v2:
requires:
type: object
properties:
service:
type: string
port:
type: integer
namespace:
type: string
prefix:
type: string
rewrite:
type: string
required:
- service
- port
- namespace
- prefix
v1:
requires:
type: object
properties:
service:
type: string
port:
type: integer
prefix:
type: string
rewrite:
type: string
required:
- service
- port
- prefix
versions: [v1]
__schema_source: https://raw.githubusercontent.com/canonical/operator-schemas/master/ingress.yaml
3 changes: 3 additions & 0 deletions requirements-integration.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,7 @@ juju
pytest-operator
selenium
selenium-wire
lightkube
aiohttp
tenacity
-r requirements.txt
45 changes: 43 additions & 2 deletions requirements-integration.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,20 @@
#
# pip-compile requirements-integration.in
#
aiohttp==3.8.6
# via -r requirements-integration.in
aiosignal==1.3.1
# via aiohttp
anyio==4.0.0
# via httpcore
asttokens==2.4.0
# via stack-data
async-timeout==4.0.3
# via aiohttp
attrs==23.1.0
# via
# -r requirements.txt
# aiohttp
# jsonschema
# outcome
# trio
Expand All @@ -29,6 +38,8 @@ cachetools==5.3.1
certifi==2023.7.22
# via
# -r requirements.txt
# httpcore
# httpx
# kubernetes
# requests
# selenium
Expand All @@ -40,6 +51,7 @@ cffi==1.16.0
charset-normalizer==3.3.0
# via
# -r requirements.txt
# aiohttp
# requests
cryptography==41.0.4
# via
Expand All @@ -53,19 +65,26 @@ envoy-data-plane==0.2.5
# via -r requirements.txt
exceptiongroup==1.1.3
# via
# anyio
# pytest
# trio
# trio-websocket
executing==2.0.0
# via stack-data
frozenlist==1.4.0
# via
# aiohttp
# aiosignal
google-auth==2.23.3
# via kubernetes
grpclib==0.4.6
# via
# -r requirements.txt
# betterproto
h11==0.14.0
# via wsproto
# via
# httpcore
# wsproto
h2==4.1.0
# via
# -r requirements.txt
Expand All @@ -75,6 +94,10 @@ hpack==4.0.0
# via
# -r requirements.txt
# h2
httpcore==0.18.0
# via httpx
httpx==0.25.0
# via lightkube
hvac==1.2.1
# via juju
hyperframe==6.0.1
Expand All @@ -85,8 +108,11 @@ hyperframe==6.0.1
idna==3.4
# via
# -r requirements.txt
# anyio
# httpx
# requests
# trio
# yarl
importlib-resources==6.1.0
# via
# -r requirements.txt
Expand All @@ -113,6 +139,10 @@ kaitaistruct==0.10
# via selenium-wire
kubernetes==27.2.0
# via juju
lightkube==0.14.0
# via -r requirements-integration.in
lightkube-models==1.28.1.4
# via lightkube
macaroonbakery==1.3.1
# via juju
markupsafe==2.1.3
Expand All @@ -122,7 +152,9 @@ matplotlib-inline==0.1.6
multidict==6.0.4
# via
# -r requirements.txt
# aiohttp
# grpclib
# yarl
mypy-extensions==1.0.0
# via typing-inspect
oauthlib==3.2.2
Expand Down Expand Up @@ -218,6 +250,7 @@ pyyaml==6.0.1
# -r requirements.txt
# juju
# kubernetes
# lightkube
# ops
# pytest-operator
# serialized-data-interface
Expand Down Expand Up @@ -251,13 +284,19 @@ six==1.16.0
# pymacaroons
# python-dateutil
sniffio==1.3.0
# via trio
# via
# anyio
# httpcore
# httpx
# trio
sortedcontainers==2.4.0
# via trio
stack-data==0.6.3
# via ipython
stringcase==1.2.0
# via -r requirements.txt
tenacity==8.2.3
# via -r requirements-integration.in
tomli==2.0.1
# via
# ipdb
Expand Down Expand Up @@ -299,6 +338,8 @@ wsproto==1.2.0
# via
# selenium-wire
# trio-websocket
yarl==1.9.2
# via aiohttp
zipp==3.17.0
# via
# -r requirements.txt
Expand Down
25 changes: 25 additions & 0 deletions src/charm.py
orfeas-k marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ def __init__(self, *args):
self.on.leader_elected,
self.on["grpc"].relation_changed,
self.on["grpc-web"].relation_changed,
self.on["ingress"].relation_changed,
]:
self.framework.observe(event, self.set_pod_spec)

Expand All @@ -166,6 +167,9 @@ def set_pod_spec(self, event):
upstreams = self._check_grpc(interfaces)

self._send_info(interfaces)

self._send_data_to_ingress_provider(interfaces)

except CheckFailed as check_failed:
self.model.unit.status = check_failed.status
return
Expand Down Expand Up @@ -276,6 +280,27 @@ def _check_grpc(self, interfaces):
raise CheckFailed("Waiting for upstream gRPC connection information.", WaitingStatus)
return upstreams

def _send_data_to_ingress_provider(self, interfaces):
"""Send data to the ingress relation data bag so the VirtualServices provider configures
a VirtualService routing traffic from `/ml_metadata` path to envoy service.

Raises an exception and sets the charm to Blocked if there is no ingress relation available
"""
if interfaces["ingress"]:
interfaces["ingress"].send_data(
{
"prefix": "/ml_metadata",
"rewrite": "/ml_metadata",
"service": self.model.app.name,
"port": int(self.model.config["http-port"]),
}
)
else:
raise CheckFailed(
"Please relate to istio-pilot, no ingress relation available.",
BlockedStatus,
)


if __name__ == "__main__":
main(Operator)
Loading
Loading