namer

package
v1.10.15 Latest Latest
Warning

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

Go to latest
Published: Mar 2, 2021 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// V1NamingScheme is v1 frontend naming scheme.
	V1NamingScheme = Scheme("v1")
	// V2NamingScheme is v2 frontend naming scheme.
	V2NamingScheme = Scheme("v2")
)

Variables

This section is empty.

Functions

func FinalizerForNamingScheme

func FinalizerForNamingScheme(scheme Scheme) (string, error)

FinalizerForNamingScheme returns finalizer corresponding to given frontend naming scheme.

func TrimFieldsEvenly

func TrimFieldsEvenly(max int, fields ...string) []string

TrimFieldsEvenly trims the fields evenly and keeps the total length <= max. Truncation is spread in ratio with their original length, meaning smaller fields will be truncated less than longer ones.

Types

type BackendNamer

type BackendNamer interface {
	// IGBackend constructs the name for a backend service targeting instance groups.
	IGBackend(nodePort int64) string
	// NEG returns the gce neg name based on the service namespace, name
	// and target port.
	NEG(namespace, name string, Port int32) string
	// VMIPNEG returns the gce neg name based on the service namespace and name.
	// The second output parameter indicates if the namer supports VM_IP_NEGs.
	VMIPNEG(namespace, name string) (string, bool)
	// InstanceGroup constructs the name for an Instance Group.
	InstanceGroup() string
	// NamedPort returns the name for a named port.
	NamedPort(port int64) string
	// NameBelongsToCluster checks if a given backend resource name is tagged with
	// this cluster's UID.
	NameBelongsToCluster(resourceName string) bool
}

BackendNamer is an interface to name GCE backend resources. It wraps backend naming policy of namer.Namer.

type FrontendNamerFactory

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

FrontendNamerFactory implements IngressFrontendNamerFactory.

func (*FrontendNamerFactory) Namer

Namer implements IngressFrontendNamerFactory.

func (*FrontendNamerFactory) NamerForLoadBalancer added in v1.9.0

func (rn *FrontendNamerFactory) NamerForLoadBalancer(lbName LoadBalancerName) IngressFrontendNamer

NamerForLoadBalancer implements IngressFrontendNamerFactory.

type IngressFrontendNamer

type IngressFrontendNamer interface {
	// ForwardingRule returns the name of the gce forwarding rule for given protocol.
	ForwardingRule(protocol NamerProtocol) string
	// TargetProxy returns the name of the gce target proxy for given protocol.
	TargetProxy(protocol NamerProtocol) string
	// UrlMap returns the name of the URL Map.
	UrlMap() string
	// RedirectUrlMap returns the name of the URL Map and if the namer supports naming redirectUrlMap
	RedirectUrlMap() (string, bool)
	// SSLCertName returns the SSL certificate name given secret hash.
	SSLCertName(secretHash string) string
	// IsCertNameForLB returns true if certName belongs to this ingress.
	IsCertNameForLB(certName string) bool
	// IsLegacySSLCert returns true if certName follows the older naming convention
	// and cert is managed by this ingress.
	// old naming convention is of the form k8s-ssl-<lbName> or k8s-ssl-1-<lbName>.
	IsLegacySSLCert(certName string) bool
	// LoadBalancer returns load-balancer name for the ingress.
	LoadBalancer() LoadBalancerName
}

IngressFrontendNamer is an interface to name GCE frontend resources.

type IngressFrontendNamerFactory

type IngressFrontendNamerFactory interface {
	// Namer returns IngressFrontendNamer for given ingress.
	Namer(ing *v1beta1.Ingress) IngressFrontendNamer
	// NamerForLoadBalancer returns IngressFrontendNamer given a load-balancer
	// name. This used only for v1 naming scheme.
	NamerForLoadBalancer(loadBalancer LoadBalancerName) IngressFrontendNamer
}

IngressFrontendNamerFactory is an interface to create a front namer for an Ingress a load balancer.

func NewFrontendNamerFactory

func NewFrontendNamerFactory(namer *Namer, kubeSystemUID types.UID) IngressFrontendNamerFactory

NewFrontendNamerFactory returns IngressFrontendNamerFactory given a v1 namer and kube-system uid.

type L4Namer added in v1.10.4

type L4Namer struct {
	// Namer is needed to implement all methods required by BackendNamer interface.
	*Namer
	// contains filtered or unexported fields
}

