adminapi

package
v2.9.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 13, 2023 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AdminAPIsFromEndpointSlice added in v2.9.0

func AdminAPIsFromEndpointSlice(endpoints discoveryv1.EndpointSlice, portNames sets.Set[string]) sets.Set[DiscoveredAdminAPI]

AdminAPIsFromEndpointSlice returns a list of Admin APIs when given an EndpointSlice.

func EnsureKonnectConnection added in v2.9.0

func EnsureKonnectConnection(ctx context.Context, client *kong.Client, logger logr.Logger) error

EnsureKonnectConnection ensures that the client is able to connect to Konnect.

func GetAdminAPIsForService added in v2.9.0

func GetAdminAPIsForService(
	ctx context.Context,
	kubeClient client.Client,
	service types.NamespacedName,
	portNames sets.Set[string],
) (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.

func MakeHTTPClient

func MakeHTTPClient(opts *HTTPClientOpts, kongAdminToken string) (*http.Client, error)

MakeHTTPClient returns an HTTP client with the specified mTLS/headers configuration.

Types

type Client added in v2.9.0

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 added in v2.9.0

func NewClient(c *kong.Client) *Client

NewClient creates an Admin API client that is to be used with a regular Admin API exposed by Kong Gateways.

func NewKongClientForKonnectRuntimeGroup added in v2.9.0

func NewKongClientForKonnectRuntimeGroup(c KonnectConfig) (*Client, error)

func NewKongClientForWorkspace added in v2.9.0

func NewKongClientForWorkspace(ctx context.Context, adminURL string, wsName string,
	httpclient *http.Client,
) (*Client, error)

NewKongClientForWorkspace returns a Kong API client for a given root API URL and workspace. If the workspace does not already exist, NewKongClientForWorkspace will create it.

func NewKonnectClient added in v2.9.0

func NewKonnectClient(c *kong.Client, runtimeGroup string) *Client

NewKonnectClient creates an Admin API client that is to be used with a Konnect Runtime Group Admin API.

func NewTestClient added in v2.9.0

func NewTestClient(address string) (*Client, error)

NewTestClient creates a client for test purposes.

func (*Client) AdminAPIClient added in v2.9.0

func (c *Client) AdminAPIClient() *kong.Client

AdminAPIClient returns an underlying go-kong's Admin API client.

func (*Client) AttachPodReference added in v2.9.0

func (c *Client) AttachPodReference(podNN types.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 added in v2.9.0

func (c *Client) BaseRootURL() string

BaseRootURL returns a base address used for communicating with the Admin API.

func (*Client) GetKongVersion added in v2.9.0

func (c *Client) GetKongVersion(ctx context.Context) (string, error)

GetKongVersion returns version of the kong gateway.

func (*Client) IsKonnect added in v2.9.0

func (c *Client) IsKonnect() bool

IsKonnect tells if a client is used for communication with Konnect Runtime Group Admin API.

func (*Client) KonnectRuntimeGroup added in v2.9.0

func (c *Client) KonnectRuntimeGroup() string

KonnectRuntimeGroup gets a unique identifier of a Konnect's Runtime Group that config should be synchronised with. Empty in case of non-Konnect clients.

func (*Client) LastConfigSHA added in v2.9.0

func (c *Client) LastConfigSHA() []byte

LastConfigSHA returns a checksum of the last successful configuration push.

func (*Client) PluginSchemaStore added in v2.9.0

func (c *Client) PluginSchemaStore() *util.PluginSchemaStore

PluginSchemaStore returns client's PluginSchemaStore.

func (*Client) PodReference added in v2.9.0

func (c *Client) PodReference() (types.NamespacedName, bool)

PodReference returns an optional reference to the Pod the client communicates with.

func (*Client) SetLastConfigSHA added in v2.9.0

func (c *Client) SetLastConfigSHA(s []byte)

SetLastConfigSHA overrides last config SHA.

type ClientFactory added in v2.9.0

type ClientFactory struct {
	// contains filtered or unexported fields
}

func NewClientFactoryForWorkspace added in v2.9.0

func NewClientFactoryForWorkspace(workspace string, httpClientOpts HTTPClientOpts, adminToken string) ClientFactory

func (ClientFactory) CreateAdminAPIClient added in v2.9.0

func (cf ClientFactory) CreateAdminAPIClient(ctx context.Context, address string) (*Client, error)

type DiscoveredAdminAPI added in v2.9.0

type DiscoveredAdminAPI struct {
	Address string
	PodRef  types.NamespacedName
}

DiscoveredAdminAPI represents an Admin API discovered from a Kubernetes Service.

type HTTPClientOpts

type HTTPClientOpts struct {
	// Disable verification of TLS certificate of Kong's Admin endpoint.
	TLSSkipVerify bool
	// SNI name to use to verify the certificate presented by Kong in TLS.
	TLSServerName string
	// Path to PEM-encoded CA certificate file to verify Kong's Admin SSL certificate.
	CACertPath string
	// PEM-encoded CA certificate to verify Kong's Admin SSL certificate.
	CACert string
	// Array of headers added to every Admin API call.
	Headers []string
	// TLSClient is TLS client config.
	TLSClient TLSClientConfig
}

HTTPClientOpts defines parameters that configure an HTTP client.

type HeaderRoundTripper

type HeaderRoundTripper struct {
	// contains filtered or unexported fields
}

HeaderRoundTripper injects Headers into requests made via RT.

func (*HeaderRoundTripper) RoundTrip

func (t *HeaderRoundTripper) RoundTrip(req *http.Request) (*http.Response, error)

RoundTrip satisfies the RoundTripper interface.

type KonnectConfig added in v2.9.0

type KonnectConfig struct {
	ConfigSynchronizationEnabled bool
	RuntimeGroupID               string
	Address                      string
	RefreshNodePeriod            time.Duration
	TLSClient                    TLSClientConfig
}

type TLSClientConfig added in v2.9.0

type TLSClientConfig struct {
	// Cert is a client certificate.
	Cert string
	// CertFile is a client certificate file path.
	CertFile string

	// Key is a client key.
	Key string
	// KeyFile is a client key file path.
	KeyFile string
}

TLSClientConfig contains TLS client certificate and client key to be used when connecting with Admin APIs. It's validated with manager.validateClientTLS before passing it further down. It guarantees that only the allowed combinations of variables will be passed: - only one of Cert / CertFile, - only one of Key / KeyFile, - if any of Cert / CertFile is set, one of Key / KeyFile has to be set, - if any of Key / KeyFile is set, one of Cert / CertFile has to be set.

func (TLSClientConfig) IsZero added in v2.9.0

func (c TLSClientConfig) IsZero() bool

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL