kubernetes

package
v0.0.0-...-ad5601e Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2019 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SERVICE_TYPE    ResourceType = 1
	DEPLOYMENT_TYPE ResourceType = 2
	POD_TYPE        ResourceType = 3
	INGRESS_TYPE    ResourceType = 4

	ENVOY_ENABLED = "traffic.envoy.enabled"

	ENVOY_PROXY_ANNOTATION = "traffic.envoy.proxy"

	DEFAULT_WEIGHT = 100

	POD_SERVICE_PREFIX          = "traffic.svc."
	POD_DEPLOYMENT_PREFIX       = "traffic.rs."
	ENVOY_ENABLED_BY_DEPLOYMENT = POD_DEPLOYMENT_PREFIX + "envoy.enabled"

	PROTO_HTTP   = 2
	PROTO_TCP    = 1
	PROTO_DIRECT = 0
)
View Source
const (
	SECRET_TLS_HOST = "traffic.tls.host"
)

Variables

This section is empty.

Functions

func AnnotationHasDeploymentLabel

func AnnotationHasDeploymentLabel(label string) bool

func AnnotationHasServiceLabel

func AnnotationHasServiceLabel(svc string, label string) bool

func DeploymentLabelToPodAnnotation

func DeploymentLabelToPodAnnotation(label string) string

func GetLabelValueBool

func GetLabelValueBool(value string) bool

func GetLabelValueFloat64

func GetLabelValueFloat64(value string) float64

func GetLabelValueInt64

func GetLabelValueInt64(value string) int64

func GetLabelValueUInt32

func GetLabelValueUInt32(value string) uint32

func GetLabelValueUInt64

func GetLabelValueUInt64(value string) uint64

func GetProtocol

func GetProtocol(value string) int

func GetRESTClientMap

func GetRESTClientMap(clientSet kubernetes.Interface) map[string]cache.Getter

func IngressAttrLabel

func IngressAttrLabel(port uint32, attr string) string

func PodEnvoyByService

func PodEnvoyByService(svc string) string

func PodPortProtcolByService

func PodPortProtcolByService(svc string, port uint32) string

func PodTargetPortProtcolByService

func PodTargetPortProtcolByService(svc string, port uint32) string

func ServiceLabelToPodAnnotation

func ServiceLabelToPodAnnotation(svc string, label string) string

func ServicePortProtocol

func ServicePortProtocol(port uint32) string

Types

type DeploymentEventHandler

type DeploymentEventHandler interface {
	DeploymentValid(deployment *DeploymentInfo) bool
	DeploymentAdded(deployment *DeploymentInfo)
	DeploymentDeleted(deployment *DeploymentInfo)
	DeploymentUpdated(oldDeployment, newDeployment *DeploymentInfo)
}

type DeploymentInfo

type DeploymentInfo struct {
	Labels      map[string]string
	Ports       []uint32
	HostNetwork bool
	// contains filtered or unexported fields
}

func NewDeploymentInfo

func NewDeploymentInfo(obj interface{}) *DeploymentInfo

func (*DeploymentInfo) EnvoyEnabled

func (deployment *DeploymentInfo) EnvoyEnabled() bool

func (*DeploymentInfo) GetSelector

func (deployment *DeploymentInfo) GetSelector() map[string]string

func (*DeploymentInfo) Name

func (deployment *DeploymentInfo) Name() string

func (*DeploymentInfo) Namespace

func (deployment *DeploymentInfo) Namespace() string

func (*DeploymentInfo) String

func (deployment *DeploymentInfo) String() string

func (*DeploymentInfo) Type

func (deployment *DeploymentInfo) Type() ResourceType

type IngressClusterInfo

type IngressClusterInfo struct {
	Service string
	Port    uint32
	Path    string
}

type IngressEventHandler

type IngressEventHandler interface {
	IngressValid(ingressInfo *IngressInfo) bool
	IngressAdded(ingressInfo *IngressInfo)
	IngressDeleted(ingressInfo *IngressInfo)
	IngressUpdated(oldIngress, newIngress *IngressInfo)
}

type IngressHostInfo

type IngressHostInfo struct {
	Host    string
	PathMap map[string]*IngressClusterInfo
	Secret  string
}

type IngressInfo

type IngressInfo struct {
	ResourceVersion string

	HostPathToClusterMap map[string]*IngressHostInfo
	// contains filtered or unexported fields
}

func NewIngressInfo

func NewIngressInfo(ingress *v1beta1.Ingress) *IngressInfo

func (*IngressInfo) GetSelector

func (ingress *IngressInfo) GetSelector() map[string]string

func (*IngressInfo) GetServiceAnnotations

func (ingress *IngressInfo) GetServiceAnnotations(hostInfo *IngressHostInfo, clusterInfo *IngressClusterInfo) map[string]string

func (*IngressInfo) Name

func (ingress *IngressInfo) Name() string

func (*IngressInfo) Namespace

