canonical / traefik-route-k8s-operator Goto Github PK
View Code? Open in Web Editor NEWConfiguration charm for traefik-k8s.
Home Page: https://charmhub.io/traefik-route-k8s
License: Apache License 2.0
Configuration charm for traefik-k8s.
Home Page: https://charmhub.io/traefik-route-k8s
License: Apache License 2.0
The traefik-route-k8s doesn't generate rules with the stripPrefix
middleware, while the "ingress-per-app" does so.
Is this intentional? Is that middleware not needed with ingress-per-unit
?
An example rule rendered by
http:
routers:
juju-prometheus-k8s-0-test-router:
entryPoints:
- web
rule: Host(`prometheus-k8s-operator-0.prometheus-k8s-operator-endpoints.test.svc.cluster.local`)
service: juju-prometheus-k8s-0-test-service
juju-prometheus-k8s-0-test-router-tls:
entryPoints:
- websecure
rule: Host(`prometheus-k8s-operator-0.prometheus-k8s-operator-endpoints.test.svc.cluster.local`)
service: juju-prometheus-k8s-0-test-service
tls:
domains:
- main: 10.64.140.43
sans:
- '*.10.64.140.43'
services:
juju-prometheus-k8s-0-test-service:
loadBalancer:
servers:
- url: http://prometheus-k8s-operator-0.prometheus-k8s-operator-endpoints.test.svc.cluster.local:8080
http:
middlewares:
juju-sidecar-noprefix-test-identity-platform-login-ui-operator:
stripPrefix:
forceSlash: false
prefixes:
- /test-identity-platform-login-ui-operator
routers:
juju-test-identity-platform-login-ui-operator-router:
entryPoints:
- web
middlewares:
- juju-sidecar-noprefix-test-identity-platform-login-ui-operator
rule: PathPrefix(`/test-identity-platform-login-ui-operator`)
service: juju-test-identity-platform-login-ui-operator-service
juju-test-identity-platform-login-ui-operator-router-tls:
entryPoints:
- websecure
rule: PathPrefix(`/test-identity-platform-login-ui-operator`)
service: juju-test-identity-platform-login-ui-operator-service
tls:
domains:
- main: 10.64.140.43
sans:
- '*.10.64.140.43'
services:
juju-test-identity-platform-login-ui-operator-service:
loadBalancer:
servers:
- url: http://identity-platform-login-ui-operator-0.identity-platform-login-ui-operator-endpoints.test.svc.cluster.local:8080
juju deploy traefik-route-k8s root_url=...
juju deploy traefik-k8s
juju deploy prometheus-k8s
juju relate traefik-route-k8s prometheus-k8s
juju relate traefik-route-k8s traefik-k8s
n/a
n/a
No response
Currently, traefik_route
only emits ready
traefik-route-k8s-operator/lib/charms/traefik_route_k8s/v0/traefik_route.py
Lines 185 to 189 in 55313c6
IPU and IPA also emit revoked
It could be handy to have a revoked here as well so users could only observe self.ingress.revoked
.
If the root_url begins with /
, we will fill in the host and port for you:
root_url="/baz/" will become: http://{external-hostname | loadbalancer ip}:{port}/baz/
This requires passing the host and port data from traefik to traefik-route, or passing the url template from Route to Traefik and the rendered url back to Route. (I guess the first is fine).
traefik_route_k8s
but in combination with traefik-k8s-operator so it might be a better place to own this library - ref canonical/traefik-k8s-operator#379 )It looks like we should consider archiving this charm and moving traefik_route_k8s
library to traefik-k8s-operator.
In directly-related Charm <--> Traefik scenarios, what happens is:
However let's add Traefik Route to the picture (Route henceforth) and that complicates things:
The event timeline is as follows:
PROBLEM: if at this point Route does both, there is a chance that the charm will believe it has ingress BEFORE Traefik has had the time to update its config and the service (or whatever it needs to do to actually start routing for that url).
Alternative design could be:
1-3. Stay the same
The charm errors out when deployed with grafana (e.g. in cos-lite) because traefik-route does not guard against 'external-host' possibly being None
juju deploy cos-lite --trust
juju 3.1-beta1 on local microk8s cluster.
File "/var/lib/juju/agents/unit-traefik-0/charm/venv/ops/framework.py", line 316, in emit
framework._emit(event)
File "/var/lib/juju/agents/unit-traefik-0/charm/venv/ops/framework.py", line 784, in _emit
self._reemit(event_path)
File "/var/lib/juju/agents/unit-traefik-0/charm/venv/ops/framework.py", line 857, in _reemit
custom_handler(event)
File "/var/lib/juju/agents/unit-traefik-0/charm/lib/charms/traefik_route_k8s/v0/traefik_route
.py", line 166, in _on_relation_changed
self._update_requirers_with_external_host()
File "/var/lib/juju/agents/unit-traefik-0/charm/lib/charms/traefik_route_k8s/v0/traefik_route
.py", line 175, in _update_requirers_with_external_host
relation.data[self.charm.app]["external_host"] = self._stored.external_host
File "/var/lib/juju/agents/unit-traefik-0/charm/venv/ops/model.py", line 945, in __setitem__
raise RelationDataError('relation data values must be strings')
### Additional context
_No response_
At the moment we do 'manual' string replacement to render config strings; let's not reinvent the wheel and use jinja2 for this.
Investigate if it's at all possible to test from within the charm if the root_url is valid in combination with a rule.
E.g. can we fire a get request to the url and see if it is routed correctly? Or at least if it responds?
_stored
gets overwritten every loop iteration.traefik-route-k8s-operator/lib/charms/traefik_route_k8s/v0/traefik_route.py
Lines 206 to 214 in d25e148
Originally posted in canonical/traefik-k8s-operator#234 (comment)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.