konnect

package
v2.9.0 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2023 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MinRefreshNodePeriod     = 30 * time.Second
	DefaultRefreshNodePeriod = 60 * time.Second
)
View Source
const (
	// NodeTypeIngressController is the type of nodes representing KIC instances.
	NodeTypeIngressController = "ingress-controller"
	// NodeTypeKongProxy is the type of nodes representing kong gateway instances.
	NodeTypeKongProxy = "kong-proxy"
)

Variables

View Source
var KicNodeAPIPathPattern = "%s/kic/api/runtime_groups/%s/v1/kic-nodes"

KicNodeAPIPathPattern is the path pattern for KIC node operations.

Functions

This section is empty.

Types

type CompatibilityIssue

type CompatibilityIssue struct {
	Code              string          `json:"code"`
	Severity          string          `json:"severity"`
	Description       string          `json:"description"`
	Resolution        string          `json:"resolution"`
	AffectedResources []*KongResource `json:"affected_resources"`
}

type CompatibilityState

type CompatibilityState string
const (
	CompatibilityStateUnspecified     CompatibilityState = "COMPATIBILITY_STATE_UNSPECIFIED"
	CompatibilityStateFullyCompatible CompatibilityState = "COMPATIBILITY_STATE_FULLY_COMPATIBLE"
	CompatibilityStateInconpatible    CompatibilityState = "COMPATIBILITY_STATE_INCOMPATIBLE"
	CompatibilityStateUnknown         CompatibilityState = "COMPATIBILITY_STATE_UNKNOWN"
)

type CompatibilityStatus

type CompatibilityStatus struct {
	State  CompatibilityState    `json:"state"`
	Issues []*CompatibilityIssue `json:"issues,omitempty"`
}

type CreateNodeRequest

type CreateNodeRequest struct {
	ID                  string               `json:"id,omitempty"`
	Hostname            string               `json:"hostname"`
	Type                string               `json:"type"`
	LastPing            int64                `json:"last_ping"`
	Version             string               `json:"version"`
	CompatabilityStatus *CompatibilityStatus `json:"compatibility_status,omitempty"`
	Status              string               `json:"status,omitempty"`
	ConfigHash          string               `json:"config_hash,omitempty"`
}

type CreateNodeResponse

type CreateNodeResponse struct {
	Item *NodeItem `json:"item"`
}

type GatewayClientGetter

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

GatewayClientGetter gets gateway instances from admin API clients.

func NewGatewayClientGetter

func NewGatewayClientGetter(logger logr.Logger, clientsProvider dataplane.AdminAPIClientsProvider) *GatewayClientGetter

NewGatewayClientGetter creates a GatewayClientGetter to get gateway instances from client provider.

func (*GatewayClientGetter) GetGatewayInstances

func (p *GatewayClientGetter) GetGatewayInstances() ([]GatewayInstance, error)

GetGatewayInstances gets gateway instances from currently available gateway API clients.

type GatewayClientsChangesNotifier

type GatewayClientsChangesNotifier interface {
	SubscribeToGatewayClientsChanges() (<-chan struct{}, bool)
}

type GatewayInstance

type GatewayInstance struct {
	Hostname string
	Version  string
}

GatewayInstance is a controlled kong gateway instance. its hostname and version will be used to update status of nodes corresponding to the instance in konnect.

type GatewayInstanceGetter

type GatewayInstanceGetter interface {
	GetGatewayInstances() ([]GatewayInstance, error)
}

GatewayInstanceGetter is the interface to get currently running gateway instances in the kubernetes cluster.

type IngressControllerState

type IngressControllerState string
const (
	IngressControllerStateUnspecified       IngressControllerState = "INGRESS_CONTROLLER_STATE_UNSPECIFIED"
	IngressControllerStateOperational       IngressControllerState = "INGRESS_CONTROLLER_STATE_OPERATIONAL"
	IngressControllerStatePartialConfigFail IngressControllerState = "INGRESS_CONTROLLER_STATE_PARTIAL_CONFIG_FAIL"
	IngressControllerStateInoperable        IngressControllerState = "INGRESS_CONTROLLER_STATE_INOPERABLE"
	IngressControllerStateUnknown           IngressControllerState = "INGRESS_CONTROLLER_STATE_UNKNOWN"
)

type KongResource

