Usage Thresholds
Introduction
The Dynamic Traffic Controller allows you to set two thresholds to mark the point at which the weight should begin to decrease from 100 and the point at which the weight should be 1. The Dynamic Traffic Controller will then calculate the weight based on the current usage value and the two thresholds.
note
A weight of 0 means do not send traffic to this service
and is reserved for
failure conditions.
Let us imagine that we have our two thresholds at 60 and 90. If we have a current usage of 60%, the weight will remain at 100. If we have a current usage of 70%, the weight will be 67. If we have a current usage of 90%, the weight will be 1.
If we have thresholds of 50 and 80 with a usage of 65%, the weight will be 50.
The weight is calculated as follows:
weight = 100 - [(current usage - low-threshold) / (high-threshold - low-threshold) * 100]
Configuration
To enable threshold on a service, add the following annotation to the relevant service definition.
annotations:
external-dns.alpha.kubernetes.io/usage-thresholds: LOW_INT,HIGH_INT
Example:
annotations:
external-dns.alpha.kubernetes.io/usage-thresholds: 50,80
The following example shows the annotations added to our sample service definition from the onboarding document.
apiVersion: v1
kind: Service
metadata:
annotations:
external-dns.alpha.kubernetes.io/usage-thresholds: 50,80
external-dns.alpha.kubernetes.io/hostname: myapp.example.com
external-dns.alpha.kubernetes.io/ttl: "60"
external-dns.alpha.kubernetes.io/weight: "100"
labels:
app: nginx
avesha.dns.metrics.io/monitor: "true"
name: myapp-internal-service
namespace: kubeslice-system
spec:
externalTrafficPolicy: Cluster
ipFamilyPolicy: SingleStack
ports:
- name: http
nodePort: 31569
port: 80
protocol: TCP
targetPort: 80
selector:
app: nginx
sessionAffinity: None
type: LoadBalancer
Confirm Measurement
After the thresholds are added, the service is influenced by the above equation. You can confirm
the DTC has picked up the service by viewing the logs for the dns-controller
pod. You can use a command similar to the one below, but with your unique pod
name.
kubectl logs dns-controller-5f7b7f7f9f-5j2xg -n kubeslice-system