Kubernetes Autostopping for Traefik
Create AutoStopping rules for Kubernetes with the Traefik ingress controller.
Learn how to create AutoStopping rules for Kubernetes with the Traefik ingress controller.
Prerequisites
Make sure to meet the following prerequisites before you create an AutoStopping rule for Traefik.
Make sure you are running at the least version 1.0.5 of
autostopping-controllerin your Kubernetes cluster.Traefik
ingressRouteis configured and is routing traffic to the service as expected.Routing to external names is allowed in Traefik by setting the following flag:
--providers.kubernetescrd.allowexternalnameservices=trueYou should have access to edit the Traefik ingressRoute.
Set up your cluster
Create an AutoStopping rule in your cluster, either through the Harness UI or by applying YAML directly on the cluster of the form:
apiVersion: ccm.harness.io/v1
kind: AutoStoppingRule
metadata:
name: test-rule
namespace: default
annotations:
harness.io/cloud-connector-id: CloudAccountID
spec:
service:
name: echo
port: 8080
traefik:
ingressRoute: httpbin
idleTimeMins: 5
hideProgressPage: falseAfter applying the YAML, an AutoStopping Rule is created in your cluster for service echo which is running on port 8080.
Create Traefik Middleware to pass the extra-header
This header sends the AutoStoppingRule header to all the associated ingress routes.
The AutoStoppingRule header should be set to a value following the pattern <namespace>-<rule> which can be found from the metadata of the AutoStoppingRule you created above.
Change IngressRoute
Once the Traefik ingressRoute is supported as a first class entity for AutoStopping, these changes will be automated.
After creating the AutoStopping Rule, make the following changes in your Traefik IngressRoute:
Change the destination
From
To
Add header middleware. Under the spec for the ingressroute, add the middleware that was created earlier.
Your ingressRoute should be similar to the following:
Now your traffic flows through the autostopping-router and the AutoStopping rule takes actions based on activity and inactivity.
Last updated
Was this helpful?