kong

package
v0.47.0 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2024 License: Apache-2.0 Imports: 33 Imported by: 1

Documentation

Index

Constants

View Source
const (
	// AddonName is the unique name of the Kong cluster.Addon
	AddonName clusters.AddonName = "kong"

	// DefaultEnterpriseImageRepo default kong enterprise image
	DefaultEnterpriseImageRepo = "kong/kong-gateway"

	// DefaultEnterpriseImageTag latest kong enterprise image tag
	DefaultEnterpriseImageTag = "3.4-ubuntu"

	// DefaultEnterpriseLicenseSecretName is the name that will be used by default for the
	// Kubernetes secret containing the Kong enterprise license that will be
	// deployed when enterprise mode is enabled.
	DefaultEnterpriseLicenseSecretName = "kong-enterprise-license"

	// DefaultEnterpriseAdminPasswordSecretName is the secret name that will be used
	// by default for the Kubernetes secret that will be deployed containing the
	// superuser admin password in enterprise mode.
	DefaultEnterpriseAdminPasswordSecretName = "kong-enterprise-superuser-password"

	// DefaultAdminGUISessionConfSecretName is the secret name that will be used by
	// default for the Kbuernetes secret that will be deployed containing the
	// session configuration for the Kong Admin GUI in enterprise mode.
	DefaultAdminGUISessionConfSecretName = "kong-session-config"

	// ProxyPullSecretName is the name of the Secret used by the WithProxyImagePullSecret() builder
	ProxyPullSecretName = "proxy-pull"
)
View Source
const (
	// KongHelmRepoURL indicates the URL that will be used for pulling Kong Helm charts.
	KongHelmRepoURL = "https://charts.konghq.com"

	// DefaultDBMode indicates which dbmode for the Kong proxy should be used if no other is specified.
	DefaultDBMode = "none"

	// DefaultNamespace is the default namespace where the Kong proxy is expected to be deployed
	DefaultNamespace = "kong-system"

	// DefaultDeploymentName is the default name of the Kong proxy deployment
	DefaultDeploymentName = "ingress-controller"

	// DefaultReleaseName is the Helm release name of the Kong proxy
	DefaultReleaseName = DefaultDeploymentName + "-kong"

	// DefaultAdminServiceName indicates the name of the Service that's serving the Admin API
	DefaultAdminServiceName = DefaultReleaseName + "-admin"

	// DefaultAdminServicePort is the port on the service at which the Kong Admin API can be reached by default.
	DefaultAdminServicePort = 8001

	// DefaultProxyServiceName indicates the name of the Service that's serving the Proxy
	DefaultProxyServiceName = DefaultReleaseName + "-proxy"

	// DefaultProxyTCPServicePort is the port on the service at which the Kong proxy can be reached by default.
	DefaultProxyTCPServicePort = 80

	// DefaultProxyHTTPServicePort is the port on the service at which the Kong proxy servers HTTP traffic by default.
	DefaultProxyHTTPPort = 80

	// DefaultProxyTLSServicePort is the port on the service at which the Kong proxy can be reached by default.
	DefaultProxyTLSServicePort = 443

	// DefaultUDPServiceName provides the name of the LoadBalancer service the proxy uses for UDP traffic.
	DefaultUDPServiceName = DefaultReleaseName + "-udp-proxy"

	// DefaultUDPServicePort indicates the default open port to be found on the Kong proxy's UDP service.
	DefaultUDPServicePort = 9999

	// DefaultTCPServicePort indicates the default open port that will be used for TCP traffic.
	DefaultTCPServicePort = 8888

	// DefaultTLSServicePort indicates the default open port that will be used for TLS traffic.
	DefaultTLSServicePort = 8899

	// DefaultProxyNodePort indicates the default NodePort that will be used for
	// the proxy when applicable.
	DefaultProxyNodePort = 30080

	// DefaultAdminNodePort indicates the default NodePort that will be used for
	// the admin API when applicable.
	DefaultAdminNodePort = 32080
)
View Source
const (
	DefaultKongAddonName = "kong"
)
View Source
const LicenseDataEnvVar = "KONG_LICENSE_DATA"

LicenseDataEnvVar is the environment variable where the Kong enterprise license will be stored if available for tests.

Variables

This section is empty.

Functions

func GetLicenseJSONFromEnv added in v0.9.1

func GetLicenseJSONFromEnv() (string, error)

GetLicenseJSONFromEnv retrieves the license data from the environment and validates it, returning the resulting JSON string.

func GetLicenseSecretFromEnv added in v0.9.1

func GetLicenseSecretFromEnv() (*corev1.Secret, error)

GetLicenseSecretFromEnv retrieves the license data from the environment and validates it, returning a Kubernetes Secret object containing the license.

func GetLicenseSecretYAMLFromEnv added in v0.9.1

func GetLicenseSecretYAMLFromEnv() (string, error)

