Files
tailscale/kube/localclient/local-client.go
chaosinthecrd b5fa6773ce cmd/containerboot,kube/{certs,health,localclient}: serve /livez and /readyz
Proxies only serve /healthz, which reports whether the node has a tailnet IP,
so it can't back a liveness or readiness probe. When TS_ENABLE_HEALTH_CHECK is
set, containerboot now also serves /livez, which fails only when tailscaled
stops answering LocalAPI, and /readyz, which passes once the node has tailnet
IPs and, with TS_SERVE_CONFIG set, has applied the serve config and has a cert
for each HTTPS-only Tailscale Service it advertises. Certs are checked through
the read-only cert-status endpoint so the probe never triggers issuance. An
expired or unreadable cert counts as present, as failing readiness on it would
stop a StatefulSet rollout before it reaches the replica that renews certs.

Updates tailscale/corp#38175

Signed-off-by: chaosinthecrd <[email protected]>
2026-11-19 13:17:44 +00:00

73 lines
2.2 KiB
Go

// Copyright (c) Tailscale Inc & contributors
// SPDX-License-Identifier: BSD-3-Clause
// Package localclient provides an interface for all the local.Client methods
// kube needs to use, so that we can easily mock it in tests.
package localclient
import (
"context"
"io"
"tailscale.com/client/local"
"tailscale.com/ipn"
"tailscale.com/tailcfg"
)
// LocalClient is roughly a subset of the local.Client struct's methods, used
// for easier testing.
type LocalClient interface {
WatchIPNBus(ctx context.Context, mask ipn.NotifyWatchOpt) (IPNBusWatcher, error)
SetServeConfig(context.Context, *ipn.ServeConfig) error
EditPrefs(ctx context.Context, mp *ipn.MaskedPrefs) (*ipn.Prefs, error)
CertDomains(ctx context.Context) ([]string, error)
CertIssuer
}
// IPNBusWatcher is local.IPNBusWatcher's methods restated in an interface to
// allow for easier mocking in tests.
type IPNBusWatcher interface {
io.Closer
Next() (ipn.Notify, error)
}
type CertIssuer interface {
CertPair(context.Context, string) ([]byte, []byte, error)
// CertStatus reports the state of the cached cert for domain without
// fetching or issuing one.
CertStatus(context.Context, string) (*tailcfg.C2NTLSCertInfo, error)
}
// New returns a LocalClient that wraps the provided local.Client.
func New(lc *local.Client) LocalClient {
return &localClient{lc: lc}
}
type localClient struct {
lc *local.Client
}
func (lc *localClient) SetServeConfig(ctx context.Context, config *ipn.ServeConfig) error {
return lc.lc.SetServeConfig(ctx, config)
}
func (lc *localClient) EditPrefs(ctx context.Context, mp *ipn.MaskedPrefs) (*ipn.Prefs, error) {
return lc.lc.EditPrefs(ctx, mp)
}
func (lc *localClient) WatchIPNBus(ctx context.Context, mask ipn.NotifyWatchOpt) (IPNBusWatcher, error) {
return lc.lc.WatchIPNBus(ctx, mask)
}
func (lc *localClient) CertPair(ctx context.Context, domain string) ([]byte, []byte, error) {
return lc.lc.CertPair(ctx, domain)
}
func (lc *localClient) CertStatus(ctx context.Context, domain string) (*tailcfg.C2NTLSCertInfo, error) {
return lc.lc.CertStatus(ctx, domain)
}
func (lc *localClient) CertDomains(ctx context.Context) ([]string, error) {
return lc.lc.CertDomains(ctx)
}