type KongResource struct {
	ID   string `json:"id,omitempty"`
	Type string `json:"type,omitempty"`
}

type ListNodeResponse

type ListNodeResponse struct {
	Items []*NodeItem     `json:"items"`
	Page  *PaginationInfo `json:"page"`
}

type NodeAPIClient

type NodeAPIClient struct {
	Address        string
	RuntimeGroupID string
	Client         *http.Client
}

NodeAPIClient is used for sending requests to Konnect Node API. It can be used to register Nodes in Konnect's Runtime Groups.

func NewNodeAPIClient

func NewNodeAPIClient(cfg adminapi.KonnectConfig) (*NodeAPIClient, error)

NewNodeAPIClient creates a Konnect client.

func (*NodeAPIClient) CreateNode

func (*NodeAPIClient) DeleteNode

func (c *NodeAPIClient) DeleteNode(ctx context.Context, nodeID string) error

func (*NodeAPIClient) ListAllNodes

func (c *NodeAPIClient) ListAllNodes(ctx context.Context) ([]*NodeItem, error)

ListAllNodes call ListNodes() repeatedly to get all nodes in a runtime group.

func (*NodeAPIClient) ListNodes

func (c *NodeAPIClient) ListNodes(ctx context.Context, pageNumber int) (*ListNodeResponse, error)

func (*NodeAPIClient) UpdateNode

func (c *NodeAPIClient) UpdateNode(ctx context.Context, nodeID string, req *UpdateNodeRequest) (*UpdateNodeResponse, error)

type NodeAgent

type NodeAgent struct {
	Hostname string
	Version  string

	Logger logr.Logger
	// contains filtered or unexported fields
}

NodeAgent gets the running status of KIC node and controlled kong gateway nodes, and update their statuses to konnect.

func NewNodeAgent

func NewNodeAgent(
	hostname string,
	version string,
	refreshPeriod time.Duration,
	logger logr.Logger,
	client *NodeAPIClient,
	configStatusSubscriber dataplane.ConfigStatusSubscriber,
	gatewayGetter GatewayInstanceGetter,
	gatewayClientsChangesNotifier GatewayClientsChangesNotifier,
) *NodeAgent

NewNodeAgent creates a new node agent. hostname and version are hostname and version of KIC.

func (*NodeAgent) NeedLeaderElection

func (a *NodeAgent) NeedLeaderElection() bool

NeedLeaderElection implements LeaderElectionRunnable interface to ensure that the node agent is run only when the KIC instance is elected a leader.

func (*NodeAgent) Start

func (a *NodeAgent) Start(ctx context.Context) error

Start runs the process of maintaining and uploading of KIC and kong gateway nodes.

type NodeItem

type NodeItem struct {
	ID                  string               `json:"id"`
	Version             string               `json:"version"`
	Hostname            string               `json:"hostname"`
	LastPing            int64                `json:"last_ping"`
	Type                string               `json:"type"`
	CreatedAt           int64                `json:"created_at"`
	UpdatedAt           int64                `json:"updated_at"`
	ConfigHash          string               `json:"config_hash"`
	CompatibilityStatus *CompatibilityStatus `json:"compatibility_status,omitempty"`
	Status              string               `json:"status,omitempty"`
}

type PaginationInfo

type PaginationInfo struct {
	TotalCount  int32 `json:"total_count,omitempty"`
	NextPageNum int32 `json:"next_page_num,omitempty"`
}

type UpdateNodeRequest

type UpdateNodeRequest struct {
	Hostname            string               `json:"hostname"`
	Type                string               `json:"type"`
	LastPing            int64                `json:"last_ping"`
	Version             string               `json:"version"`
	ConfigHash          string               `json:"config_hash,omitempty"`
	CompatabilityStatus *CompatibilityStatus `json:"compatibility_status,omitempty"`
	Status              string               `json:"status,omitempty"`
}

type UpdateNodeResponse

type UpdateNodeResponse struct {
	Item *NodeItem `json:"item"`
}

Directories

Path Synopsis
Package runtimegroups provides primitives to interact with the openapi HTTP API.
Package runtimegroups provides primitives to interact with the openapi HTTP API.
Package runtimegroupsconfig provides primitives to interact with the openapi HTTP API.
Package runtimegroupsconfig provides primitives to interact with the openapi HTTP API.

Jump to

Keyboard shortcuts

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