GetLicenseSecretYAMLFromEnv retrieves the license data from the environment and validates it, returning a Kubernetes Secret manifest containing the license.

Types

type Addon

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

Addon is a Kong Proxy addon which can be deployed on a clusters.Cluster.

func New

func New() *Addon

New produces a new clusters.Addon for Kong but uses a very opionated set of default configurations (see the defaults() function for more details). If you need to customize your Kong deployment, use the kong.Builder instead.

func (*Addon) Delete

func (a *Addon) Delete(ctx context.Context, cluster clusters.Cluster) error

func (*Addon) Dependencies added in v0.11.0

func (a *Addon) Dependencies(_ context.Context, cluster clusters.Cluster) []clusters.AddonName

func (*Addon) Deploy

func (a *Addon) Deploy(ctx context.Context, cluster clusters.Cluster) error

func (*Addon) DumpDiagnostics added in v0.17.0

func (a *Addon) DumpDiagnostics(ctx context.Context, cluster clusters.Cluster) (map[string][]byte, error)

func (*Addon) Name

func (a *Addon) Name() clusters.AddonName

func (*Addon) Namespace added in v0.2.0

func (a *Addon) Namespace() string

Namespace indicates the operational namespace of Kong addon components, e.g. where the controller and proxy pods live.

func (*Addon) ProxyAdminURL

func (a *Addon) ProxyAdminURL(ctx context.Context, cluster clusters.Cluster) (*url.URL, error)

ProxyAdminURL provides a routable *url.URL for accessing the Kong Admin API.

func (*Addon) ProxyHTTPSURL added in v0.46.0

func (a *Addon) ProxyHTTPSURL(ctx context.Context, cluster clusters.Cluster) (*url.URL, error)

ProxyHTTPSURL provides a routable *url.URL for accessing the Kong proxy.

func (*Addon) ProxyHTTPURL added in v0.46.0

func (a *Addon) ProxyHTTPURL(ctx context.Context, cluster clusters.Cluster) (*url.URL, error)

ProxyHTTPURL provides a routable *url.URL for accessing the Kong proxy.

func (*Addon) ProxyTCPURL added in v0.46.0

func (a *Addon) ProxyTCPURL(ctx context.Context, cluster clusters.Cluster) (string, error)

ProxyTCPURL provides a routable address for accessing the default TCP service for the Kong Proxy.

func (*Addon) ProxyTLSURL added in v0.46.0

func (a *Addon) ProxyTLSURL(ctx context.Context, cluster clusters.Cluster) (string, error)

ProxyTLSURL provides a routable address for accessing the Kong proxy over TLS.

func (*Addon) ProxyUDPURL

func (a *Addon) ProxyUDPURL(ctx context.Context, cluster clusters.Cluster) (string, error)

ProxyUDPURL provides a routable address for accessing the default UDP service for the Kong Proxy.

func (*Addon) Ready

func (a *Addon) Ready(ctx context.Context, cluster clusters.Cluster) (waitForObjects []runtime.Object, ready bool, err error)

type Builder

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

Builder is a configuration tool for Kong cluster.Addons

func NewBuilder

func NewBuilder() *Builder

NewBuilder provides a new Builder object for configuring and generating Kong Addon objects which can be deployed to cluster.Clusters

func (*Builder) Build

func (b *Builder) Build() *Addon

Build generates a new kong cluster.Addon which can be loaded and deployed into a test Environment's cluster.Cluster.

func (*Builder) WithAdditionalValue added in v0.38.0

func (b *Builder) WithAdditionalValue(name, value string) *Builder

WithAdditionalValue sets arbitrary value of installing by helm.

func (*Builder) WithAdminNodePort added in v0.41.0

func (b *Builder) WithAdminNodePort(port int) *Builder

WithAdminNodePort sets the HTTP Nodeport.

func (*Builder) WithControllerDisabled added in v0.2.0

func (b *Builder) WithControllerDisabled() *Builder

WithControllerDisabled configures the Addon in proxy only mode (bring your own control plane).

func (*Builder) WithControllerImage added in v0.15.0

func (b *Builder) WithControllerImage(repo, tag string) *Builder

WithControllerImage configures the ingress controller container image name and tag.

func (*Builder) WithDBLess

func (b *Builder) WithDBLess() *Builder

WithDBLess configures the resulting Addon to deploy a DBLESS proxy backend.

func (*Builder) WithHTTPNodePort added in v0.41.0

func (b *Builder) WithHTTPNodePort(port int) *Builder

WithHTTPNodePort sets the HTTP Nodeport.

func (*Builder) WithHelmChartVersion added in v0.36.0

func (b *Builder) WithHelmChartVersion(version string) *Builder

WithHelmChartVersion sets the helm chart version to use for the Kong proxy.

func (*Builder) WithHelmReleaseName added in v0.41.0

