Hi,
We're using Traefik 2.4 with Kubernetes 1.21.
We're making a breaking change to a service. We'd like to:
- Disable POSTs (writes) to a certain endpoint.
- Redeploy the k8s service; this brings up the new pod before bringing down the old one.
- Re-enable POSTs to that endpoint.
This way we don't have any downtime for reads to the service during this deployment.
I heard about the noop@internal
service and tried it out:
# ingressroute.yaml
apiVersion: traefik.containo.us/v1alpha1
kind: IngressRoute
metadata:
name: myservice
spec:
entryPoints:
- websecure
routes:
# prevent POSTs to /my_path
- kind: Rule
match: Method(`POST`) && Path(`/api/my_path`)
priority: 10000
services:
- name: noop@internal
kind: TraefikService
- kind: Rule
match: PathPrefix(`/api`)
services:
- name: myservice
port: 80
This successfully blocks POST /api/my_path
from reaching myservice
. However, this returns the status 418 I Am A Teapot
. But for various reasons, we need to return 503 Service Unavailable
instead.
Is there any kind of middleware or other built-in Traefik feature that can control this?
If one of these doesn't exist, we can probably create a very thin web service that always returns 503
and point the ingressroute rule at that service, but that seems a bit annoying.