Documentation ¶
Index ¶
- Constants
- func FinalizerForNamingScheme(scheme Scheme) (string, error)
- func TrimFieldsEvenly(max int, fields ...string) []string
- type BackendNamer
- type FrontendNamerFactory
- type IngressFrontendNamer
- type IngressFrontendNamerFactory
- type NameComponents
- type Namer
- func (n *Namer) Firewall() string
- func (n *Namer) FirewallRule() string
- func (n *Namer) ForwardingRule(lbName string, protocol NamerProtocol) string
- func (n *Namer) IGBackend(port int64) string
- func (n *Namer) IGBackendPort(beName string) (string, error)
- func (n *Namer) InstanceGroup() string
- func (n *Namer) IsCertUsedForLB(lbName, resourceName string) bool
- func (n *Namer) IsLegacySSLCert(lbName string, resourceName string) bool
- func (n *Namer) IsNEG(name string) bool
- func (n *Namer) LoadBalancer(key string) string
- func (n *Namer) LoadBalancerFromLbName(lbName string) string
- func (n *Namer) NEG(namespace, name string, port int32) string
- func (n *Namer) NEGWithSubset(namespace, name, subset string, port int32) string
- func (n *Namer) NameBelongsToCluster(name string) bool
- func (n *Namer) NamedPort(port int64) string
- func (n *Namer) ParseName(name string) *NameComponents
- func (n *Namer) SSLCertName(lbName string, secretHash string) string
- func (n *Namer) SetFirewall(name string)
- func (n *Namer) SetUID(name string)
- func (n *Namer) TargetProxy(lbName string, protocol NamerProtocol) string
- func (n *Namer) UID() string
- func (n *Namer) UrlMap(lbName string) string
- type NamerProtocol
- type Scheme
- type V1FrontendNamer
- type V1IngressFrontendNamer
- func (ln *V1IngressFrontendNamer) ForwardingRule(protocol NamerProtocol) string
- func (ln *V1IngressFrontendNamer) IsCertNameForLB(certName string) bool
- func (ln *V1IngressFrontendNamer) IsLegacySSLCert(certName string) bool
- func (ln *V1IngressFrontendNamer) LbName() string
- func (ln *V1IngressFrontendNamer) SSLCertName(secretHash string) string
- func (ln *V1IngressFrontendNamer) TargetProxy(protocol NamerProtocol) string
- func (ln *V1IngressFrontendNamer) UrlMap() string
- type V2IngressFrontendNamer
- func (vn *V2IngressFrontendNamer) ForwardingRule(protocol NamerProtocol) string
- func (vn *V2IngressFrontendNamer) IsCertNameForLB(certName string) bool
- func (vn *V2IngressFrontendNamer) IsLegacySSLCert(certName string) bool
- func (vn *V2IngressFrontendNamer) LbName() string
- func (vn *V2IngressFrontendNamer) SSLCertName(secretHash string) string
- func (vn *V2IngressFrontendNamer) TargetProxy(protocol NamerProtocol) string
- func (vn *V2IngressFrontendNamer) UrlMap() string
Constants ¶
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 ¶
FinalizerForNamingScheme returns finalizer corresponding to given frontend naming scheme.
func TrimFieldsEvenly ¶
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 ¶
func (rn *FrontendNamerFactory) Namer(ing *v1beta1.Ingress) IngressFrontendNamer
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, uid types.UID) IngressFrontendNamerFactory
NewFrontendNamerFactory returns IngressFrontendNamerFactory given a v1 namer and 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 NewNamerWithPrefix ¶
NewNamerWithPrefix creates a new namer with a custom prefix.
func (*Namer) FirewallRule ¶
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 ¶
IGBackend constructs the name for a backend service targeting instance groups.
func (*Namer) IGBackendPort ¶
IGBackendPort retrieves the port from the given backend name.
func (*Namer) InstanceGroup ¶
InstanceGroup constructs the name for an Instance Group.
func (*Namer) IsCertUsedForLB ¶
IsCertUsedForLB returns true if the resourceName belongs to this cluster's ingress. It checks that the hashed lbName exists and
func (*Namer) IsLegacySSLCert ¶
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 ¶
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 ¶
LoadBalancer constructs a loadbalancer name from the given key. The key is usually the namespace/name of a Kubernetes Ingress.
func (*Namer) LoadBalancerFromLbName ¶
LoadBalancerFromLbName reconstructs the full loadbalancer name, given the lbName portion from NameComponents
func (*Namer) NEG ¶
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 ¶
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 ¶
NameBelongsToCluster checks if a given name is tagged with this cluster's UID.
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 ¶
SSLCertName returns the name of the certificate.
func (*Namer) SetFirewall ¶
SetFirewall sets the firewall 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.
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 ¶
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.