func (b *Builder) WithHelmReleaseName(name string) *Builder

WithHelmReleaseName sets the helm release name.

func (*Builder) WithLogLevel added in v0.17.0

func (b *Builder) WithLogLevel(level string) *Builder

WithLogLevel sets the proxy log level

func (*Builder) WithLogger added in v0.7.0

func (b *Builder) WithLogger(logger *logrus.Logger) *Builder

WithLogger adds a logger that will provide extra information about the build step of the addon at various configured log levels.

func (*Builder) WithName added in v0.41.0

func (b *Builder) WithName(name string) *Builder

WithName sets the addon name.

Note: if you want to deploy more than 1 addon of this type in a cluster, then you need to specify the name here. Without this, environment builder will silently overwrite the first addon of the same type (using the same, default name).

TODO: https://github.com/Kong/kubernetes-testing-framework/issues/846

func (*Builder) WithNamespace added in v0.35.0

func (b *Builder) WithNamespace(namespace string) *Builder

func (*Builder) WithPostgreSQL

func (b *Builder) WithPostgreSQL() *Builder

WithPostgreSQL configures the resulting Addon to deploy a PostgreSQL proxy backend.

func (*Builder) WithProxyAdminServiceTypeLoadBalancer added in v0.7.0

func (b *Builder) WithProxyAdminServiceTypeLoadBalancer() *Builder

WithProxyAdminServiceTypeLoadBalancer sets the Kong proxy's admin API's Kubernetes Service type to a "LoadBalancer" type for access outside of the cluster.

WARNING: Keep in mind that depending on your cluster provider and configuration using this option may expose your admin api endpoint to the internet.

func (*Builder) WithProxyEnterpriseEnabled added in v0.7.0

func (b *Builder) WithProxyEnterpriseEnabled(licenseJSON string) *Builder

WithProxyEnterpriseEnabled configures the resulting Addon to deploy the enterprise version of the Kong proxy. See: https://docs.konghq.com/enterprise/

func (*Builder) WithProxyEnterpriseSuperAdminPassword added in v0.7.0

func (b *Builder) WithProxyEnterpriseSuperAdminPassword(password string) *Builder

WithProxyEnterpriseSuperAdminPassword specify kong admin password

func (*Builder) WithProxyEnvVar added in v0.20.0

func (b *Builder) WithProxyEnvVar(name, value string) *Builder

WithProxyEnvVar sets an arbitrary proxy/Kong container environment variable to a string value. The name must be the lowercase kong.conf style with no KONG_ prefix.

func (*Builder) WithProxyImage added in v0.7.0

func (b *Builder) WithProxyImage(repo, tag string) *Builder

WithProxyImage configures the container image name and tag for the Kong proxy.

func (*Builder) WithProxyImagePullSecret added in v0.16.0

func (b *Builder) WithProxyImagePullSecret(server, username, password, email string) *Builder

func (*Builder) WithProxyReadinessProbePath added in v0.36.0

func (b *Builder) WithProxyReadinessProbePath(path string) *Builder

WithProxyReadinessProbePath sets the path to use for the proxy readiness probe.

func (*Builder) WithProxyServiceType added in v0.20.0

func (b *Builder) WithProxyServiceType(serviceType corev1.ServiceType) *Builder

WithProxyServiceType indicates which Service type to use for ingress traffic, including tcp proxy and udp proxy services. The default type is LoadBalancer.

type DBMode

type DBMode string

DBMode indicate which storage backend the Kong Proxy should be deployed with (e.g. DBLESS, Postgres, e.t.c.)

const (
	// DBLESS indicates that the Kong Proxy should be deployed with the DBLESS storage backend.
	DBLESS DBMode = "dbless"

	// PostgreSQL indicates that the Kong Proxy should be deployed with a PostgreSQL storage backend.
	PostgreSQL DBMode = "postgres"
)

type License added in v0.9.1

type License struct {
	Data LicenseData `json:"license"`
}

func GetLicenseFromEnv added in v0.9.1

func GetLicenseFromEnv() (*License, error)

GetLicenseFromEnv retrieves the license data from the environment and validates it, returning the resulting *License object.

type LicenseData added in v0.9.1

type LicenseData struct {
	Payload   LicensePayload `json:"payload"`
	Signature string         `json:"signature"`
	Version   string         `json:"version"`
}

type LicensePayload added in v0.9.1

type LicensePayload struct {
	AdminSeats          string `json:"admin_seats"`
	Customer            string `json:"customer"`
	DataPlanes          string `json:"dataplanes"`
	CreationDate        string `json:"license_creation_date"`
	ExpirationDate      string `json:"license_expiration_date"`
	Key                 string `json:"license_key"`
	ProductSubscription string `json:"product_subscription"`
	SupportPlan         string `json:"support_plan"`
}

Jump to

Keyboard shortcuts

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