项目作者: gardener

项目描述 :
The DNS Load Balancer Controller Manager hosts kubernetes controllers managing DNS entries acting as kind of load balancer. Depending on health checks on explicitly maintained endpoints the endpoints are added or removed from an DNS entry.
高级语言: Go
项目地址: git://github.com/gardener/dnslb-controller-manager.git
创建时间: 2018-07-24T15:54:46Z
项目社区:https://github.com/gardener/dnslb-controller-manager

开源协议:Other

下载


DNS Loadbalancer Controller Manager

reuse compliant

The DNS Load Balancer Controller Manager hosts kubernetes controllers managing
DNS entries acting as kind of load balancer. Depending on health checks on
explicitly maintained endpoints the endpoints are added or removed from an DNS
entry. In order words it acts as a DNS source controller, and the DNS entries are
provisioned to an external DNS server with the help of a separately running DNS provisioning
controller. See project external-dns-management for more details.

It is primarily designed to support multi-cluster loadbalancing (see below)

It defines 2 new resource kinds using the api group loadbalancer.gardener.cloud
and version v1beta1.

  • DNSLoadBalancer: a resource describing a dedicated load balancer defining the DNS name and the health check
  • DNSLoadBalancerEndpoint: a resource describing a dedicated load balancer target endpoint

Controllers

The controller manager hosts two different controllers:

DNS Controller

The DNS Controller uses the resources described above to main DNS entries.
The DNSLoadBalancerEndpointresources are used as potential targets for the
maintained DNS names.

DNS Endpoint Controller

The endpoint controller scans a cluster for annotated service and ingress resources
looking for the annotation

  1. loadbalancer.gardener.cloud/dnsloadbalancer

expecting the name of the load balancer resource as value.
For those matching resources it maintains endpoint resources (mentioned above).

Multi Cluster Mode

Basically both controllers can work on the same cluster. This would be a single
cluster scenario. But for such a scenario the introduction of explicitly maintained
loadbalancer and endpoint resources would be superfluous.

The intended scenario is a multi-cluster scenario, where the various endpoints
reside in different clusters. Therefore the two controllers may use different
target clusters for scanning.

If two kubeconfigs are configured for the controller manager, the endpoint
controller scans the default (source) cluster for service and ingress resources
and expects the load balancer and endpoint resources to be maintained in the
second cluster.

The dns controller acts on the second cluster to look for
loadbalancers and endpoints to maintain the desired DNS entries.

This second cluster should be shared among the various source clusters to
maintain a central loadbalancing datasource.

For every source cluster the complete controller manager is deployed varying
the first cluster access for the local cluster and using the second cluster
access for the shared one.

Leases

The controllers request leases in the different clusters, therefore they can be
run multiple times across the involved clusters.

Run Modes

The controller manager can be started for a single kind of controller or for
both controllers at once. Nevertheless the DNS controller always requests
its lease from the shared cluster. Therefore it effectivly runs only once
in the complete landscape, even if started with each controller manager instance.

If the --watches option is used, the DNS controller doesn’t use the custom
resources for the load balancer but reads the definitions from the given
config file (legacy mode).

