mirror of
https://github.com/tailscale/tailscale.git
synced 2025-08-11 13:18:53 +00:00
cmd/{k8s-operator,containerboot},kube: ensure egress ProxyGroup proxies don't terminate while cluster traffic is still routed to them (#14436)
cmd/{containerboot,k8s-operator},kube: add preshutdown hook for egress PG proxies This change is part of work towards minimizing downtime during update rollouts of egress ProxyGroup replicas. This change: - updates the containerboot health check logic to return Pod IP in headers, if set - always runs the health check for egress PG proxies - updates ClusterIP Services created for PG egress endpoints to include the health check endpoint - implements preshutdown endpoint in proxies. The preshutdown endpoint logic waits till, for all currently configured egress services, the ClusterIP Service health check endpoint is no longer returned by the shutting-down Pod (by looking at the new Pod IP header). - ensures that kubelet is configured to call the preshutdown endpoint This reduces the possibility that, as replicas are terminated during an update, a replica gets terminated to which cluster traffic is still being routed via the ClusterIP Service because kube proxy has not yet updated routig rules. This is not a perfect check as in practice, it only checks that the kube proxy on the node on which the proxy runs has updated rules. However, overall this might be good enough. The preshutdown logic is disabled if users have configured a custom health check port via TS_LOCAL_ADDR_PORT env var. This change throws a warnign if so and in future setting of that env var for operator proxies might be disallowed (as users shouldn't need to configure this for a Pod directly). This is backwards compatible with earlier proxy versions. Updates tailscale/tailscale#14326 Signed-off-by: Irbe Krumina <irbe@tailscale.com>
This commit is contained in:
@@ -13,9 +13,15 @@ import (
|
||||
"net/netip"
|
||||
)
|
||||
|
||||
// KeyEgressServices is name of the proxy state Secret field that contains the
|
||||
// currently applied egress proxy config.
|
||||
const KeyEgressServices = "egress-services"
|
||||
const (
|
||||
// KeyEgressServices is name of the proxy state Secret field that contains the
|
||||
// currently applied egress proxy config.
|
||||
KeyEgressServices = "egress-services"
|
||||
|
||||
// KeyHEPPings is the number of times an egress service health check endpoint needs to be pinged to ensure that
|
||||
// each currently configured backend is hit. In practice, it depends on the number of ProxyGroup replicas.
|
||||
KeyHEPPings = "hep-pings"
|
||||
)
|
||||
|
||||
// Configs contains the desired configuration for egress services keyed by
|
||||
// service name.
|
||||
@@ -24,6 +30,7 @@ type Configs map[string]Config
|
||||
// Config is an egress service configuration.
|
||||
// TODO(irbekrm): version this?
|
||||
type Config struct {
|
||||
HealthCheckEndpoint string `json:"healthCheckEndpoint"`
|
||||
// TailnetTarget is the target to which cluster traffic for this service
|
||||
// should be proxied.
|
||||
TailnetTarget TailnetTarget `json:"tailnetTarget"`
|
||||
|
@@ -55,7 +55,7 @@ func Test_jsonMarshalConfig(t *testing.T) {
|
||||
protocol: "tcp",
|
||||
matchPort: 4003,
|
||||
targetPort: 80,
|
||||
wantsBs: []byte(`{"tailnetTarget":{"ip":"","fqdn":""},"ports":[{"protocol":"tcp","matchPort":4003,"targetPort":80}]}`),
|
||||
wantsBs: []byte(`{"healthCheckEndpoint":"","tailnetTarget":{"ip":"","fqdn":""},"ports":[{"protocol":"tcp","matchPort":4003,"targetPort":80}]}`),
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
|
@@ -43,4 +43,9 @@ const (
|
||||
// that cluster workloads behind the Ingress can now be accessed via the given DNS name over HTTPS.
|
||||
KeyHTTPSEndpoint string = "https_endpoint"
|
||||
ValueNoHTTPS string = "no-https"
|
||||
|
||||
// Pod's IPv4 address header key as returned by containerboot health check endpoint.
|
||||
PodIPv4Header string = "Pod-IPv4"
|
||||
|
||||
EgessServicesPreshutdownEP = "/internal-egress-services-preshutdown"
|
||||
)
|
||||
|
Reference in New Issue
Block a user