Documentation ¶
Overview ¶
Copyright 2021 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Index ¶
- Constants
- Variables
- func Equal(fr1, fr2 *composite.ForwardingRule) (bool, error)
- func GCEResourceName(ingAnnotations map[string]string, resourceName string) string
- func GetLBAnnotations(l7 *L7, existing map[string]string, backendSyncer backends.Syncer) (map[string]string, error)
- func InsertForwardingRuleHook(ctx context.Context, key *meta.Key, obj *compute.ForwardingRule, ...) (b bool, e error)
- func InsertGlobalForwardingRuleHook(ctx context.Context, key *meta.Key, obj *compute.ForwardingRule, ...) (b bool, e error)
- type IPAddressType
- type L4
- func (l *L4) CreateKey(name string) (*meta.Key, error)
- func (l *L4) EnsureInternalLoadBalancer(nodeNames []string, svc *corev1.Service) *L4ILBSyncResult
- func (l *L4) EnsureInternalLoadBalancerDeleted(svc *corev1.Service) *L4ILBSyncResult
- func (l *L4) GetFRName() string
- func (l *L4) GetForwardingRule(name string, version meta.Version) *composite.ForwardingRule
- type L4ILBSyncResult
- type L4NetLB
- func (l4netlb *L4NetLB) EnsureFrontend(nodeNames []string, svc *corev1.Service) *L4NetLBSyncResult
- func (l4netlb *L4NetLB) EnsureLoadBalancerDeleted(svc *corev1.Service) *L4NetLBSyncResult
- func (l4netlb *L4NetLB) GetFRName() string
- func (l4netlb *L4NetLB) GetForwardingRule(name string, version meta.Version) *composite.ForwardingRule
- type L4NetLBSyncResult
- type L7
- func (l *L7) Cleanup(versions *features.ResourceVersions) error
- func (l *L7) CreateKey(name string) (*meta.Key, error)
- func (l *L7) GetIP() string
- func (l *L7) Regional() bool
- func (l *L7) RuntimeInfo() *L7RuntimeInfo
- func (l *L7) String() string
- func (l *L7) UrlMap() *composite.UrlMap
- func (l *L7) Versions() *features.ResourceVersions
- type L7RuntimeInfo
- type L7s
- func (l *L7s) Ensure(ri *L7RuntimeInfo) (*L7, error)
- func (l *L7s) FrontendScopeChangeGC(ing *v1.Ingress) (*meta.KeyType, error)
- func (l *L7s) GCv1(names []string) error
- func (l *L7s) GCv2(ing *v1.Ingress, scope meta.KeyType) error
- func (l *L7s) HasUrlMap(ing *v1.Ingress) (bool, error)
- func (l *L7s) Shutdown(ings []*v1.Ingress) error
- type LoadBalancerPool
Constants ¶
const ( SyncTypeCreate = "create" SyncTypeUpdate = "update" SyncTypeDelete = "delete" )
const FakeCertQuota = 15
const SslCertificateMissing = "SslCertificateMissing"
const (
// Every target https proxy accepts upto 10 ssl certificates.
TargetProxyCertLimit = 10
)
Variables ¶
var L4LBResourceAnnotationKeys = []string{ annotations.BackendServiceKey, annotations.TCPForwardingRuleKey, annotations.UDPForwardingRuleKey, annotations.HealthcheckKey, annotations.FirewallRuleKey, annotations.FirewallRuleForHealthcheckKey, }
var L4RBSAnnotations = append(L4LBResourceAnnotationKeys, annotations.RBSAnnotationKey)
Functions ¶
func GCEResourceName ¶
GCEResourceName retrieves the name of the gce resource created for this Ingress, of the given resource type, by inspecting the map of ingress annotations.
func GetLBAnnotations ¶
func GetLBAnnotations(l7 *L7, existing map[string]string, backendSyncer backends.Syncer) (map[string]string, error)
GetLBAnnotations returns the annotations of an l7. This includes it's current status.
func InsertForwardingRuleHook ¶ added in v1.9.0
func InsertGlobalForwardingRuleHook ¶ added in v1.7.0
Types ¶
type IPAddressType ¶ added in v1.16.0
type IPAddressType int
IPAddressType defines if IP address is Managed by controller
const ( IPAddrUndefined IPAddressType = iota // IP Address type could not be determine due to error is address provisioning. IPAddrManaged IPAddrUnmanaged )
type L4 ¶ added in v1.9.0
type L4 struct { Service *corev1.Service ServicePort utils.ServicePort NamespacedName types.NamespacedName // contains filtered or unexported fields }
Many of the functions in this file are re-implemented from gce_loadbalancer_internal.go L4 handles the resource creation/deletion/update for a given L4 ILB service.
func NewL4Handler ¶ added in v1.9.0
func NewL4Handler(service *corev1.Service, cloud *gce.Cloud, scope meta.KeyType, namer namer.L4ResourcesNamer, recorder record.EventRecorder) *L4
NewL4Handler creates a new L4Handler for the given L4 service.
func (*L4) CreateKey ¶ added in v1.9.0
CreateKey generates a meta.Key for a given GCE resource name.
func (*L4) EnsureInternalLoadBalancer ¶ added in v1.9.0
func (l *L4) EnsureInternalLoadBalancer(nodeNames []string, svc *corev1.Service) *L4ILBSyncResult
EnsureInternalLoadBalancer ensures that all GCE resources for the given loadbalancer service have been created. It returns a LoadBalancerStatus with the updated ForwardingRule IP address.
func (*L4) EnsureInternalLoadBalancerDeleted ¶ added in v1.9.0
func (l *L4) EnsureInternalLoadBalancerDeleted(svc *corev1.Service) *L4ILBSyncResult
EnsureInternalLoadBalancerDeleted performs a cleanup of all GCE resources for the given loadbalancer service.
func (*L4) GetFRName ¶ added in v1.9.0
GetFRName returns the name of the forwarding rule for the given ILB service. This appends the protocol to the forwarding rule name, which will help supporting multiple protocols in the same ILB service.
func (*L4) GetForwardingRule ¶ added in v1.11.7
type L4ILBSyncResult ¶ added in v1.16.0
type L4ILBSyncResult struct { Annotations map[string]string Error error GCEResourceInError string Status *corev1.LoadBalancerStatus MetricsState metrics.L4ILBServiceState SyncType string StartTime time.Time }
L4ILBSyncResult contains information about the outcome of an L4 ILB sync. It stores the list of resource name annotations, sync error, the GCE resource that hit the error along with the error type, metrics and more fields.
type L4NetLB ¶ added in v1.15.0
type L4NetLB struct { Service *corev1.Service ServicePort utils.ServicePort NamespacedName types.NamespacedName // contains filtered or unexported fields }
L4NetLB handles the resource creation/deletion/update for a given L4 External LoadBalancer service.
func NewL4NetLB ¶ added in v1.15.0
func NewL4NetLB(service *corev1.Service, cloud *gce.Cloud, scope meta.KeyType, namer namer.L4ResourcesNamer, recorder record.EventRecorder) *L4NetLB
NewL4NetLB creates a new Handler for the given L4NetLB service.
func (*L4NetLB) EnsureFrontend ¶ added in v1.15.0
func (l4netlb *L4NetLB) EnsureFrontend(nodeNames []string, svc *corev1.Service) *L4NetLBSyncResult
EnsureFrontend ensures that all frontend resources for the given loadbalancer service have been created. It is health check, firewall rules, backend service and forwarding rule. It returns a LoadBalancerStatus with the updated ForwardingRule IP address. This function does not link instances to Backend Service.
func (*L4NetLB) EnsureLoadBalancerDeleted ¶ added in v1.15.0
func (l4netlb *L4NetLB) EnsureLoadBalancerDeleted(svc *corev1.Service) *L4NetLBSyncResult
EnsureLoadBalancerDeleted performs a cleanup of all GCE resources for the given loadbalancer service. It is health check, firewall rules and backend service
func (*L4NetLB) GetFRName ¶ added in v1.15.0
GetFRName returns the name of the forwarding rule for the given L4 External LoadBalancer service. This name should align with legacy forwarding rule name because we use forwarding rule to determine which controller should process the service Ingress-GCE or k/k service controller.
func (*L4NetLB) GetForwardingRule ¶ added in v1.15.0
type L4NetLBSyncResult ¶ added in v1.16.0
type L4NetLBSyncResult struct { Annotations map[string]string Error error GCEResourceInError string Status *corev1.LoadBalancerStatus MetricsState metrics.L4NetLBServiceState SyncType string StartTime time.Time }
L4NetLBSyncResult contains information about the outcome of an L4 NetLB sync. It stores the list of resource name annotations, sync error, the GCE resource that hit the error along with the error type, metrics and more fields.
func NewL4SynResult ¶ added in v1.17.1
func NewL4SynResult(syncType string) *L4NetLBSyncResult
func (*L4NetLBSyncResult) SetMetricsForSuccessfulServiceSync ¶ added in v1.17.1
func (r *L4NetLBSyncResult) SetMetricsForSuccessfulServiceSync()
SetMetricsForSuccessfulServiceSync should be call after successful sync.
type L7 ¶
type L7 struct {
// contains filtered or unexported fields
}
L7 represents a single L7 loadbalancer.
func (*L7) Cleanup ¶
func (l *L7) Cleanup(versions *features.ResourceVersions) error
Cleanup deletes resources specific to this l7 in the right order. forwarding rule -> target proxy -> url map This leaves backends and health checks, which are shared across loadbalancers.
func (*L7) RuntimeInfo ¶ added in v1.2.2
func (l *L7) RuntimeInfo() *L7RuntimeInfo
RuntimeInfo returns the L7RuntimeInfo associated with the L7 load balancer.
func (*L7) String ¶ added in v1.8.0
String returns the name of the loadbalancer. Warning: This should be used only for logging and should not be used to retrieve/ delete gce resource names.
func (*L7) Versions ¶ added in v1.7.0
func (l *L7) Versions() *features.ResourceVersions
Versions returns the struct listing the versions for every resource
type L7RuntimeInfo ¶
type L7RuntimeInfo struct { // IP is the desired ip of the loadbalancer, eg from a staticIP. IP string // TLS are the tls certs to use in termination. TLS []*translator.TLSCerts // TLSName is the name of the preshared cert to use. Multiple certs can be specified as a comma-separated string TLSName string // Ingress is the processed Ingress API object. Ingress *v1.Ingress // AllowHTTP will not setup :80, if TLS is nil and AllowHTTP is set, // no loadbalancer is created. AllowHTTP bool // The name of a Global/Regional Static IP. If specified, the IP associated with // this name is used in the Forwarding Rules for this loadbalancer. // If this is an l7-ILB ingress, the static IP is assumed to be internal StaticIPName string // The name of the static IP subnet, this is only used for L7-ILB Ingress static IPs StaticIPSubnet string // UrlMap is our internal representation of a url map. UrlMap *utils.GCEURLMap // FrontendConfig is the type which encapsulates features for the load balancer. FrontendConfig *frontendconfigv1beta1.FrontendConfig }
L7RuntimeInfo is info passed to this module from the controller runtime.
type L7s ¶
type L7s struct {
// contains filtered or unexported fields
}
L7s implements LoadBalancerPool.
func (*L7s) Ensure ¶ added in v1.5.0
func (l *L7s) Ensure(ri *L7RuntimeInfo) (*L7, error)
Ensure implements LoadBalancerPool.
func (*L7s) FrontendScopeChangeGC ¶ added in v1.9.10
FrontendScopeChangeGC returns the scope to GC if the LB has changed scopes (e.g. when a user migrates from ILB to ELB on the same ingress or vice versa.) This only applies to the V2 Naming Scheme TODO(shance): Refactor to avoid calling GCE every sync loop
func (*L7s) GCv1 ¶ added in v1.8.0
GCv1 implements LoadBalancerPool. TODO(shance): Update to handle regional and global LB with same name
type LoadBalancerPool ¶
type LoadBalancerPool interface { // Ensure ensures a loadbalancer and its resources given the RuntimeInfo. Ensure(ri *L7RuntimeInfo) (*L7, error) // GCv2 garbage collects loadbalancer associated with given ingress using v2 naming scheme. GCv2(ing *v1.Ingress, scope meta.KeyType) error // GCv1 garbage collects loadbalancers not in the input list using v1 naming scheme. GCv1(names []string) error // FrontendScopeChangeGC checks if GC is needed for an ingress that has changed scopes FrontendScopeChangeGC(ing *v1.Ingress) (*meta.KeyType, error) // Shutdown deletes all loadbalancers for given list of ingresses. Shutdown(ings []*v1.Ingress) error // HasUrlMap returns true if an URL map exists in GCE for given ingress. HasUrlMap(ing *v1.Ingress) (bool, error) }
LoadBalancerPool is an interface to manage the cloud resources associated with a gce loadbalancer.
func NewLoadBalancerPool ¶
func NewLoadBalancerPool(cloud *gce.Cloud, v1NamerHelper namer_util.V1FrontendNamer, recorderProducer events.RecorderProducer, namerFactory namer_util.IngressFrontendNamerFactory) LoadBalancerPool
NewLoadBalancerPool returns a new loadbalancer pool.
- cloud: implements LoadBalancers. Used to sync L7 loadbalancer resources with the cloud.