Command Line Interface

  1. This manager manages DNS LB endpoint resources for DNS Loadbalancer
  2. resources based on annotations in services and ingresses. Based on
  3. those endpoints a second controller manages DNS entries. The endpoint
  4. sources may reside in different kubernetes clusters than the one
  5. hosting the DNS loadbalancer and endpoint resources.
  6. Usage:
  7. dnslb-controller-manager [flags]
  8. Flags:
  9. --bogus-nxdomain string default for all controller "bogus-nxdomain" options
  10. -c, --controllers string comma separated list of controllers to start (<name>,source,target,all) (default "all")
  11. --dnslb-endpoint.endpoints.pool.size int worker pool size for pool endpoints of controller dnslb-endpoint
  12. --dnslb-loadbalancer.bogus-nxdomain string ip address returned by DNS for unknown domain
  13. --dnslb-loadbalancer.default.pool.size int worker pool size for pool default of controller dnslb-loadbalancer
  14. --dnslb-loadbalancer.exclude-domains stringArray excluded domains
  15. --dnslb-loadbalancer.key string selecting key for annotation
  16. --dnslb-loadbalancer.target-name-prefix string name prefix in target namespace for cross cluster generation
  17. --dnslb-loadbalancer.target-namespace string target namespace for cross cluster generation
  18. --dnslb-loadbalancer.targets.pool.size int worker pool size for pool targets of controller dnslb-loadbalancer
  19. --exclude-domains stringArray default for all controller "exclude-domains" options
  20. -h, --help help for dnslb-controller-manager
  21. --key string default for all controller "key" options
  22. --kubeconfig string default cluster access
  23. --kubeconfig.id string id for cluster default
  24. -D, --log-level string logrus log level
  25. -n, --namespace-local-access-only enable access restriction for namespace local access only
  26. --plugin-dir string directory containing go plugins
  27. --pool.size int default for all controller "pool.size" options
  28. --server-port-http int directory containing go plugins
  29. --target string target cluster for dns requests
  30. --target-name-prefix string default for all controller "target-name-prefix" options
  31. --target-namespace string default for all controller "target-namespace" options
  32. --target.id string id for cluster target

Custom Resource Definitions

DNS Load Balancer

  1. apiVersion: loadbalancer.gardener.cloud/v1beta1
  2. kind: DNSLoadBalancer
  3. metadata:
  4. name: test
  5. namespace: acme
  6. spec:
  7. DNSName: test.acme.com
  8. type: Balanced # or Exclusive
  9. healthPath: /healthz
  10. statusCode: 200 # default
  11. endpointValidityInterval: 5m # Optional
  12. status:
  13. active:
  14. - ipaddress: "172.18.117.33"
  15. name: "a-test-service"
  16. state: healthy
  17. message:

If the optional endpoint validity interval is specified, the endpoint
controller generates endpoints with a limited lifetime, and updates
it accordingly as long as it is running. The dns controller automatically
discards outdated endpoint resources.

DNS Load Balancer Endpoint

  1. apiVersion: loadbalancer.gardener.cloud/v1beta1
  2. kind: DNSLoadBalancerEndpoint
  3. metadata:
  4. name: a-test-service
  5. namespace: acme
  6. spec:
  7. ipaddress: 172.18.117.33 # or cname
  8. loadbalancer: test
  9. status:
  10. active: true
  11. healthy: true
  12. validUntil: 2018-07-24T11:34:44Z

The validUtil status property is managed by the
endpoint controller, if the loadbalancer resource requests it
by specifying a validity interval for endpoints.

HTTP Endpoints

If the controller manager is called with the --port option using a value larger
than zero an https server is started serving two endpoints:

Health Endpoint

A health endpoint with path /healthz is provided at the given port.
It reports status code 200 if everything looks fine. The timestamps of the
internal check keys are reported as content.

Metrics Endpoint

A metrics endpoint (for prometheus) is provided with the path /metrics .
It supports five metrics:

Metric Label Meaning
endpoint_health Health status of an endpoint (0/1)
loadbalancer Load balancer name
endpoint Endpoint name
endpoint_active Active status of an endpoint (assigned to DNS entry)
loadbalancer Load balancer name
endpoint Endpoint name
endpoint_hosts Hostname for an endpoint resource with health status
endpoint Endpoint name
host Hostname
loadbalancer_health Health status of a load balancer (0/1)
loadbalancer Load balancer name
loadbalancer_dnsnames DNS names of a load balancer with health status
loadbalancer Load balancer name dns_reconcile_duration
dnsname DNS name of the load balancer
dns_reconcile_duration Duration of a DNS reconcilation run
dns_reconcile_interval Duration between two DNS reconcilations