Documentation ¶
Overview ¶
Package kubernetes is a generated GoMock package.
Package kubernetes implements the Kubernetes Controller interface to monitor and retrieve information regarding Kubernetes resources such as Namespaces, Services, Pods, Endpoints, and ServiceAccounts.
Index ¶
- Constants
- func DialerToPod(conf *rest.Config, clientSet kubernetes.Interface, podName string, ...) (httpstream.Dialer, error)
- func GetAppProtocolFromPortName(portName string) string
- func GetHostnamesForService(service *corev1.Service, sameNamespace bool) []string
- func GetKubernetesEventHandlers(informerName, providerName string, shouldObserve observeFilter, ...) cache.ResourceEventHandlerFuncs
- func GetKubernetesServerVersionNumber(kubeClient kubernetes.Interface) ([]int, error)
- func GetServiceFromHostname(host string) string
- func NamespacedNameFrom(name string) (types.NamespacedName, error)
- func PatchSecretHandler(kubeClient kubernetes.Interface) chan struct{}
- type Client
- func (c Client) GetEndpoints(svc service.MeshService) (*corev1.Endpoints, error)
- func (c Client) GetNamespace(ns string) *corev1.Namespace
- func (c Client) GetService(svc service.MeshService) *corev1.Service
- func (c Client) IsMetricsEnabled(pod *corev1.Pod) bool
- func (c Client) IsMonitoredNamespace(namespace string) bool
- func (c Client) ListMonitoredNamespaces() ([]string, error)
- func (c Client) ListPods() []*corev1.Pod
- func (c Client) ListServiceAccounts() []*corev1.ServiceAccount
- func (c Client) ListServiceIdentitiesForService(svc service.MeshService) ([]identity.K8sServiceAccount, error)
- func (c Client) ListServices() []*corev1.Service
- type Controller
- type EventType
- type EventTypes
- type InformerKey
- type MockController
- func (m *MockController) EXPECT() *MockControllerMockRecorder
- func (m *MockController) GetEndpoints(arg0 service.MeshService) (*v1.Endpoints, error)
- func (m *MockController) GetNamespace(arg0 string) *v1.Namespace
- func (m *MockController) GetService(arg0 service.MeshService) *v1.Service
- func (m *MockController) IsMetricsEnabled(arg0 *v1.Pod) bool
- func (m *MockController) IsMonitoredNamespace(arg0 string) bool
- func (m *MockController) ListMonitoredNamespaces() ([]string, error)
- func (m *MockController) ListPods() []*v1.Pod
- func (m *MockController) ListServiceAccounts() []*v1.ServiceAccount
- func (m *MockController) ListServiceIdentitiesForService(arg0 service.MeshService) ([]identity.K8sServiceAccount, error)
- func (m *MockController) ListServices() []*v1.Service
- type MockControllerMockRecorder
- func (mr *MockControllerMockRecorder) GetEndpoints(arg0 interface{}) *gomock.Call
- func (mr *MockControllerMockRecorder) GetNamespace(arg0 interface{}) *gomock.Call
- func (mr *MockControllerMockRecorder) GetService(arg0 interface{}) *gomock.Call
- func (mr *MockControllerMockRecorder) IsMetricsEnabled(arg0 interface{}) *gomock.Call
- func (mr *MockControllerMockRecorder) IsMonitoredNamespace(arg0 interface{}) *gomock.Call
- func (mr *MockControllerMockRecorder) ListMonitoredNamespaces() *gomock.Call
- func (mr *MockControllerMockRecorder) ListPods() *gomock.Call
- func (mr *MockControllerMockRecorder) ListServiceAccounts() *gomock.Call
- func (mr *MockControllerMockRecorder) ListServiceIdentitiesForService(arg0 interface{}) *gomock.Call
- func (mr *MockControllerMockRecorder) ListServices() *gomock.Call
- type PortForwarder
Constants ¶
const ( // DefaultKubeEventResyncInterval is the default resync interval for k8s events DefaultKubeEventResyncInterval = 5 * time.Minute )
Variables ¶
This section is empty.
Functions ¶
func DialerToPod ¶ added in v0.8.0
func DialerToPod(conf *rest.Config, clientSet kubernetes.Interface, podName string, namespace string) (httpstream.Dialer, error)
DialerToPod constructs a new httpstream.Dialer to connect to a pod for use with a PortForwarder
func GetAppProtocolFromPortName ¶ added in v0.7.0
GetAppProtocolFromPortName returns the port's application protocol from its name, defaults to 'http' if not specified.
func GetHostnamesForService ¶ added in v0.3.0
GetHostnamesForService returns a list of hostnames over which the service can be accessed within the local cluster. If 'sameNamespace' is set to true, then the shorthand hostnames service and service:port are also returned.
func GetKubernetesEventHandlers ¶
func GetKubernetesEventHandlers(informerName, providerName string, shouldObserve observeFilter, eventTypes EventTypes) cache.ResourceEventHandlerFuncs
GetKubernetesEventHandlers creates Kubernetes events handlers.
func GetKubernetesServerVersionNumber ¶ added in v0.9.0
func GetKubernetesServerVersionNumber(kubeClient kubernetes.Interface) ([]int, error)
GetKubernetesServerVersionNumber returns the Kubernetes server version number in chunks, ex. v1.19.3 => [1, 19, 3]
func GetServiceFromHostname ¶ added in v0.3.0
GetServiceFromHostname returns the service name from its hostname
func NamespacedNameFrom ¶ added in v0.9.2
func NamespacedNameFrom(name string) (types.NamespacedName, error)
NamespacedNameFrom returns the namespaced name for the given name if possible, otherwise an error
func PatchSecretHandler ¶ added in v0.9.0
func PatchSecretHandler(kubeClient kubernetes.Interface) chan struct{}
PatchSecretHandler patches the envoy bootstrap config secrets based on the PodAdd events returns a stop channel which can be used to stop the inner handler
Types ¶
type Client ¶ added in v0.4.0
type Client struct {
// contains filtered or unexported fields
}
Client is a struct for all components necessary to connect to and maintain state of a Kubernetes cluster.
func (Client) GetEndpoints ¶ added in v0.7.0
GetEndpoints returns the endpoint for a given service, otherwise returns nil if not found or error if the API errored out.
func (Client) GetNamespace ¶ added in v0.4.1
GetNamespace returns a Namespace resource if found, nil otherwise.
func (Client) GetService ¶ added in v0.4.0
func (c Client) GetService(svc service.MeshService) *corev1.Service
GetService retrieves the Kubernetes Services resource for the given MeshService
func (Client) IsMetricsEnabled ¶ added in v0.9.1
IsMetricsEnabled returns true if the pod in the mesh is correctly annotated for prometheus scrapping
func (Client) IsMonitoredNamespace ¶ added in v0.4.0
IsMonitoredNamespace returns a boolean indicating if the namespace is among the list of monitored namespaces
func (Client) ListMonitoredNamespaces ¶ added in v0.4.0
ListMonitoredNamespaces returns all namespaces that the mesh is monitoring.
func (Client) ListPods ¶ added in v0.4.1
ListPods returns a list of pods part of the mesh Kubecontroller does not currently segment pod notifications, hence it receives notifications for all k8s Pods.
func (Client) ListServiceAccounts ¶ added in v0.8.0
func (c Client) ListServiceAccounts() []*corev1.ServiceAccount
ListServiceAccounts returns a list of service accounts that are part of monitored namespaces
func (Client) ListServiceIdentitiesForService ¶ added in v0.9.0
func (c Client) ListServiceIdentitiesForService(svc service.MeshService) ([]identity.K8sServiceAccount, error)
ListServiceIdentitiesForService lists ServiceAccounts associated with the given service
func (Client) ListServices ¶ added in v0.4.0
ListServices returns a list of services that are part of monitored namespaces
type Controller ¶ added in v0.4.0
type Controller interface { // ListServices returns a list of all (monitored-namespace filtered) services in the mesh ListServices() []*corev1.Service // ListServiceAccounts returns a list of all (monitored-namespace filtered) service accounts in the mesh ListServiceAccounts() []*corev1.ServiceAccount // GetService returns a corev1 Service representation if the MeshService exists in cache, otherwise nil GetService(svc service.MeshService) *corev1.Service // IsMonitoredNamespace returns whether a namespace with the given name is being monitored // by the mesh IsMonitoredNamespace(string) bool // ListMonitoredNamespaces returns the namespaces monitored by the mesh ListMonitoredNamespaces() ([]string, error) // GetNamespace returns k8s namespace present in cache GetNamespace(ns string) *corev1.Namespace // ListPods returns a list of pods part of the mesh ListPods() []*corev1.Pod // ListServiceIdentitiesForService lists ServiceAccounts associated with the given service ListServiceIdentitiesForService(svc service.MeshService) ([]identity.K8sServiceAccount, error) // GetEndpoints returns the endpoints for a given service, if found GetEndpoints(svc service.MeshService) (*corev1.Endpoints, error) // IsMetricsEnabled returns true if the pod in the mesh is correctly annotated for prometheus scrapping IsMetricsEnabled(*corev1.Pod) bool }
Controller is the controller interface for K8s services
func NewKubernetesController ¶ added in v0.4.0
func NewKubernetesController(kubeClient kubernetes.Interface, meshName string, stop chan struct{}, selectInformers ...InformerKey) (Controller, error)
NewKubernetesController returns a new kubernetes.Controller which means to provide access to locally-cached k8s resources
type EventType ¶
type EventType string
EventType is the type of event we have received from Kubernetes
type EventTypes ¶ added in v0.6.0
type EventTypes struct { Add a.AnnouncementType Update a.AnnouncementType Delete a.AnnouncementType }
EventTypes is a struct helping pass the correct types to GetKubernetesEventHandlers
type InformerKey ¶ added in v0.4.0
type InformerKey string
InformerKey stores the different Informers we keep for K8s resources
const ( // Namespaces lookup identifier Namespaces InformerKey = "Namespaces" // Services lookup identifier Services InformerKey = "Services" // Pods lookup identifier Pods InformerKey = "Pods" // Endpoints lookup identifier Endpoints InformerKey = "Endpoints" // ServiceAccounts lookup identifier ServiceAccounts InformerKey = "ServiceAccounts" )
type MockController ¶ added in v0.4.0
type MockController struct {
// contains filtered or unexported fields
}
MockController is a mock of Controller interface
func NewMockController ¶ added in v0.4.0
func NewMockController(ctrl *gomock.Controller) *MockController
NewMockController creates a new mock instance
func (*MockController) EXPECT ¶ added in v0.4.0
func (m *MockController) EXPECT() *MockControllerMockRecorder
EXPECT returns an object that allows the caller to indicate expected use
func (*MockController) GetEndpoints ¶ added in v0.7.0
func (m *MockController) GetEndpoints(arg0 service.MeshService) (*v1.Endpoints, error)
GetEndpoints mocks base method
func (*MockController) GetNamespace ¶ added in v0.4.1
func (m *MockController) GetNamespace(arg0 string) *v1.Namespace
GetNamespace mocks base method
func (*MockController) GetService ¶ added in v0.4.0
func (m *MockController) GetService(arg0 service.MeshService) *v1.Service
GetService mocks base method
func (*MockController) IsMetricsEnabled ¶ added in v0.9.1
func (m *MockController) IsMetricsEnabled(arg0 *v1.Pod) bool
IsMetricsEnabled mocks base method
func (*MockController) IsMonitoredNamespace ¶ added in v0.4.0
func (m *MockController) IsMonitoredNamespace(arg0 string) bool
IsMonitoredNamespace mocks base method
func (*MockController) ListMonitoredNamespaces ¶ added in v0.4.0
func (m *MockController) ListMonitoredNamespaces() ([]string, error)
ListMonitoredNamespaces mocks base method
func (*MockController) ListPods ¶ added in v0.4.1
func (m *MockController) ListPods() []*v1.Pod
ListPods mocks base method
func (*MockController) ListServiceAccounts ¶ added in v0.8.0
func (m *MockController) ListServiceAccounts() []*v1.ServiceAccount
ListServiceAccounts mocks base method
func (*MockController) ListServiceIdentitiesForService ¶ added in v0.9.0
func (m *MockController) ListServiceIdentitiesForService(arg0 service.MeshService) ([]identity.K8sServiceAccount, error)
ListServiceIdentitiesForService mocks base method
func (*MockController) ListServices ¶ added in v0.4.0
func (m *MockController) ListServices() []*v1.Service
ListServices mocks base method
type MockControllerMockRecorder ¶ added in v0.4.0
type MockControllerMockRecorder struct {
// contains filtered or unexported fields
}
MockControllerMockRecorder is the mock recorder for MockController
func (*MockControllerMockRecorder) GetEndpoints ¶ added in v0.7.0
func (mr *MockControllerMockRecorder) GetEndpoints(arg0 interface{}) *gomock.Call
GetEndpoints indicates an expected call of GetEndpoints
func (*MockControllerMockRecorder) GetNamespace ¶ added in v0.4.1
func (mr *MockControllerMockRecorder) GetNamespace(arg0 interface{}) *gomock.Call
GetNamespace indicates an expected call of GetNamespace
func (*MockControllerMockRecorder) GetService ¶ added in v0.4.0
func (mr *MockControllerMockRecorder) GetService(arg0 interface{}) *gomock.Call
GetService indicates an expected call of GetService
func (*MockControllerMockRecorder) IsMetricsEnabled ¶ added in v0.9.1
func (mr *MockControllerMockRecorder) IsMetricsEnabled(arg0 interface{}) *gomock.Call
IsMetricsEnabled indicates an expected call of IsMetricsEnabled
func (*MockControllerMockRecorder) IsMonitoredNamespace ¶ added in v0.4.0
func (mr *MockControllerMockRecorder) IsMonitoredNamespace(arg0 interface{}) *gomock.Call
IsMonitoredNamespace indicates an expected call of IsMonitoredNamespace
func (*MockControllerMockRecorder) ListMonitoredNamespaces ¶ added in v0.4.0
func (mr *MockControllerMockRecorder) ListMonitoredNamespaces() *gomock.Call
ListMonitoredNamespaces indicates an expected call of ListMonitoredNamespaces
func (*MockControllerMockRecorder) ListPods ¶ added in v0.4.1
func (mr *MockControllerMockRecorder) ListPods() *gomock.Call
ListPods indicates an expected call of ListPods
func (*MockControllerMockRecorder) ListServiceAccounts ¶ added in v0.8.0
func (mr *MockControllerMockRecorder) ListServiceAccounts() *gomock.Call
ListServiceAccounts indicates an expected call of ListServiceAccounts
func (*MockControllerMockRecorder) ListServiceIdentitiesForService ¶ added in v0.9.0
func (mr *MockControllerMockRecorder) ListServiceIdentitiesForService(arg0 interface{}) *gomock.Call
ListServiceIdentitiesForService indicates an expected call of ListServiceIdentitiesForService
func (*MockControllerMockRecorder) ListServices ¶ added in v0.4.0
func (mr *MockControllerMockRecorder) ListServices() *gomock.Call
ListServices indicates an expected call of ListServices
type PortForwarder ¶ added in v0.6.0
type PortForwarder struct {
// contains filtered or unexported fields
}
PortForwarder is a type that implements port forwarding to a pod
func NewPortForwarder ¶ added in v0.6.0
func NewPortForwarder(dialer httpstream.Dialer, portSpec string) (*PortForwarder, error)
NewPortForwarder creates a new port forwarder to a pod
func (*PortForwarder) Done ¶ added in v0.8.0
func (pf *PortForwarder) Done() <-chan struct{}
Done returns a channel that is closed after Stop has been called.
func (*PortForwarder) Start ¶ added in v0.6.0
func (pf *PortForwarder) Start(readyFunc func(pf *PortForwarder) error) error
Start starts the port forwarding and calls the readyFunc callback function when port forwarding is ready
func (*PortForwarder) Stop ¶ added in v0.6.0
func (pf *PortForwarder) Stop()
Stop stops the port forwarding if not stopped already
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package events implements the eventing framework to receive and relay kubernetes events, and a framework to publish events to the Kubernetes API server.
|
Package events implements the eventing framework to receive and relay kubernetes events, and a framework to publish events to the Kubernetes API server. |