L4Namer implements naming scheme for L4 LoadBalancer resources. This uses the V2 Naming scheme Example: For Service - namespace/svc, clusterUID/clusterName - uid01234, prefix - k8s2, protocol TCP Assume that hash("uid01234;svc;namespace") = cysix1wq The resource names are - TCP Forwarding Rule : k8s2-tcp-uid01234-namespace-svc-cysix1wq UDP Forwarding Rule : k8s2-udp-uid01234-namespace-svc-cysix1wq All other resources : k8s2-uid01234-namespace-svc-cysix1wq The "namespace-svc" part of the string will be trimmed as needed.

func NewL4Namer added in v1.10.4

func NewL4Namer(kubeSystemUID string, namer *Namer) *L4Namer

func (*L4Namer) IsNEG added in v1.10.4

func (namer *L4Namer) IsNEG(name string) bool

IsNEG indicates if the given name is a NEG following the L4 naming convention.

func (*L4Namer) L4ForwardingRule added in v1.10.4

func (namer *L4Namer) L4ForwardingRule(namespace, name, protocol string) string

L4ForwardingRule returns the name of the L4 forwarding rule name based on the service namespace, name and protocol. Naming convention:

k8s2-{protocol}-{uid}-{ns}-{name}-{suffix}

Output name is at most 63 characters.

func (*L4Namer) L4HealthCheck added in v1.10.4

func (namer *L4Namer) L4HealthCheck(namespace, name string, shared bool) (string, string)

L4HealthCheck returns the name of the L4 ILB Healthcheck and the associated firewall rule.

func (*L4Namer) VMIPNEG added in v1.10.4

func (namer *L4Namer) VMIPNEG(namespace, name string) (string, bool)

VMIPNEG returns the gce VM_IP_NEG name based on the service namespace and name NEG naming convention:

k8s2-{uid}-{ns}-{name}-{suffix}

Output name is at most 63 characters.

type L4ResourcesNamer added in v1.10.4

type L4ResourcesNamer interface {
	// BackendNamer is included so implementations of this interface can be used along with backendPools for linking VM_IP_NEGs.
	BackendNamer
	// L4ForwardingRule returns the name of the forwarding rule for the given service and protocol.
	L4ForwardingRule(namespace, name, protocol string) string
	// L4HealthCheck returns the names of the Healthcheck and HC-firewall rule.
	L4HealthCheck(namespace, name string, shared bool) (string, string)
	// IsNEG returns if the given name is a VM_IP_NEG name.
	IsNEG(name string) bool
}

L4ResourcesNamer is an interface to name L4 LoadBalancing resources.

type LoadBalancerName added in v1.9.0

type LoadBalancerName string

LoadBalancerName is the name of a GCE load-balancer for an ingress.

func (LoadBalancerName) String added in v1.9.0

func (lbName LoadBalancerName) String() string

String typecasts LoadBalancerName to string type.

type NameComponents

type NameComponents struct {
	ClusterName, Resource, Metadata, LbNamePrefix string
}

NameComponents is a struct representing the components of a a GCE resource name constructed by the namer. The format of such a name is: k8s-resource-<metadata, eg port>--uid Note that the LbNamePrefix field is empty if the resource is a BackendService.

type Namer

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

Namer is the centralized naming policy for Ingress-related GCP resources.

func NewNamer

func NewNamer(clusterName, firewallName string) *Namer

NewNamer creates a new namer with a Cluster and Firewall name.

func NewNamerWithPrefix

func NewNamerWithPrefix(prefix, clusterName, firewallName string) *Namer

NewNamerWithPrefix creates a new namer with a custom prefix.

func (*Namer) Firewall

func (n *Namer) Firewall() string

Firewall returns the firewall name of this cluster.

func (*Namer) FirewallRule

func (n *Namer) FirewallRule() string

FirewallRule constructs the full firewall rule name, this is the name assigned by the cloudprovider lib + suffix from glbc, so we don't mix this rule with a rule created for L4 loadbalancing.

func (*Namer) ForwardingRule

func (n *Namer) ForwardingRule(lbName LoadBalancerName, protocol NamerProtocol) string

ForwardingRule returns the name of the forwarding rule prefix.

func (*Namer) IGBackend

func (n *Namer) IGBackend(port int64) string

IGBackend constructs the name for a backend service targeting instance groups.

func (*Namer) IGBackendPort

func (n *Namer) IGBackendPort(beName string) (string, error)

IGBackendPort retrieves the port from the given backend name.

func (*Namer) InstanceGroup

func (n *Namer) InstanceGroup() string

InstanceGroup constructs the name for an Instance Group.

