namer

package
v1.8.3 Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2020 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
	// 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) NamerForLbName

func (rn *FrontendNamerFactory) NamerForLbName(lbName string) IngressFrontendNamer

NamerForLbName 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
	// 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
	// LbName returns load-balancer name for the ingress.
	LbName() string
}

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
	// NamerForLbName returns IngressFrontendNamer given a load-balancer
	// name. This used only for v1 naming scheme.
	NamerForLbName(lbName string) 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 NameComponents

type NameComponents struct {
	ClusterName, Resource, Metadata, LbName 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 LbName 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 string, 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, 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 string, 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) string

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

func (*Namer) LoadBalancerFromLbName

func (n *Namer) LoadBalancerFromLbName(lbName string) string

LoadBalancerFromLbName reconstructs the full loadbalancer name, given the lbName portion from NameComponents

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) SSLCertName

func (n *Namer) SSLCertName(lbName string, 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 string, 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.

func (*Namer) UrlMap

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

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

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) string
	// LoadBalancerFromLbName reconstructs the full loadbalancer name, given the
	// lbName portion from NameComponents.
	LoadBalancerFromLbName(lbName string) string
	// ParseName parses the resource name of a resource generated by the namer.
	ParseName(resourceName string) *NameComponents
	// 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) LbName

func (ln *V1IngressFrontendNamer) LbName() string

LbName 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) LbName

func (vn *V2IngressFrontendNamer) LbName() string

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

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