func (ingress *IngressInfo) Namespace() string

func (*IngressInfo) String

func (ingress *IngressInfo) String() string

func (*IngressInfo) Type

func (ingress *IngressInfo) Type() ResourceType

type K8sResourceManager

type K8sResourceManager struct {
	ClientSet kubernetes.Interface
	// contains filtered or unexported fields
}

func NewFakeK8sResourceManager

func NewFakeK8sResourceManager() *K8sResourceManager

func NewK8sResourceManager

func NewK8sResourceManager() (*K8sResourceManager, error)

func (*K8sResourceManager) AddServiceLabel

func (manager *K8sResourceManager) AddServiceLabel(serviceInfo *ServiceInfo, key string, value string) error

func (*K8sResourceManager) DeploymentAdded

func (manager *K8sResourceManager) DeploymentAdded(deployment *DeploymentInfo)

func (*K8sResourceManager) DeploymentDeleted

func (manager *K8sResourceManager) DeploymentDeleted(deployment *DeploymentInfo)

func (*K8sResourceManager) DeploymentUpdated

func (manager *K8sResourceManager) DeploymentUpdated(oldDeployment, newDeployment *DeploymentInfo)

func (*K8sResourceManager) DeploymentValid

func (manager *K8sResourceManager) DeploymentValid(deployment *DeploymentInfo) bool

func (*K8sResourceManager) GetListerWatcher

func (manager *K8sResourceManager) GetListerWatcher(resourceType string) *fcache.FakeControllerSource

func (*K8sResourceManager) GetMatchedResources

func (manager *K8sResourceManager) GetMatchedResources(resource ResourceInfoPointer, matchType ResourceType) []ResourceInfoPointer

func (*K8sResourceManager) IsLocked

func (manager *K8sResourceManager) IsLocked() bool

func (*K8sResourceManager) Lock

func (manager *K8sResourceManager) Lock()

func (*K8sResourceManager) MergeServiceAnnotation

func (manager *K8sResourceManager) MergeServiceAnnotation(name string, ns string, values map[string]string) error

func (*K8sResourceManager) NewCond

func (manager *K8sResourceManager) NewCond() *sync.Cond

func (*K8sResourceManager) PodAdded

func (manager *K8sResourceManager) PodAdded(info *PodInfo)

func (*K8sResourceManager) PodDeleted

func (manager *K8sResourceManager) PodDeleted(info *PodInfo)

func (*K8sResourceManager) PodExists

func (manager *K8sResourceManager) PodExists(name string, ns string) (bool, error)

func (*K8sResourceManager) PodUpdated

func (manager *K8sResourceManager) PodUpdated(oldPod, newPod *PodInfo)

func (*K8sResourceManager) PodValid

func (manager *K8sResourceManager) PodValid(info *PodInfo) bool

func (*K8sResourceManager) PostSecret

func (manager *K8sResourceManager) PostSecret(name string, namespace string, certificate []byte, privateKey []byte) error

func (*K8sResourceManager) RemovePodAnnotation

func (manager *K8sResourceManager) RemovePodAnnotation(podInfo *PodInfo, annotationkeys []string) error

func (*K8sResourceManager) RemoveServiceAnnotation

func (manager *K8sResourceManager) RemoveServiceAnnotation(name string, ns string, values map[string]string) error

func (*K8sResourceManager) ServiceAdded

func (manager *K8sResourceManager) ServiceAdded(info *ServiceInfo)

func (*K8sResourceManager) ServiceDeleted

func (manager *K8sResourceManager) ServiceDeleted(info *ServiceInfo)

func (*K8sResourceManager) ServiceUpdated

func (manager *K8sResourceManager) ServiceUpdated(oldService, newService *ServiceInfo)

func (*K8sResourceManager) ServiceValid

func (manager *K8sResourceManager) ServiceValid(info *ServiceInfo) bool

func (*K8sResourceManager) Unlock

func (manager *K8sResourceManager) Unlock()

func (*K8sResourceManager) UpdatePodAnnotation

func (manager *K8sResourceManager) UpdatePodAnnotation(podInfo *PodInfo, annotation map[string]string) error

func (*K8sResourceManager) WatchDaemonSets

func (manager *K8sResourceManager) WatchDaemonSets(stopper chan struct{}, handlers ...DeploymentEventHandler)

func (*K8sResourceManager) WatchDeployments

func (manager *K8sResourceManager) WatchDeployments(stopper chan struct{}, handlers ...DeploymentEventHandler)

func (*K8sResourceManager) WatchIngresss

func (manager *K8sResourceManager) WatchIngresss(stopper chan struct{}, handlers ...IngressEventHandler)

func (*K8sResourceManager) WatchPods

func (manager *K8sResourceManager) WatchPods(stopper chan struct{}, handlers ...PodEventHandler)

func (*K8sResourceManager) WatchSecrets

func (manager *K8sResourceManager) WatchSecrets(stopper chan struct{}, handlers ...SecretEventHandler)

