Documentation
¶
Index ¶
- Constants
- func EnsureKonnectConnection(ctx context.Context, client *kong.Client, logger logr.Logger) error
- func KonnectHTTPDoer() kong.Doer
- func NewKongAPIClient(adminURL string, kongAdminAPIConfig managercfg.AdminAPIClientConfig, ...) (*kong.Client, error)
- type Client
- func (c *Client) AdminAPIClient() *kong.Client
- func (c *Client) AttachPodReference(podNN k8stypes.NamespacedName)
- func (c *Client) BaseRootURL() string
- func (c *Client) GetKongVersion(ctx context.Context) (string, error)
- func (c *Client) IsKonnect() bool
- func (c *Client) IsReady(ctx context.Context) error
- func (c *Client) KonnectControlPlane() string
- func (c *Client) LastCacheStoresHash() store.SnapshotHash
- func (c *Client) LastConfigSHA() []byte
- func (c *Client) NodeID(ctx context.Context) (string, error)
- func (c *Client) PluginSchemaStore() *util.PluginSchemaStore
- func (c *Client) PodReference() (k8stypes.NamespacedName, bool)
- func (c *Client) SetLastCacheStoresHash(s store.SnapshotHash)
- func (c *Client) SetLastConfigSHA(s []byte)
- type ClientFactory
- type Clock
- type DiscoveredAdminAPI
- type Discoverer
- type HeaderRoundTripper
- type KongGatewayUnsupportedVersionError
- type KonnectBackoffStrategy
- type KonnectClient
- type KonnectClientFactory
- type UpdateBackoffStrategy
Constants ¶
const ( KonnectBackoffInitialInterval = time.Second * 3 KonnectBackoffMaxInterval = time.Minute * 15 KonnectBackoffMultiplier = 2 )
const (
HeaderNameAdminToken = "Kong-Admin-Token"
)
Variables ¶
This section is empty.
Functions ¶
func EnsureKonnectConnection ¶
EnsureKonnectConnection ensures that the client is able to connect to Konnect.
func KonnectHTTPDoer ¶
KonnectHTTPDoer is a Doer implementation to be used with Konnect Admin API client. It decorates the HTTP client Do method with extracting tracing information from the response headers and logging it for correlation with traces in DataDog.
func NewKongAPIClient ¶
func NewKongAPIClient(adminURL string, kongAdminAPIConfig managercfg.AdminAPIClientConfig, kongAdminToken string) (*kong.Client, error)
NewKongAPIClient returns a Kong API client for a given root API URL. It ensures that proper User-Agent is set. Do not use kong.NewClient directly.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is a wrapper around raw *kong.Client. It's advised to pass this wrapper across the codebase, and fallback to the underlying *kong.Client only when it's passed to external functions that require it. Also, where it's possible, use a specific Abstract*Service interfaces that *kong.Client includes. Each Client holds its own PluginSchemaStore to cache plugins' schemas as they may theoretically differ between instances.
func NewClient ¶
NewClient creates an Admin API client that is to be used with a regular Admin API exposed by Kong Gateways.
func NewKongClientForWorkspace ¶
func NewKongClientForWorkspace( ctx context.Context, adminURL string, wsName string, kongAdminAPIConfig managercfg.AdminAPIClientConfig, kongAdminToken string, ) (*Client, error)
NewKongClientForWorkspace returns a Kong API client for a given root API URL and workspace. It ensures that the client is ready to be used by performing a status check, returns KongClientNotReadyError if not or KongGatewayUnsupportedVersionError if it can't check Kong Gateway's version or it is not >= 3.4.1. If the workspace does not already exist, NewKongClientForWorkspace will create it.
func NewTestClient ¶
NewTestClient creates a client for test purposes.
func (*Client) AdminAPIClient ¶
AdminAPIClient returns an underlying go-kong's Admin API client.
func (*Client) AttachPodReference ¶
func (c *Client) AttachPodReference(podNN k8stypes.NamespacedName)
AttachPodReference allows attaching a Pod reference to the client. Should be used in case we know what Pod the client will communicate with (e.g. when the gateway service discovery is used).
func (*Client) BaseRootURL ¶
BaseRootURL returns a base address used for communicating with the Admin API.
func (*Client) GetKongVersion ¶
GetKongVersion returns version of the kong gateway.
func (*Client) IsKonnect ¶
IsKonnect tells if a client is used for communication with Konnect Control Plane Admin API.
func (*Client) KonnectControlPlane ¶
KonnectControlPlane gets a unique identifier of a Konnect's Control Plane that config should be synchronised with. Empty in case of non-Konnect clients.
func (*Client) LastCacheStoresHash ¶
func (c *Client) LastCacheStoresHash() store.SnapshotHash
LastCacheStoresHash returns a checksum of the last successful cache stores push.
func (*Client) LastConfigSHA ¶
LastConfigSHA returns a checksum of the last successful configuration push.
func (*Client) PluginSchemaStore ¶
func (c *Client) PluginSchemaStore() *util.PluginSchemaStore
PluginSchemaStore returns client's PluginSchemaStore.
func (*Client) PodReference ¶
func (c *Client) PodReference() (k8stypes.NamespacedName, bool)
PodReference returns an optional reference to the Pod the client communicates with.
func (*Client) SetLastCacheStoresHash ¶
func (c *Client) SetLastCacheStoresHash(s store.SnapshotHash)
SetLastCacheStoresHash overrides last cache stores hash.
func (*Client) SetLastConfigSHA ¶
SetLastConfigSHA overrides last config SHA.
type ClientFactory ¶
type ClientFactory struct {
// contains filtered or unexported fields
}
func NewClientFactoryForWorkspace ¶
func NewClientFactoryForWorkspace( logger logr.Logger, workspace string, clientOpts managercfg.AdminAPIClientConfig, adminToken string, ) ClientFactory
func (ClientFactory) CreateAdminAPIClient ¶
func (cf ClientFactory) CreateAdminAPIClient(ctx context.Context, discoveredAdminAPI DiscoveredAdminAPI) (*Client, error)
type DiscoveredAdminAPI ¶
type DiscoveredAdminAPI struct { // Address format is https://10.68.0.5:8444. Address string // TLSServerName format is pod.dataplane-admin-kong-rqwr9-sc49t.default.svc. TLSServerName string // PodRef is the reference to the Pod with the above IP address. PodRef k8stypes.NamespacedName }
DiscoveredAdminAPI represents an Admin API discovered from a Kubernetes Service. For field Address use format https://<podIP>:<port>, and for field TLSServerName use format pod.<serviceName>.<namespace>.svc.
type Discoverer ¶
type Discoverer struct {
// contains filtered or unexported fields
}
func NewDiscoverer ¶
func NewDiscoverer( adminAPIPortNames sets.Set[string], ) (*Discoverer, error)
func (*Discoverer) AdminAPIsFromEndpointSlice ¶
func (d *Discoverer) AdminAPIsFromEndpointSlice( endpoints discoveryv1.EndpointSlice, ) (sets.Set[DiscoveredAdminAPI], error)
AdminAPIsFromEndpointSlice returns a list of Admin APIs when given an EndpointSlice.
func (*Discoverer) GetAdminAPIsForService ¶
func (d *Discoverer) GetAdminAPIsForService( ctx context.Context, kubeClient client.Client, service k8stypes.NamespacedName, ) (sets.Set[DiscoveredAdminAPI], error)
GetAdminAPIsForService performs an endpoint lookup, using provided kubeClient to list provided Admin API Service EndpointSlices. The retrieved EndpointSlices' ports are compared with the provided portNames set.
type HeaderRoundTripper ¶
type HeaderRoundTripper struct {
// contains filtered or unexported fields
}
HeaderRoundTripper injects Headers into requests made via RT.
type KongGatewayUnsupportedVersionError ¶
type KongGatewayUnsupportedVersionError struct {
// contains filtered or unexported fields
}
func (KongGatewayUnsupportedVersionError) Error ¶
func (e KongGatewayUnsupportedVersionError) Error() string
type KonnectBackoffStrategy ¶
type KonnectBackoffStrategy struct {
// contains filtered or unexported fields
}
KonnectBackoffStrategy keeps track of Konnect config push backoffs.
It takes into account: - a regular exponential backoff that is incremented on every Update failure, - a last failed configuration hash (where we skip Update until a config changes).
It's important to note that KonnectBackoffStrategy can use the latter (config hash) because of the nature of the one-directional integration where KIC is the only component responsible for populating configuration of Konnect's Control Plane. In case that changes in the future (e.g. manual modifications to parts of the configuration are allowed on Konnect side for some reason), we might have to drop this part of the backoff strategy.
func NewKonnectBackoffStrategy ¶
func NewKonnectBackoffStrategy(clock Clock) *KonnectBackoffStrategy
func (*KonnectBackoffStrategy) CanUpdate ¶
func (s *KonnectBackoffStrategy) CanUpdate(configHash []byte) (bool, string)
func (*KonnectBackoffStrategy) RegisterUpdateFailure ¶
func (s *KonnectBackoffStrategy) RegisterUpdateFailure(err error, configHash []byte)
func (*KonnectBackoffStrategy) RegisterUpdateSuccess ¶
func (s *KonnectBackoffStrategy) RegisterUpdateSuccess()
type KonnectClient ¶
type KonnectClient struct { Client // contains filtered or unexported fields }
func NewKongClientForKonnectControlPlane ¶
func NewKongClientForKonnectControlPlane(c managercfg.KonnectConfig) (*KonnectClient, error)
func NewKonnectClient ¶
func NewKonnectClient(c *kong.Client, controlPlane string, consumersSyncDisabled bool) *KonnectClient
NewKonnectClient creates an Admin API client that is to be used with a Konnect Control Plane Admin API.
func (*KonnectClient) BackoffStrategy ¶
func (c *KonnectClient) BackoffStrategy() UpdateBackoffStrategy
func (*KonnectClient) ConsumersSyncDisabled ¶
func (c *KonnectClient) ConsumersSyncDisabled() bool
type KonnectClientFactory ¶
type KonnectClientFactory struct {
// contains filtered or unexported fields
}
KonnectClientFactory is a factory to create KonnectClient instances.
func NewKonnectClientFactory ¶
func NewKonnectClientFactory(konnectConfig managercfg.KonnectConfig, logger logr.Logger) *KonnectClientFactory
NewKonnectClientFactory creates a new KonnectClientFactory instance.
func (*KonnectClientFactory) NewKonnectClient ¶
func (f *KonnectClientFactory) NewKonnectClient(ctx context.Context) (*KonnectClient, error)
NewKonnectClient create a new KonnectClient instance, ensuring the connection to Konnect Admin API. Please note it may block for a few seconds while trying to connect to Konnect Admin API.
type UpdateBackoffStrategy ¶
type UpdateBackoffStrategy interface { // CanUpdate tells whether we're allowed to make an update attempt for a given config hash. // In case it returns false, the second return value is a human-readable explanation of why the update cannot // be performed at this point in time. CanUpdate([]byte) (bool, string) // RegisterUpdateSuccess resets the backoff strategy, effectively making it allow next update straight away. RegisterUpdateSuccess() // RegisterUpdateFailure registers an update failure along with its failure reason passed as a generic error, and // a config hash that we failed to push. RegisterUpdateFailure(failureReason error, configHash []byte) }
UpdateBackoffStrategy keeps state of an update backoff strategy.