utils

package
v0.0.0-...-7669b99 Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2017 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Add used to record additions in a sync pool.
	Add = iota
	// Remove used to record removals from a sync pool.
	Remove
	// Sync used to record syncs of a sync pool.
	Sync
	// Get used to record Get from a sync pool.
	Get
	// Create used to record creations in a sync pool.
	Create
	// Update used to record updates in a sync pool.
	Update
	// Delete used to record deltions from a sync pool.
	Delete
	// AddInstances used to record a call to AddInstances.
	AddInstances
	// RemoveInstances used to record a call to RemoveInstances.
	RemoveInstances

	// DefaultBackendKey is the key used to transmit the defaultBackend through
	// a urlmap. It's not a valid subdomain, and it is a catch all path.
	// TODO: Find a better way to transmit this, once we've decided on default
	// backend semantics (i.e do we want a default per host, per lb etc).
	DefaultBackendKey = "DefaultBackend"

	// K8sAnnotationPrefix is the prefix used in annotations used to record
	// debug information in the Ingress annotations.
	K8sAnnotationPrefix = "ingress.kubernetes.io"

	// DefaultHealthCheckInterval defines how frequently a probe runs
	DefaultHealthCheckInterval = 60
	// DefaultHealthyThreshold defines the threshold of success probes that declare a backend "healthy"
	DefaultHealthyThreshold = 1
	// DefaultUnhealthyThreshold defines the threshold of failure probes that declare a backend "unhealthy"
	DefaultUnhealthyThreshold = 10
	// DefaultTimeoutSeconds defines the timeout of each probe
	DefaultTimeoutSeconds = 60
)

Variables

This section is empty.

Functions

func CompareLinks(l1, l2 string) bool

CompareLinks returns true if the 2 self links are equal.

func DefaultHealthCheckTemplate

func DefaultHealthCheckTemplate(port int64) *compute.HttpHealthCheck

DefaultHealthCheckTemplate simply returns the default health check template.

func FakeGoogleAPINotFoundErr

func FakeGoogleAPINotFoundErr() *googleapi.Error

FakeNotFoundErr creates a NotFound error with type googleapi.Error

func IsHTTPErrorCode

func IsHTTPErrorCode(err error, code int) bool

IsHTTPErrorCode checks if the given error matches the given HTTP Error code. For this to work the error must be a googleapi Error.

Types

type FakeIngressRuleValueMap

type FakeIngressRuleValueMap map[string]string

FakeIngressRuleValueMap is a convenience type used by multiple submodules that share the same testing methods.

type GCEURLMap

type GCEURLMap map[string]map[string]*compute.BackendService

GCEURLMap is a nested map of hostname->path regex->backend

func (GCEURLMap) GetDefaultBackend

func (g GCEURLMap) GetDefaultBackend() *compute.BackendService

GetDefaultBackend performs a destructive read and returns the default backend of the urlmap.

func (GCEURLMap) PutDefaultBackend

func (g GCEURLMap) PutDefaultBackend(d *compute.BackendService)

PutDefaultBackend performs a destructive write replacing the default backend of the url map with the given backend.

func (GCEURLMap) String

func (g GCEURLMap) String() string

String implements the string interface for the GCEURLMap.

type NameComponents

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

type Namer

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

Namer handles centralized naming for the cluster.

func NewNamer

func NewNamer(clusterName, firewallName string) *Namer

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

func (*Namer) BeName

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

BeName constructs the name for a backend.

func (*Namer) BePort

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

BePort retrieves the port from the given backend name.

func (*Namer) FrName

func (n *Namer) FrName(suffix string) string

FrName 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) FrSuffix

func (n *Namer) FrSuffix() string

FrSuffix constructs the glbc specific suffix for the FirewallRule.

func (*Namer) GetClusterName

func (n *Namer) GetClusterName() string

GetClusterName returns the UID/name of this cluster.

func (*Namer) GetFirewallName

func (n *Namer) GetFirewallName() string

GetFirewallName returns the firewall name of this cluster.

func (*Namer) IGName

func (n *Namer) IGName() string

IGName constructs the name for an Instance Group.

func (*Namer) LBName

func (n *Namer) LBName(key string) string

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

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

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

ParseName parses the name of a resource generated by the namer.

func (*Namer) SetClusterName

func (n *Namer) SetClusterName(name string)

SetClusterName sets the UID/name of this cluster.

func (*Namer) SetFirewallName

func (n *Namer) SetFirewallName(firewall_name string)

SetFirewallName sets the firewall name of this cluster.

func (*Namer) Truncate

func (n *Namer) Truncate(key string) string

Truncate truncates the given key to a GCE length limit.

Jump to

Keyboard shortcuts

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