func (*K8sResourceManager) WatchServices

func (manager *K8sResourceManager) WatchServices(stopper chan struct{}, handlers ...ServiceEventHandler)

func (*K8sResourceManager) WatchStatefulSets

func (manager *K8sResourceManager) WatchStatefulSets(stopper chan struct{}, handlers ...DeploymentEventHandler)

type PodEventHandler

type PodEventHandler interface {
	PodValid(pod *PodInfo) bool
	PodAdded(pod *PodInfo)
	PodDeleted(pod *PodInfo)
	PodUpdated(oldPod, newPod *PodInfo)
}

type PodInfo

type PodInfo struct {
	ResourceVersion string

	PodIP       string
	HostIP      string
	HostNetwork bool
	Labels      map[string]string
	Annotations map[string]string
	Containers  []string
	// contains filtered or unexported fields
}

func NewPodInfo

func NewPodInfo(pod *v1.Pod) *PodInfo

func (*PodInfo) EnvoyDockerId

func (pod *PodInfo) EnvoyDockerId() string

func (*PodInfo) EnvoyEnabled

func (pod *PodInfo) EnvoyEnabled() bool

func (*PodInfo) GetPortSet

func (pod *PodInfo) GetPortSet() map[uint32]map[string]bool

func (*PodInfo) GetSelector

func (pod *PodInfo) GetSelector() map[string]string

func (*PodInfo) GetTargetPortConfig

func (pod *PodInfo) GetTargetPortConfig() map[uint32]*PodPortInfo

*

  • Used for k8s headless service.
  • LDS should create a listener for each podip:targetPort of the service
  • CDS should create a static cluster for each podip:targetPort of the service
  • example:
  • traffic.svc.service1.attr=value
  • traffic.svc.service1.target.port.5678=http
  • should return map 5678 => PodPortInfo{PROTO_HTTP, traffic.attr=value }

func (*PodInfo) IsSkip

func (pod *PodInfo) IsSkip() bool

func (*PodInfo) Name

func (pod *PodInfo) Name() string

func (*PodInfo) Namespace

func (pod *PodInfo) Namespace() string

func (*PodInfo) NodeId

func (pod *PodInfo) NodeId() string

func (*PodInfo) String

func (pod *PodInfo) String() string

func (*PodInfo) Type

func (pod *PodInfo) Type() ResourceType

func (*PodInfo) Valid

func (pod *PodInfo) Valid() bool

type PodPortInfo

type PodPortInfo struct {
	Protocol int
	//Service   string
	ConfigMap map[string]string
}

type ResourceInfoPointer

type ResourceInfoPointer interface {
	GetSelector() map[string]string
	Namespace() string
	Name() string
	Type() ResourceType
	String() string
}

type ResourceType

type ResourceType int

func (ResourceType) String

func (e ResourceType) String() string

type ResourcesOnLabel

type ResourcesOnLabel map[ResourceType][]ResourceInfoPointer

type SecretEventHandler

type SecretEventHandler interface {
	SecretValid(info *SecretInfo) bool
	SecretAdded(svc *SecretInfo)
	SecretDeleted(svc *SecretInfo)
	SecretUpdated(oldSecret, newSecret *SecretInfo)
}

type SecretInfo

type SecretInfo struct {
	Name            string
	Namespace       string
	Labels          map[string]string
	Data            map[string][]byte
	ResourceVersion string
}

func NewSecretInfo

func NewSecretInfo(secret *v1.Secret) *SecretInfo

type ServiceEventHandler

type ServiceEventHandler interface {
	ServiceValid(info *ServiceInfo) bool
	ServiceAdded(svc *ServiceInfo)
	ServiceDeleted(svc *ServiceInfo)
	ServiceUpdated(oldService, newService *ServiceInfo)
}

type ServiceInfo

type ServiceInfo struct {
	ResourceVersion string

	ClusterIP string

	Labels      map[string]string
	Annotations map[string]string
	Ports       []*ServicePortInfo
	// contains filtered or unexported fields
}

func NewServiceInfo

func NewServiceInfo(service *v1.Service) *ServiceInfo

func (*ServiceInfo) GetSelector

func (service *ServiceInfo) GetSelector() map[string]string

func (*ServiceInfo) IsIngressHttpPort

func (service *ServiceInfo) IsIngressHttpPort(port uint32) bool

func (*ServiceInfo) Name

func (service *ServiceInfo) Name() string

func (*ServiceInfo) Namespace

func (service *ServiceInfo) Namespace() string

func (*ServiceInfo) Protocol

func (svc *ServiceInfo) Protocol(port uint32) int

func (*ServiceInfo) String

func (service *ServiceInfo) String() string

func (*ServiceInfo) Type

func (service *ServiceInfo) Type() ResourceType

type ServicePortInfo

type ServicePortInfo struct {
	Port       uint32
	TargetPort uint32
	Name       string
}

Jump to

Keyboard shortcuts

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