Documentation ¶
Index ¶
- Constants
- func GetK8sVersion(client kubernetes.Interface) (v *version.Version, err error)
- func ParseNamespaceName(value string) (ns string, name string, err error)
- func ValidateEscapedString(body string, examples ...string) error
- type Configuration
- func (c *Configuration) AddOrUpdateGlobalConfiguration(gc *conf_v1.GlobalConfiguration) ([]ResourceChange, []ConfigurationProblem, error)
- func (c *Configuration) AddOrUpdateIngress(ing *networking.Ingress) ([]ResourceChange, []ConfigurationProblem)
- func (c *Configuration) AddOrUpdateTransportServer(ts *conf_v1.TransportServer) ([]ResourceChange, []ConfigurationProblem)
- func (c *Configuration) AddOrUpdateVirtualServer(vs *conf_v1.VirtualServer) ([]ResourceChange, []ConfigurationProblem)
- func (c *Configuration) AddOrUpdateVirtualServerRoute(vsr *conf_v1.VirtualServerRoute) ([]ResourceChange, []ConfigurationProblem)
- func (c *Configuration) DeleteGlobalConfiguration() ([]ResourceChange, []ConfigurationProblem)
- func (c *Configuration) DeleteIngress(key string) ([]ResourceChange, []ConfigurationProblem)
- func (c *Configuration) DeleteTransportServer(key string) ([]ResourceChange, []ConfigurationProblem)
- func (c *Configuration) DeleteVirtualServer(key string) ([]ResourceChange, []ConfigurationProblem)
- func (c *Configuration) DeleteVirtualServerRoute(key string) ([]ResourceChange, []ConfigurationProblem)
- func (c *Configuration) FindResourcesForAppProtectDosProtected(namespace string, name string) []Resource
- func (c *Configuration) FindResourcesForAppProtectLogConfAnnotation(logConfNamespace string, logConfName string) []Resource
- func (c *Configuration) FindResourcesForAppProtectPolicyAnnotation(policyNamespace string, policyName string) []Resource
- func (c *Configuration) FindResourcesForEndpoints(endpointsNamespace string, endpointsName string) []Resource
- func (c *Configuration) FindResourcesForPolicy(policyNamespace string, policyName string) []Resource
- func (c *Configuration) FindResourcesForSecret(secretNamespace string, secretName string) []Resource
- func (c *Configuration) FindResourcesForService(svcNamespace string, svcName string) []Resource
- func (c *Configuration) GetGlobalConfiguration() *conf_v1.GlobalConfiguration
- func (c *Configuration) GetResources() []Resource
- func (c *Configuration) GetResourcesWithFilter(filter resourceFilter) []Resource
- func (c *Configuration) GetTransportServerMetrics() *TransportServerMetrics
- type ConfigurationProblem
- type IngressConfiguration
- func (ic *IngressConfiguration) AddWarning(warning string)
- func (ic *IngressConfiguration) GetKeyWithKind() string
- func (ic *IngressConfiguration) GetObjectMeta() *metav1.ObjectMeta
- func (ic *IngressConfiguration) IsEqual(resource Resource) bool
- func (ic *IngressConfiguration) Wins(resource Resource) bool
- type LoadBalancerController
- func (lbc *LoadBalancerController) AddSyncQueue(item interface{})
- func (lbc *LoadBalancerController) HasCorrectIngressClass(obj interface{}) bool
- func (lbc *LoadBalancerController) IsExternalServiceForStatus(svc *api_v1.Service) bool
- func (lbc *LoadBalancerController) IsExternalServiceKeyForStatus(key string) bool
- func (lbc *LoadBalancerController) IsNginxReady() bool
- func (lbc *LoadBalancerController) Run()
- func (lbc *LoadBalancerController) Stop()
- func (lbc *LoadBalancerController) UpdateIngressStatusAndEventsOnDelete(ingConfig *IngressConfiguration, changeError string, deleteErr error)
- func (lbc *LoadBalancerController) UpdateVirtualServerStatusAndEventsOnDelete(vsConfig *VirtualServerConfiguration, changeError string, deleteErr error)
- type MinionConfiguration
- type NewLoadBalancerControllerInput
- type Operation
- type Resource
- type ResourceChange
- type TransportServerConfiguration
- func (tsc *TransportServerConfiguration) AddWarning(warning string)
- func (tsc *TransportServerConfiguration) GetKeyWithKind() string
- func (tsc *TransportServerConfiguration) GetObjectMeta() *metav1.ObjectMeta
- func (tsc *TransportServerConfiguration) IsEqual(resource Resource) bool
- func (tsc *TransportServerConfiguration) Wins(resource Resource) bool
- type TransportServerMetrics
- type VirtualServerConfiguration
- func (vsc *VirtualServerConfiguration) AddWarning(warning string)
- func (vsc *VirtualServerConfiguration) GetKeyWithKind() string
- func (vsc *VirtualServerConfiguration) GetObjectMeta() *metav1.ObjectMeta
- func (vsc *VirtualServerConfiguration) IsEqual(resource Resource) bool
- func (vsc *VirtualServerConfiguration) Wins(resource Resource) bool
Constants ¶
const (
// IngressControllerName holds Ingress Controller name
IngressControllerName = "nginx.org/ingress-controller"
)
Variables ¶
This section is empty.
Functions ¶
func GetK8sVersion ¶
func GetK8sVersion(client kubernetes.Interface) (v *version.Version, err error)
GetK8sVersion returns the running version of k8s
func ParseNamespaceName ¶
ParseNamespaceName parses the string in the <namespace>/<name> format and returns the name and the namespace. It returns an error in case the string does not follow the <namespace>/<name> format.
func ValidateEscapedString ¶
ValidateEscapedString validates an escaped string.
Types ¶
type Configuration ¶
type Configuration struct {
// contains filtered or unexported fields
}
Configuration represents the configuration of the Ingress Controller - a collection of configuration objects (Ingresses, VirtualServers, VirtualServerRoutes) ready to be transformed into NGINX config. It holds the latest valid state of those objects. The IC needs to ensure that at any point in time the NGINX config on the filesystem reflects the state of the objects in the Configuration.
func NewConfiguration ¶
func NewConfiguration( hasCorrectIngressClass func(interface{}) bool, isPlus bool, appProtectEnabled bool, appProtectDosEnabled bool, internalRoutesEnabled bool, virtualServerValidator *validation.VirtualServerValidator, globalConfigurationValidator *validation.GlobalConfigurationValidator, transportServerValidator *validation.TransportServerValidator, isTLSPassthroughEnabled bool, snippetsEnabled bool, isCertManagerEnabled bool, isIPV6Disabled bool, ) *Configuration
NewConfiguration creates a new Configuration.
func (*Configuration) AddOrUpdateGlobalConfiguration ¶
func (c *Configuration) AddOrUpdateGlobalConfiguration(gc *conf_v1.GlobalConfiguration) ([]ResourceChange, []ConfigurationProblem, error)
AddOrUpdateGlobalConfiguration adds or updates the GlobalConfiguration.
func (*Configuration) AddOrUpdateIngress ¶
func (c *Configuration) AddOrUpdateIngress(ing *networking.Ingress) ([]ResourceChange, []ConfigurationProblem)
AddOrUpdateIngress adds or updates the Ingress resource.
func (*Configuration) AddOrUpdateTransportServer ¶
func (c *Configuration) AddOrUpdateTransportServer(ts *conf_v1.TransportServer) ([]ResourceChange, []ConfigurationProblem)
AddOrUpdateTransportServer adds or updates the TransportServer.
func (*Configuration) AddOrUpdateVirtualServer ¶
func (c *Configuration) AddOrUpdateVirtualServer(vs *conf_v1.VirtualServer) ([]ResourceChange, []ConfigurationProblem)
AddOrUpdateVirtualServer adds or updates the VirtualServer resource.
func (*Configuration) AddOrUpdateVirtualServerRoute ¶
func (c *Configuration) AddOrUpdateVirtualServerRoute(vsr *conf_v1.VirtualServerRoute) ([]ResourceChange, []ConfigurationProblem)
AddOrUpdateVirtualServerRoute adds or updates the VirtualServerRoute.
func (*Configuration) DeleteGlobalConfiguration ¶
func (c *Configuration) DeleteGlobalConfiguration() ([]ResourceChange, []ConfigurationProblem)
DeleteGlobalConfiguration deletes GlobalConfiguration.
func (*Configuration) DeleteIngress ¶
func (c *Configuration) DeleteIngress(key string) ([]ResourceChange, []ConfigurationProblem)
DeleteIngress deletes an Ingress resource by the key.
func (*Configuration) DeleteTransportServer ¶
func (c *Configuration) DeleteTransportServer(key string) ([]ResourceChange, []ConfigurationProblem)
DeleteTransportServer deletes a TransportServer by the key.
func (*Configuration) DeleteVirtualServer ¶
func (c *Configuration) DeleteVirtualServer(key string) ([]ResourceChange, []ConfigurationProblem)
DeleteVirtualServer deletes a VirtualServerResource by the key.
func (*Configuration) DeleteVirtualServerRoute ¶
func (c *Configuration) DeleteVirtualServerRoute(key string) ([]ResourceChange, []ConfigurationProblem)
DeleteVirtualServerRoute deletes a VirtualServerRoute by the key.
func (*Configuration) FindResourcesForAppProtectDosProtected ¶
func (c *Configuration) FindResourcesForAppProtectDosProtected(namespace string, name string) []Resource
FindResourcesForAppProtectDosProtected finds resources that reference the specified AppProtectDos DosLogConf.
func (*Configuration) FindResourcesForAppProtectLogConfAnnotation ¶
func (c *Configuration) FindResourcesForAppProtectLogConfAnnotation(logConfNamespace string, logConfName string) []Resource
FindResourcesForAppProtectLogConfAnnotation finds resources that reference the specified AppProtect LogConf.
func (*Configuration) FindResourcesForAppProtectPolicyAnnotation ¶
func (c *Configuration) FindResourcesForAppProtectPolicyAnnotation(policyNamespace string, policyName string) []Resource
FindResourcesForAppProtectPolicyAnnotation finds resources that reference the specified AppProtect policy via annotation.
func (*Configuration) FindResourcesForEndpoints ¶
func (c *Configuration) FindResourcesForEndpoints(endpointsNamespace string, endpointsName string) []Resource
FindResourcesForEndpoints finds resources that reference the specified endpoints.
func (*Configuration) FindResourcesForPolicy ¶
func (c *Configuration) FindResourcesForPolicy(policyNamespace string, policyName string) []Resource
FindResourcesForPolicy finds resources that reference the specified policy.
func (*Configuration) FindResourcesForSecret ¶
func (c *Configuration) FindResourcesForSecret(secretNamespace string, secretName string) []Resource
FindResourcesForSecret finds resources that reference the specified secret.
func (*Configuration) FindResourcesForService ¶
func (c *Configuration) FindResourcesForService(svcNamespace string, svcName string) []Resource
FindResourcesForService finds resources that reference the specified service.
func (*Configuration) GetGlobalConfiguration ¶
func (c *Configuration) GetGlobalConfiguration() *conf_v1.GlobalConfiguration
GetGlobalConfiguration returns the current GlobalConfiguration.
func (*Configuration) GetResources ¶
func (c *Configuration) GetResources() []Resource
GetResources returns all configuration resources.
func (*Configuration) GetResourcesWithFilter ¶
func (c *Configuration) GetResourcesWithFilter(filter resourceFilter) []Resource
GetResourcesWithFilter returns resources using the filter.
func (*Configuration) GetTransportServerMetrics ¶
func (c *Configuration) GetTransportServerMetrics() *TransportServerMetrics
GetTransportServerMetrics returns metrics about TransportServers
type ConfigurationProblem ¶
type ConfigurationProblem struct { // Object is a configuration object. Object runtime.Object // IsError tells if the problem is an error. If it is an error, then it is expected that the status of the object // will be updated to the state 'invalid'. Otherwise, the state will be 'warning'. IsError bool // Reason tells the reason. It matches the reason in the events/status of our configuration objects. Reason string // Messages gives the details about the problem. It matches the message in the events/status of our configuration objects. Message string }
ConfigurationProblem is a problem associated with a configuration object.
type IngressConfiguration ¶
type IngressConfiguration struct { // Ingress holds a regular Ingress or a master Ingress. Ingress *networking.Ingress // IsMaster is true when the Ingress is a master. IsMaster bool // Minions contains minions if the Ingress is a master. Minions []*MinionConfiguration // ValidHosts marks the hosts of the Ingress as valid (true) or invalid (false). // Regular Ingress resources can have multiple hosts. It is possible that some of the hosts are taken by other // resources. In that case, those hosts will be marked as invalid. ValidHosts map[string]bool // Warnings includes all the warnings for the resource. Warnings []string // ChildWarnings includes the warnings of the minions. The key is the namespace/name. ChildWarnings map[string][]string }
IngressConfiguration holds an Ingress resource with its minions. It implements the Resource interface.
func NewMasterIngressConfiguration ¶
func NewMasterIngressConfiguration(ing *networking.Ingress, minions []*MinionConfiguration, childWarnings map[string][]string) *IngressConfiguration
NewMasterIngressConfiguration creates an IngressConfiguration from a master Ingress resource.
func NewRegularIngressConfiguration ¶
func NewRegularIngressConfiguration(ing *networking.Ingress) *IngressConfiguration
NewRegularIngressConfiguration creates an IngressConfiguration from an Ingress resource.
func (*IngressConfiguration) AddWarning ¶
func (ic *IngressConfiguration) AddWarning(warning string)
AddWarning adds a warning.
func (*IngressConfiguration) GetKeyWithKind ¶
func (ic *IngressConfiguration) GetKeyWithKind() string
GetKeyWithKind returns the key of the resource with its kind. For example, Ingress/my-namespace/my-name.
func (*IngressConfiguration) GetObjectMeta ¶
func (ic *IngressConfiguration) GetObjectMeta() *metav1.ObjectMeta
GetObjectMeta returns the resource ObjectMeta.
func (*IngressConfiguration) IsEqual ¶
func (ic *IngressConfiguration) IsEqual(resource Resource) bool
IsEqual tests if the IngressConfiguration is equal to the resource.
func (*IngressConfiguration) Wins ¶
func (ic *IngressConfiguration) Wins(resource Resource) bool
Wins tells if this resource wins over the specified resource.
type LoadBalancerController ¶
type LoadBalancerController struct {
// contains filtered or unexported fields
}
LoadBalancerController watches Kubernetes API and reconfigures NGINX via NginxController when needed
func NewLoadBalancerController ¶
func NewLoadBalancerController(input NewLoadBalancerControllerInput) *LoadBalancerController
NewLoadBalancerController creates a controller
func (*LoadBalancerController) AddSyncQueue ¶
func (lbc *LoadBalancerController) AddSyncQueue(item interface{})
AddSyncQueue enqueues the provided item on the sync queue
func (*LoadBalancerController) HasCorrectIngressClass ¶
func (lbc *LoadBalancerController) HasCorrectIngressClass(obj interface{}) bool
HasCorrectIngressClass checks if resource ingress class annotation (if exists) or ingressClass string for VS/VSR is matching with Ingress Controller class
func (*LoadBalancerController) IsExternalServiceForStatus ¶
func (lbc *LoadBalancerController) IsExternalServiceForStatus(svc *api_v1.Service) bool
IsExternalServiceForStatus matches the service specified by the external-service cli arg
func (*LoadBalancerController) IsExternalServiceKeyForStatus ¶
func (lbc *LoadBalancerController) IsExternalServiceKeyForStatus(key string) bool
IsExternalServiceKeyForStatus matches the service key specified by the external-service cli arg
func (*LoadBalancerController) IsNginxReady ¶
func (lbc *LoadBalancerController) IsNginxReady() bool
IsNginxReady returns ready status of NGINX
func (*LoadBalancerController) Run ¶
func (lbc *LoadBalancerController) Run()
Run starts the loadbalancer controller
func (*LoadBalancerController) Stop ¶
func (lbc *LoadBalancerController) Stop()
Stop shutsdown the load balancer controller
func (*LoadBalancerController) UpdateIngressStatusAndEventsOnDelete ¶
func (lbc *LoadBalancerController) UpdateIngressStatusAndEventsOnDelete(ingConfig *IngressConfiguration, changeError string, deleteErr error)
UpdateIngressStatusAndEventsOnDelete updates the ingress status and events.
func (*LoadBalancerController) UpdateVirtualServerStatusAndEventsOnDelete ¶
func (lbc *LoadBalancerController) UpdateVirtualServerStatusAndEventsOnDelete(vsConfig *VirtualServerConfiguration, changeError string, deleteErr error)
UpdateVirtualServerStatusAndEventsOnDelete updates the virtual server status and events
type MinionConfiguration ¶
type MinionConfiguration struct { // Ingress is the Ingress behind a minion. Ingress *networking.Ingress // ValidPaths marks the paths of the Ingress as valid (true) or invalid (false). // Minion Ingress resources can have multiple paths. It is possible that some of the paths are taken by other // Minions. In that case, those paths will be marked as invalid. ValidPaths map[string]bool }
MinionConfiguration holds a Minion resource.
func NewMinionConfiguration ¶
func NewMinionConfiguration(ing *networking.Ingress) *MinionConfiguration
NewMinionConfiguration creates a new MinionConfiguration.
type NewLoadBalancerControllerInput ¶
type NewLoadBalancerControllerInput struct { KubeClient kubernetes.Interface ConfClient k8s_nginx.Interface DynClient dynamic.Interface RestConfig *rest.Config ResyncPeriod time.Duration Namespace []string SecretNamespace []string NginxConfigurator *configs.Configurator DefaultServerSecret string AppProtectEnabled bool AppProtectDosEnabled bool IsNginxPlus bool IngressClass string ExternalServiceName string IngressLink string ControllerNamespace string ReportIngressStatus bool IsLeaderElectionEnabled bool LeaderElectionLockName string WildcardTLSSecret string ConfigMaps string GlobalConfiguration string AreCustomResourcesEnabled bool EnableOIDC bool MetricsCollector collectors.ControllerCollector GlobalConfigurationValidator *validation.GlobalConfigurationValidator TransportServerValidator *validation.TransportServerValidator VirtualServerValidator *validation.VirtualServerValidator SpireAgentAddress string InternalRoutesEnabled bool IsPrometheusEnabled bool IsLatencyMetricsEnabled bool IsTLSPassthroughEnabled bool TLSPassthroughPort int SnippetsEnabled bool CertManagerEnabled bool ExternalDNSEnabled bool IsIPV6Disabled bool WatchNamespaceLabel string }
NewLoadBalancerControllerInput holds the input needed to call NewLoadBalancerController.
type Resource ¶
type Resource interface { GetObjectMeta() *metav1.ObjectMeta GetKeyWithKind() string Wins(resource Resource) bool AddWarning(warning string) IsEqual(resource Resource) bool }
Resource represents a configuration resource. A Resource can be a top level configuration object: - Regular or Master Ingress - VirtualServer - TransportServer
type ResourceChange ¶
type ResourceChange struct { // Op is an operation that needs be performed on the resource. Op Operation // Resource is the target resource. Resource Resource // Error is the error associated with the resource. Error string }
ResourceChange represents a change of the resource that needs to be reflected in the NGINX config.
type TransportServerConfiguration ¶
type TransportServerConfiguration struct { ListenerPort int TransportServer *conf_v1.TransportServer Warnings []string }
TransportServerConfiguration holds a TransportServer resource.
func NewTransportServerConfiguration ¶
func NewTransportServerConfiguration(ts *conf_v1.TransportServer) *TransportServerConfiguration
NewTransportServerConfiguration creates a new TransportServerConfiguration.
func (*TransportServerConfiguration) AddWarning ¶
func (tsc *TransportServerConfiguration) AddWarning(warning string)
AddWarning adds a warning.
func (*TransportServerConfiguration) GetKeyWithKind ¶
func (tsc *TransportServerConfiguration) GetKeyWithKind() string
GetKeyWithKind returns the key of the resource with its kind. For example, TransportServer/my-namespace/my-name.
func (*TransportServerConfiguration) GetObjectMeta ¶
func (tsc *TransportServerConfiguration) GetObjectMeta() *metav1.ObjectMeta
GetObjectMeta returns the resource ObjectMeta.
func (*TransportServerConfiguration) IsEqual ¶
func (tsc *TransportServerConfiguration) IsEqual(resource Resource) bool
IsEqual tests if the TransportServerConfiguration is equal to the resource.
func (*TransportServerConfiguration) Wins ¶
func (tsc *TransportServerConfiguration) Wins(resource Resource) bool
Wins tells if this resource wins over the specified resource. It is used to determine which resource should win over a host or port.
type TransportServerMetrics ¶
TransportServerMetrics holds metrics about TransportServer resources
type VirtualServerConfiguration ¶
type VirtualServerConfiguration struct { VirtualServer *conf_v1.VirtualServer VirtualServerRoutes []*conf_v1.VirtualServerRoute Warnings []string HTTPPort int HTTPSPort int }
VirtualServerConfiguration holds a VirtualServer along with its VirtualServerRoutes.
func NewVirtualServerConfiguration ¶
func NewVirtualServerConfiguration(vs *conf_v1.VirtualServer, vsrs []*conf_v1.VirtualServerRoute, warnings []string) *VirtualServerConfiguration
NewVirtualServerConfiguration creates a VirtualServerConfiguration.
func (*VirtualServerConfiguration) AddWarning ¶
func (vsc *VirtualServerConfiguration) AddWarning(warning string)
AddWarning adds a warning.
func (*VirtualServerConfiguration) GetKeyWithKind ¶
func (vsc *VirtualServerConfiguration) GetKeyWithKind() string
GetKeyWithKind returns the key of the resource with its kind. For example, VirtualServer/my-namespace/my-name.
func (*VirtualServerConfiguration) GetObjectMeta ¶
func (vsc *VirtualServerConfiguration) GetObjectMeta() *metav1.ObjectMeta
GetObjectMeta returns the resource ObjectMeta.
func (*VirtualServerConfiguration) IsEqual ¶
func (vsc *VirtualServerConfiguration) IsEqual(resource Resource) bool
IsEqual tests if the VirtualServerConfiguration is equal to the resource.
func (*VirtualServerConfiguration) Wins ¶
func (vsc *VirtualServerConfiguration) Wins(resource Resource) bool
Wins tells if this resource wins over the specified resource. It is used to determine which resource should win over a host.