用于 Kubernetes 多集群入口的 Envoy 控制平面
Yggdrasil is an Envoy control plane that configures listeners and clusters based off Kubernetes ingresses from multiple Kube Clusters. This allows you to have an envoy cluster acting as a mutli-cluster loadbalancer for Kubernetes. This was something we needed as we wanted our apps to be highly available in the event of a cluster outage but did not want the solution to live inside of Kubernetes itself.
Note: Currently we support versions 1.20.x to 1.29.x of Envoy.
Note: Yggdrasil now uses Go modules to handle dependencies.
Yggdrasil will watch all Ingresses in each Kubernetes Cluster that you give it via the Kubeconfig flag. Any ingresses that match any of the ingress classes that you have specified will have a listener and cluster created that listens on the same Host as the Host defined in the Ingress object. If you have multiple clusters Yggdrasil will create a cluster address for each Kubernetes cluster your Ingress is in, the address is the address of the ingress loadbalancer.
Joseph Irving has published a blog post which describes our need for and use of Yggdrasil at Uswitch.
Please see the Getting Started guide for a walkthrough of setting up a simple HTTP service with Yggdrasil and envoy.
The basic setup is to have a cluster of envoy nodes which connect to Yggdrasil via GRPC and get given dynamic listeners and clusters from it. Yggdrasil is set up to talk to each Kubernetes api where it will watch the ingresses for any that are using the ingress class it's watching for.
Your envoy nodes only need a very minimal config where they are simply set up to get dynamic clusters and listeners from Yggdrasil. Example envoy config:
…Your ingress set up then looks like this:
Where the envoy nodes are loadbalancing between each cluster for a given ingress.
Yggdrasil always configures a path on your Envoy nodes at /yggdrasil/status, this can be used to health check your envoy nodes, it will only return 200 if your nodes have started and been configured by Yggdrasil.
Yggdrasil allows for some customisation of the route and cluster config per Ingress through the annotations below.
| Name | type |
|---|---|
| yggdrasil.uswitch.com/healthcheck-path | string |
| yggdrasil.uswitch.com/timeout | duration |
| yggdrasil.uswitch.com/cluster-timeout | duration |
| yggdrasil.uswitch.com/route-timeout | duration |
| yggdrasil.uswitch.com/per-try-timeout | duration |
| yggdrasil.uswitch.com/weight | uint32 |
| yggdrasil.uswitch.com/retry-on | string |
Specifies a path to configure a HTTP health check to. Envoy will not route to clusters that fail health checks.
Allows for adjusting the timeout in envoy.
The yggdrasil.uswitch.com/cluster-timeout annotation will set the config.cluster.v3.Cluster.ConnectTimeout
The yggdrasil.uswitch.com/route-timeout annotation will set the config.route.v3.RouteAction.Timeout
the yggdrasil.uswitch.com/per-try-timeout annotation will set the config.route.v3.RetryPolicy.PerTryTimeout
The yggdrasil.uswitch.com/timeout annotation will set all of the above with the same value. This annotation has the lowest priority, if set with one of the other TO annotations, the specific one will override the general annotation.
Allows for adjusting the load balancer weights in envoy.
Allows overwriting the default retry policy's config.route.v3.RetryPolicy.RetryOn set by the --retry-on flag (default 5xx). Accepts a comma-separated list of retry-on policies.
Below is an example of an ingress with some of the annotations specified
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: example-com
namespace: default
annotations:
yggdrasil.uswitch.com/healthcheck-path: /healthz
yggdrasil.uswitch.com/timeout: 30s
yggdrasil.uswitch.com/weight: "12"
yggdrasil.uswitch.com/retry-on: gateway-error,connect-failure
spec:
rules:
- host: example.com
http:
paths:
- backend:
serviceName: example
servicePort: 80Downstream TLS certificates can be dynamically fetched and updated from Kubernetes secrets configured under ingresses' spec.tls by setting syncSecrets true in Yggdrasil configuration (false by default).
In this mode, only a single certificate may be specified in Yggdrasil configuration. It will be used for hosts with misconfigured or invalid secret.
Note: ECDSA >256 keys are not supported by envoy and will be discarded. See https://github.com/envoyproxy/envoy/issues/10855
Yggdrasil can be configured using a config file e.g:
{
"nodeName": "foo",
"ingressClasses": ["multi-cluster", "multi-cluster-staging"],
"syncSecrets": false,
"certificates": [
{
"hosts": ["*.api.com"],
"cert": "path/to/cert",
"key": "path/to/key"
}
],
"clusters": [
{
"token": "xxxxxxxxxxxxxxxx",
"apiServer": "https://cluster1.api.com",
"ca": "pathto/cluster1/ca"
},
{
"tokenPath": "/path/to/a/token",
"apiServer": "https://cluster2.api.com",
"ca": "pathto/cluster2/ca"
}
]
}The list of certificates will be loaded by Yggdrasil and served to the Envoy nodes by inlining the key pairs. These will then be used to group the ingress into different filter chains, split using hosts.
nodeName is the same node-name that you start your envoy nodes with.
The ingressClasses is a list of ingress classes that yggdrasil will watch for.
Each cluster represents a different Kubernetes cluster with the token being a service account token for that cluster. ca is the Path to the ca certificate for that cluster.
Yggdrasil has a number of Go, gRPC, Prometheus, and Yggdrasil-specific metrics built in which can be reached by cURLing the /metrics path at the health API address/port (default: 8081). See Flags for more information on configuring the health API address/port.
The Yggdrasil-specific metrics which are available from the API are:
| Name | Description | Type |
|---|---|---|
| yggdrasil_cluster_updates | Number of times the clusters have been updated | counter |
| yggdrasil_clusters | Total number of clusters generated | gauge |
| yggdrasil_ingresses | Total number of matching ingress objects | gauge |
| yggdrasil_listener_updates | Number of times the listener has been updated | counter |
| yggdrasil_virtual_hosts | Total number of virtual hosts generated | gauge |
…暂无开放 Issues,或尚未同步最近议题。