func (*Namer) IsCertUsedForLB

func (n *Namer) IsCertUsedForLB(lbName LoadBalancerName, resourceName string) bool

IsCertUsedForLB returns true if the resourceName belongs to this cluster's ingress. It checks that the hashed lbName exists and

func (*Namer) IsLegacySSLCert

func (n *Namer) IsLegacySSLCert(lbName LoadBalancerName, resourceName string) bool

IsLegacySSLCert returns true if certName is an Ingress managed name following the older naming convention. The check also ensures that the cert is managed by the specific ingress instance - lbName

func (*Namer) IsNEG

func (n *Namer) IsNEG(name string) bool

IsNEG returns true if the name is a NEG owned by this cluster. It checks that the UID is present and a substring of the cluster uid, since the NEG naming schema truncates it to 8 characters. This is only valid for NEGs, BackendServices and Healthchecks for NEG.

func (*Namer) LoadBalancer

func (n *Namer) LoadBalancer(key string) LoadBalancerName

LoadBalancer constructs a loadbalancer name from the given key. The key is usually the namespace/name of a Kubernetes Ingress.

func (*Namer) LoadBalancerForURLMap added in v1.9.0

func (n *Namer) LoadBalancerForURLMap(urlMap string) LoadBalancerName

LoadBalancerForURLMap returns the loadbalancer name for given URL map.

func (*Namer) NEG

func (n *Namer) NEG(namespace, name string, port int32) string

NEG returns the gce neg name based on the service namespace, name and target port. NEG naming convention:

{prefix}{version}-{clusterid}-{namespace}-{name}-{service port}-{hash}

Output name is at most 63 characters. NEG tries to keep as much information as possible.

WARNING: Controllers depend on the naming pattern to get the list of all NEGs associated with the current cluster. Any modifications must be backward compatible.

func (*Namer) NEGWithSubset

func (n *Namer) NEGWithSubset(namespace, name, subset string, port int32) string

NEGWithSubset returns the gce neg name based on the service namespace, name target port and Istio:DestinationRule subset. NEG naming convention:

{prefix}{version}-{clusterid}-{namespace}-{name}-{service port}-{destination rule subset}-{hash}

Output name is at most 63 characters. NEG tries to keep as much information as possible.

WARNING: Controllers depend on the naming pattern to get the list of all NEGs associated with the current cluster. Any modifications must be backward compatible.

func (*Namer) NameBelongsToCluster

func (n *Namer) NameBelongsToCluster(name string) bool

NameBelongsToCluster checks if a given name is tagged with this cluster's UID.

func (*Namer) NamedPort

func (n *Namer) NamedPort(port int64) string

NamedPort returns the name for a named port.

func (*Namer) ParseName

func (n *Namer) ParseName(name string) *NameComponents

ParseName parses the name of a resource generated by the namer. This is only valid for the following resources:

Backend, InstanceGroup, UrlMap.

func (*Namer) RedirectUrlMap added in v1.10.0

func (n *Namer) RedirectUrlMap(lbName LoadBalancerName) string

UrlMap returns the name for the UrlMap for a given load balancer.

func (*Namer) SSLCertName

func (n *Namer) SSLCertName(lbName LoadBalancerName, secretHash string) string

SSLCertName returns the name of the certificate.

func (*Namer) SetFirewall

func (n *Namer) SetFirewall(name string)

SetFirewall sets the firewall name of this cluster.

func (*Namer) SetUID

func (n *Namer) SetUID(name string)

SetUID sets the UID/name of this cluster.

func (*Namer) TargetProxy

func (n *Namer) TargetProxy(lbName LoadBalancerName, protocol NamerProtocol) string

TargetProxy returns the name for target proxy given the load balancer name and the protocol.

func (*Namer) UID

func (n *Namer) UID() string

UID returns the UID/name of this cluster. WARNING: Use KubeSystemUID instead

func (*Namer) UrlMap

func (n *Namer) UrlMap(lbName LoadBalancerName) string

UrlMap returns the name for the UrlMap for a given load balancer.

func (*Namer) VMIPNEG added in v1.9.4

func (namer *Namer) VMIPNEG(namespace, name string) (string, bool)

VMIPNEG is only supported by L4Namer.

type NamerProtocol

type NamerProtocol string

NamerProtocol is an enum for the different protocols given as parameters to Namer.

const (
	HTTPProtocol  NamerProtocol = "HTTP"
	HTTPSProtocol NamerProtocol = "HTTPS"
)

type Scheme

type Scheme string

Scheme is ingress frontend name scheme.

