Documentation ¶
Index ¶
- Constants
- func GetKongVersion() semver.Version
- func GetNodeIPOrName(ctx context.Context, kubeClient clientset.Interface, name string) string
- func IsValidPort(port int) bool
- func MakeDebugLoggerWithReducedRedudancy(writer io.Writer, formatter logrus.Formatter, ...) *logrus.Logger
- func MakeLogger(level string, formatter string) (logrus.FieldLogger, error)
- func ParseNameNS(input string) (string, string, error)
- func ServerHasGVK(client discovery.ServerResourcesInterface, groupVersion, kind string) (bool, error)
- func SetKongVersion(version semver.Version)
- func ValidateProtocol(protocol string) bool
- type ConfigDump
- type ConfigDumpDiagnostic
- type ConfigDumpMode
- type Endpoint
- type ForeignRelations
- type Info
- type IngressAPI
- type K8sObjectInfo
- type PluginSchemaStore
- type PodInfo
- type RawSSLCert
- type Rel
- type Reporter
- type SecretGetterFromK8s
Constants ¶
const ( // InfoLevel is the converted logging level from logrus to go-logr for // information level logging. Note that the logrusr middleware technically // flattens all levels prior to this level into this level as well. InfoLevel = int(logrus.InfoLevel) - logrusrDiff // DebugLevel is the converted logging level from logrus to go-logr for // debug level logging. DebugLevel = int(logrus.DebugLevel) - logrusrDiff // WarnLevel is the converted logrus level to go-logr for warnings WarnLevel = int(logrus.WarnLevel) - logrusrDiff )
we currently implement two different loggers and use a middleware called logrusr to translate logrus loggers into go-logrs (used by controller-runtime). The middleware currently squashes loglevels 0-4 together and effectively starts the "info" level logging at 0 (whereas logrus starts that at 4 (range from 0)). Since the middleware at the time of writing made all of this part of the private implementation these options are used for convenience until a time when we unify our logging implementations into one or the other.
See: https://github.com/Kong/kubernetes-ingress-controller/issues/1893
Variables ¶
This section is empty.
Functions ¶
func GetKongVersion ¶ added in v2.3.0
func GetKongVersion() semver.Version
GetKongVersion retrieves the Kong version. If the version is not set, it returns the lowest possible version
func GetNodeIPOrName ¶
GetNodeIPOrName returns the IP address or the name of a node in the cluster
func IsValidPort ¶
IsValidPort is a convenience function to validate whether or not a given integer is a valid networking port number.
func MakeDebugLoggerWithReducedRedudancy ¶
func MakeDebugLoggerWithReducedRedudancy(writer io.Writer, formatter logrus.Formatter, redudantLogEntryAllowedConsecutively int, redundantLogEntryBackoff time.Duration, ) *logrus.Logger
MakeDebugLoggerWithReducedRedudancy is a logrus.Logger that "stifles" repetitive logs.
The "stifling" mechanism is triggered by one of two conditions the result of which is that the "stifled" log entry will be dropped entirely.
The conditions checked are:
This logger will drop log entries where an identical log entry has posted within the last "redundantLogEntryBackoff". For example, you could set this to "time.Second * 3" and the result would be that if the logger had already logged an identical message within the previous 3 seconds it will be dropped.
This logger will "stifle" redudant entries which are logged consecutively a number of times equal to the provided "redudantLogEntryAllowedConsecutively" number. For example, you could set this to 3 and then if the last 3 log entries emitted were the same message further entries of the same message would be dropped.
The caller can choose to set either argument to "0" to disable that check, but setting both to zero will result in no redundancy reduction.
NOTE: Please consider this logger a "debug" only logging implementation.
This logger was originally created to help reduce the noise coming from the controller during integration tests for better human readability, so keep in mind it was built for testing environments if you're currently reading this and you're considering using it somewhere that would produce production environment logs: there's significant performance overhead triggered by the logging hooks this adds.
func MakeLogger ¶
func MakeLogger(level string, formatter string) (logrus.FieldLogger, error)
func ParseNameNS ¶
ParseNameNS parses a string searching a namespace and name
func ServerHasGVK ¶
func ServerHasGVK(client discovery.ServerResourcesInterface, groupVersion, kind string) (bool, error)
ServerHasGVK returns true iff the Kubernetes API server supports the given resource kind at the given group-version.
func SetKongVersion ¶ added in v2.3.0
func SetKongVersion(version semver.Version)
SetKongVersion sets the Kong version. It can only be used once. Repeated calls will not update the Kong version
func ValidateProtocol ¶
ValidateProtocol returns a bool of whether string is a valid protocol
Types ¶
type ConfigDump ¶
ConfigDump contains a config dump and a flag indicating that the config was not successfully applid
type ConfigDumpDiagnostic ¶
type ConfigDumpDiagnostic struct { DumpsIncludeSensitive bool Configs chan ConfigDump }
ConfigDumpDiagnostic contains settings and channels for receiving diagnostic configuration dumps
type ConfigDumpMode ¶
type ConfigDumpMode int
const ( ConfigDumpModeOff ConfigDumpMode = iota ConfigDumpModeEnabled ConfigDumpMode = iota ConfigDumpModeSensitive ConfigDumpMode = iota )
func ParseConfigDumpMode ¶
func ParseConfigDumpMode(in string) (ConfigDumpMode, error)
type Endpoint ¶
type Endpoint struct { // Address IP address of the endpoint Address string `json:"address"` // Port number of the TCP port Port string `json:"port"` }
Endpoint describes a kubernetes endpoint, same as a target in Kong.
type ForeignRelations ¶
type ForeignRelations struct {
Consumer, Route, Service []string
}
func (*ForeignRelations) GetCombinations ¶
func (relations *ForeignRelations) GetCombinations() []Rel
type Info ¶
type Info struct { KubernetesVersion string KongVersion string KICVersion string Hostname string KongDB string ID string FeatureGates map[string]bool }
Info holds the metadata to be sent as part of a report.
type IngressAPI ¶
type IngressAPI int
const ( OtherAPI IngressAPI = iota NetworkingV1 IngressAPI = iota NetworkingV1beta1 IngressAPI = iota ExtensionsV1beta1 IngressAPI = iota )
func NegotiateResourceAPI ¶
func NegotiateResourceAPI(client discovery.ServerResourcesInterface, kind string, allowedVersions []IngressAPI, ) (IngressAPI, error)
func (IngressAPI) String ¶
func (ia IngressAPI) String() string
type K8sObjectInfo ¶
type K8sObjectInfo struct { Name string Namespace string Annotations map[string]string GroupVersionKind schema.GroupVersionKind }
K8sObjectInfo describes a Kubernetes object.
func FromK8sObject ¶
func FromK8sObject(obj client.Object) K8sObjectInfo
type PluginSchemaStore ¶
type PluginSchemaStore struct {
// contains filtered or unexported fields
}
PluginSchemaStore retrives a schema of a Plugin from Kong.
func NewPluginSchemaStore ¶
func NewPluginSchemaStore(client *kong.Client) *PluginSchemaStore
NewPluginSchemaStore creates a PluginSchemaStore.
type PodInfo ¶
type PodInfo struct { Name string Namespace string NodeIP string // Labels selectors of the running pod // This is used to search for other Ingress controller pods Labels map[string]string }
PodInfo contains runtime information about the pod running the Ingres controller
type RawSSLCert ¶
RawSSLCert represnts TLS cert and key in bytes
type Reporter ¶
type Reporter struct { Info Info Logger logrus.FieldLogger // contains filtered or unexported fields }
Reporter sends anonymous reports of runtime properties and errors in Kong.
type SecretGetterFromK8s ¶
SecretGetterFromK8s is a SecretGetter that reads secrets from Kubernetes API.