Annotations for Load Balancers

Use annotations for Load Balancers #

Annotations are a way to add custom, non-identifiable metadata to objects. They are used to configure additional behavior for Load Balancers service in Kubernetes clusters beyond the standard configuration offerings. Learn more about annotations in the official Kubernetes documentation.

You can add annotations via the command line (kubectl) or the Kubernetes service manifest using the annotations field as follows:

metadata: {
 annotations: {
   key: "value"
 }
}

Below, we have compiled annotations that apply to clusters created in VNETWORK:

Key (annotation)Value sampleTypeDescription
loadbalancer.gcorelabs.com/
ddos-profile
{ "profile_template":65,
"fields": [{ "base_field":272,
"field_value":40 }] }
IntegerConfigures and ads the DDoS Protection profile to the Load Balancer
loadbalancer.gcorelabs.com/
flavor
lb1-1-2StringSpecifies a custom name for the flavor
loadbalancer.gcorelabs.com/
floating-cleanup
trueBooleanAutomatically cleans up the floating IP assigned to the load balancer after deleting the service
loadbalancer.gcorelabs.com/
logging-topic-name
topic-123StringSpecifies LaaS topic name for pushing logs.
Note: Must be used with the logging-destination-region-id, otherwise logs won’t be sent to LaaS
loadbalancer.gcorelabs.com/
logging-destination-region-id
1IntegerSpecifies LaaS destination region.
Note: Must be used with the logging-topic-name, otherwise logs won’t be sent to LaaS
loadbalancer.gcorelabs.com/
logging-retention-policy-period
45IntegerConfigures log retention policy for LaaS topic (in days)
loadbalancer.gcorelabs.com/
proxy-protocol
trueBooleanEnables proxy protocol type for Load Balancer listeners
loadbalancer.gcorelabs.com/
timeout-client-data
6000IntegerSets client data timeouts for Load Balancer listeners (in msec).
Note: When removed, the previously set value in effect
loadbalancer.gcorelabs.com/
timeout-member-connect
6000IntegerSets member connect timeouts for Load Balancer listeners (in msec).
Note: When removed, the previously set value in effect
loadbalancer.gcorelabs.com/
timeout-member-data
6000IntegerSets member data timeouts for Load Balancer listeners (in msec).
Note: When removed, the previously set value in effect
loadbalancer.gcorelabs.com/
x-forwarded-for
trueBooleanAdds the “X-Forwarded-For,” “X-Forwarded-Port” and “X-Forwarded-Proto“ headers to requests
service.beta.kubernetes.io/
vnetwork-internal-load-balancer
trueBooleanDisables floating IP creation and makes the Load Balancer non available for external requests
service.beta.kubernetes.io/
vnetwork-external-load-balancer
trueBooleanMakes the Load Balancer public

Examples #

Here, several examples of annotations using are presented.

To assign an Advanced DDoS protection profile to your cluster, use the following code in the manifest:

apiVersion: v1
kind: Service
metadata:
  annotations:
    loadbalancer.gcorelabs.com/ddos-profile: |
  {"profile_template":65,"fields":[{"base_field":272,"field_value":40}]}
  labels:
    app: grafana
  name: grafana
  namespace: default
spec:
  ports:
  - port: 80
    protocol: TCP
    targetPort: 80
  selector:
    app: grafana
  type: LoadBalancer

Instead of the sample values (65, 272, and 40), use the appropriate values for your project.

To enable logging for your cluster, use the following one:

apiVersion: v1
kind: Service
metadata:
  annotations:
    loadbalancer.gcorelabs.com/logging-topic-name: test123
    loadbalancer.gcorelabs.com/logging-destination-region-id: 15
  labels:
    app: grafana
  name: grafana
  namespace: default
spec:
  ports:
  - port: 80
    protocol: TCP
    targetPort: 80
  selector:
    app: grafana
  type: LoadBalancer

Instead of the sample values (test123 and 15), use the appropriate values for your project.