func FrontendNamingScheme

func FrontendNamingScheme(ing *v1beta1.Ingress) Scheme

FrontendNamingScheme returns naming scheme for given ingress based on its finalizer.

type V1FrontendNamer

type V1FrontendNamer interface {
	// LoadBalancer constructs a loadbalancer name from the given ingress key.
	LoadBalancer(ingKey string) LoadBalancerName
	// LoadBalancerForURLMap returns the loadbalancer name for given URL map.
	LoadBalancerForURLMap(urlMap string) LoadBalancerName
	// NameBelongsToCluster checks if a given frontend resource name is tagged with
	// this cluster's UID.
	NameBelongsToCluster(resourceName string) bool
}

V1FrontendNamer wraps frontend naming policy helper functions of namer.Namer.

type V1IngressFrontendNamer

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

V1IngressFrontendNamer implements IngressFrontendNamer. This is a wrapper on top of namer.Namer.

func (*V1IngressFrontendNamer) ForwardingRule

func (ln *V1IngressFrontendNamer) ForwardingRule(protocol NamerProtocol) string

ForwardingRule implements IngressFrontendNamer.

func (*V1IngressFrontendNamer) IsCertNameForLB

func (ln *V1IngressFrontendNamer) IsCertNameForLB(certName string) bool

IsCertNameForLB implements IngressFrontendNamer.

func (*V1IngressFrontendNamer) IsLegacySSLCert

func (ln *V1IngressFrontendNamer) IsLegacySSLCert(certName string) bool

IsLegacySSLCert implements IngressFrontendNamer.

func (*V1IngressFrontendNamer) LoadBalancer added in v1.9.0

func (ln *V1IngressFrontendNamer) LoadBalancer() LoadBalancerName

LoadBalancer implements IngressFrontendNamer.

func (*V1IngressFrontendNamer) RedirectUrlMap added in v1.10.0

func (ln *V1IngressFrontendNamer) RedirectUrlMap() (string, bool)

RedirectUrlMap implements IngressFrontendNamer.

func (*V1IngressFrontendNamer) SSLCertName

func (ln *V1IngressFrontendNamer) SSLCertName(secretHash string) string

SSLCertName implements IngressFrontendNamer.

func (*V1IngressFrontendNamer) TargetProxy

func (ln *V1IngressFrontendNamer) TargetProxy(protocol NamerProtocol) string

TargetProxy implements IngressFrontendNamer.

func (*V1IngressFrontendNamer) UrlMap

func (ln *V1IngressFrontendNamer) UrlMap() string

UrlMap implements IngressFrontendNamer.

type V2IngressFrontendNamer

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

V2IngressFrontendNamer implements IngressFrontendNamer.

func (*V2IngressFrontendNamer) ForwardingRule

func (vn *V2IngressFrontendNamer) ForwardingRule(protocol NamerProtocol) string

ForwardingRule returns the name of forwarding rule based on given protocol.

func (*V2IngressFrontendNamer) IsCertNameForLB

func (vn *V2IngressFrontendNamer) IsCertNameForLB(certName string) bool

IsCertNameForLB returns true if the certName belongs to this cluster's ingress. It checks that the hashed lbName exists.

func (*V2IngressFrontendNamer) IsLegacySSLCert

func (vn *V2IngressFrontendNamer) IsLegacySSLCert(certName string) bool

IsLegacySSLCert always return false as v2 naming scheme does not use legacy certs.

func (*V2IngressFrontendNamer) LoadBalancer added in v1.9.0

func (vn *V2IngressFrontendNamer) LoadBalancer() LoadBalancerName

LoadBalancer returns loadbalancer name. Note that this is used for generating GCE resource names.

func (*V2IngressFrontendNamer) RedirectUrlMap added in v1.10.0

func (vn *V2IngressFrontendNamer) RedirectUrlMap() (string, bool)

RedirectUrlMap returns the name of Redirect URL map.

func (*V2IngressFrontendNamer) SSLCertName

func (vn *V2IngressFrontendNamer) SSLCertName(secretHash string) string

SSLCertName returns the name of the certificate.

func (*V2IngressFrontendNamer) TargetProxy

func (vn *V2IngressFrontendNamer) TargetProxy(protocol NamerProtocol) string

TargetProxy returns the name of target proxy based on given protocol.

func (*V2IngressFrontendNamer) UrlMap

func (vn *V2IngressFrontendNamer) UrlMap() string

UrlMap returns the name of URL map.

Jump to

Keyboard shortcuts

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