Documentation ¶
Index ¶
- type BeforeStartHandle
- type ClusterCfgInfo
- type ClusterConfigurationManager
- type ClusterEventHandler
- type Controller
- type ControllerRuntimeManagerResource
- type Event
- type EventHandler
- type EventRecorder
- type EventReonciler
- type EventRequest
- type KubeConfigType
- type KubernetesResource
- type Metrics
- type MingleClient
- type MingleProxyClient
- type MultiClientOperate
- type MultiMingleClient
- type MultiMingleResource
- type MultiProxyClient
- type NeedRequeue
- type ObjectTransformFunc
- type Predicate
- type Reconciler
- type ResourceOperate
- type SetKubeRestConfig
- type WorkQueue
- type WrapNamespacedName
- type WrapReconciler
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BeforeStartHandle ¶
type BeforeStartHandle func(ctx context.Context, cli MingleClient) error
BeforeStartHandle before Start exec this handle registry informer, when multi cluster manager add new cluster should record before handle, returns error will not start ctx => use single context can bound handle life cycle with client
type ClusterCfgInfo ¶
type ClusterCfgInfo interface { // GetName return cluster Name GetName() string // GetKubeConfigType return kubeconfig type GetKubeConfigType() KubeConfigType // GetKubeConfig return kubeconfig such as file path or rawstring, reference KubeConfigType GetKubeConfig() string // GetKubeContext return kubeconfig context // if kubeconfig have multi cluster info, use context choice one cluster connect GetKubeContext() string }
ClusterCfgInfo clusterconfiguration info
type ClusterConfigurationManager ¶
type ClusterConfigurationManager interface { // GetAll return all need connect kubernetes cluster // return clusterconfiguration slice and error // if first get 3 clusterinfo, such as a, b, c // second get 2 clusterinfo, such as a, b, will means have one cluster (c) should be shutdown GetAll() ([]ClusterCfgInfo, error) }
ClusterConfigurationManager clusterconfiguration manager
type ClusterEventHandler ¶
type ClusterEventHandler interface { OnAdd(ctx context.Context, cli MingleClient) OnDelete(ctx context.Context, cli MingleClient) }
ClusterEventHandler cluster event handler
type Controller ¶
type Controller interface { // Watch takes events provided by a Source and uses the EventHandler to // enqueue reconcile.Requests in response to the events. // // Watch may be provided one or more Predicates to filter events before // they are given to the EventHandler. Events will be passed to the // EventHandler if all provided Predicates evaluate to true. Watch(src rtclient.Object, queue WorkQueue, handler EventHandler, predicates ...Predicate) error }
Controller implements a Kubernetes API. A Controller manages a work queue fed reconcile.Requests from source.Sources. Work is performed through the reconcile.Reconcile for each enqueued item. Work typically is reads and writes Kubernetes objectes to make the system state match the state specified in the object Spec.
type ControllerRuntimeManagerResource ¶
type ControllerRuntimeManagerResource interface { // GetCtrlRtManager return controller-runtime manager object GetCtrlRtManager() rtmanager.Manager // GetCtrlRtCache return controller-runtime cache object GetCtrlRtCache() rtcache.Cache // GetCtrlRtClient return controller-runtime client GetCtrlRtClient() rtclient.Client }
ControllerRuntimeManagerResource controller-runtime manager resource
type EventHandler ¶
type EventHandler interface { // Create is called in response to an create event - e.g. Pod Creation. Create(obj rtclient.Object, queue WorkQueue) // Update is called in response to an update event - e.g. Pod Updated. Update(oldObj, newObj rtclient.Object, queue WorkQueue) // Delete is called in response to a delete event - e.g. Pod Deleted. Delete(obj rtclient.Object, queue WorkQueue) // Generic is called in response to an event of an unknown type or a synthetic event triggered as a cron or // external trigger request - e.g. reconcile Autoscaling, or a Webhook. Generic(obj rtclient.Object, queue WorkQueue) }
EventHandler deal event handler
type EventRecorder ¶
type EventRecorder interface { // Event constructs an event from the given information and puts it in the queue for sending. // 'object' is the object this event is about. Event will make a reference-- or you may also // pass a reference to the object directly. // 'type' of this event, and can be one of Normal, Warning. New types could be added in future // 'reason' is the reason this event is generated. 'reason' should be short and unique; it // should be in UpperCamelCase format (starting with a capital letter). "reason" will be used // to automate handling of events, so imagine people writing switch statements to handle them. // You want to make that easy. // 'message' is intended to be human readable. // // The resulting event will be created in the same namespace as the reference object. Event(object runtime.Object, eventtype, reason, message string) // Eventf is just like Event, but with Sprintf for the message field. Eventf(object runtime.Object, eventtype, reason, messageFmt string, args ...interface{}) // AnnotatedEventf is just like eventf, but with annotations attached AnnotatedEventf(object runtime.Object, annotations map[string]string, eventtype, reason, messageFmt string, args ...interface{}) }
EventRecorder knows how to record events on behalf of an EventSource.
type EventReonciler ¶
type EventReonciler interface { // OnAdd is called when an object is added. OnAdd(ctx context.Context, qname string, obj interface{}) (requeue NeedRequeue, after time.Duration, err error) // OnUpdate is called when an object is modified. Note that oldObj is the // last known state of the object-- it is possible that several changes // were combined together, so you can't use this to see every single // change. OnUpdate is also called when a re-list happens, and it will // get called even if nothing changed. This is useful for periodically // evaluating or syncing something. OnUpdate(ctx context.Context, qname string, oldObj, newObj interface{}) (requeue NeedRequeue, after time.Duration, err error) // OnDelete will get the final state of the item if it is known, otherwise // it will get an object of type DeletedFinalStateUnknown. This can // happen if the watch is closed and misses the delete event and we don't // notice the deletion until the subsequent re-list. OnDelete(ctx context.Context, qname string, obj interface{}) (requeue NeedRequeue, after time.Duration, err error) }
EnhanceResourceEventReconciler interface, warpper an ResourceEventHandler qname is queue name, obj raw resource which add watched. returns requeue, after, error 1. if error is not empty, will readd ratelimit queue 2. if after > 0, will add queue after `after` time 3. if requeue is true, readd ratelimit queue
type EventRequest ¶
type EventRequest struct { EventType Event OldResource interface{} NewResource interface{} }
type KubeConfigType ¶
type KubeConfigType string
KubeConfigType kubeconfig type
const ( KubeConfigTypeFile KubeConfigType = "File" KubeConfigTypeRawString KubeConfigType = "RawString" KubeConfigTypeInCluster KubeConfigType = "InCluster" )
KubeConfigTypeFile file KubeConfigTypeRawString rawstring
type KubernetesResource ¶
type KubernetesResource interface { // GetRestConfig return Kubernetes rest Config GetKubeRestConfig() *rest.Config // GetKubeInterface return Kubernetes Interface. // kubernetes.ClientSet impl kubernetes.Interface GetKubeInterface() kubernetes.Interface // GetDynamicInterface return dynamic Interface. // dynamic.ClientSet impl dynamic.Interface GetDynamicInterface() dynamic.Interface }
KubernetesResource Kubernetes object operate
type Metrics ¶
type Metrics interface { // Counter creates or returns a prometheus counter by name // if the key is registered by other interface, it will return nil // Counter: invoke CounterWithLabelsWithError(name, nil) and ignore error // CounterWithLabels: invoke CounterWithLabelsWithError(name, dynamicLables) and ignore error Counter(name string) prometheus.Counter CounterWithLabelsWithError(name string, dynamicLabels map[string]string) (prometheus.Counter, error) CounterWithLabels(name string, dynamicLabels map[string]string) prometheus.Counter // Gauge creates or returns a prometheus gauge by key // if the key is registered by other interface, it will return nil // Gauge: invoke GaugeWithLabelsWithError(name, nil) and ignore error // GaugeWithLabels: invoke GaugeWithLabelsWithError(name, dynamicLables) and ignore error Gauge(key string) prometheus.Gauge GaugeWithLabels(name string, dynamicLabels map[string]string) prometheus.Gauge GaugeWithLabelsWithError(name string, dynamicLabels map[string]string) (prometheus.Gauge, error) // Histogram creates or returns a prometheus histogram by key // if the key is registered by other interface, it will be return nil // Histogram: invoke HistogramWithLabelsWithError(name, buckets, nil) and ignore error // HistogramWithLabels: invoke HistogramWithLabelsWithError(name, buckets, dynamicLables) and ignore error Histogram(key string, buckets []float64) prometheus.Histogram HistogramWithLabels(name string, buckets []float64, dynamicLabels map[string]string) prometheus.Histogram HistogramWithLabelsWithError(name string, buckets []float64, dynamicLabels map[string]string) (prometheus.Histogram, error) // Summary creates or returns a summary histogram by key, objectives default 50%, 90% 95% and 99% // if the key is registered by other interface, it will be return nil // Summary: invoke SummaryWithLabelsWithError(name, objectives, nil) and ignore error // SummaryWithLables: invoke SummaryWithLabelsWithError(name, objectives, dynamicLables) and ignore error Summary(key string, objectives map[float64]float64) prometheus.Summary SummaryWithLables(name string, objectives map[float64]float64, dynamicLabels map[string]string) prometheus.Summary SummaryWithLabelsWithError(name string, objectives map[float64]float64, dynamicLabels map[string]string) (prometheus.Summary, error) // UnregisterAll unregister all metrics. (Mostly for testing.) UnregisterAll() // Delete With metricsVec, not unregister metrics DeleteWithLabels(name string, labels map[string]string) bool }
Metrics is a wrapper interface for prometheus
type MingleClient ¶
type MingleClient interface { ResourceOperate EventRecorder // if dissatisfy can use this interface get Kubernetes resource KubernetesResource // if dissatisfy can use this interface get controller-runtime manager resource ControllerRuntimeManagerResource Controller // Start client and blocks until the context is cancelled // Returns an error if there is an error starting Start(ctx context.Context) error // Stop stop mingle client, just use with multiclient, not recommend use direct Stop() // IsConnected return connected status IsConnected() bool // GetClusterCfgInfo returns cluster configuration info GetClusterCfgInfo() ClusterCfgInfo }
MingleClient mingle client wrap controller-runtime manager
type MingleProxyClient ¶
type MingleProxyClient interface { KubernetesResource // GetRuntimeClient() return controller runtime client GetRuntimeClient() rtclient.Client // GetClusterCfgInfo returns cluster configuration info GetClusterCfgInfo() ClusterCfgInfo }
type MultiClientOperate ¶
type MultiClientOperate interface { // GetWithName returns MingleClient object with name GetWithName(name string) (MingleClient, error) // GetConnectedWithName returns MingleClient object with name and status is connected GetConnectedWithName(name string) (MingleClient, error) // GetAll returns all MingleClient GetAll() []MingleClient // GetAllConnected returns all MingleClient which status is connected GetAllConnected() []MingleClient // RegistryBeforeStartHandler registry BeforeStartHandle RegistryBeforeStartHandler(handler BeforeStartHandle) }
MultiClientOperate multi client operate
type MultiMingleClient ¶
type MultiMingleClient interface { MultiMingleResource MultiClientOperate Controller // FetchClientOnce use GetAll function get clusterconfigurationmanager list and rebuild clusterClientMap FetchClientInfoOnce() error // AddClusterEventHandler subscription client add/delete event AddClusterEventHandler(handler ClusterEventHandler) // HasSynced return true if all mingleclient and all informers underlying store has synced // !import if informerlist is empty, will return true HasSynced() bool // Start multiclient and blocks until the context is cancelled // Returns an error if there is an error starting Start(ctx context.Context) error }
MultiMingleClient multi mingleclient
type MultiMingleResource ¶
type MultiMingleResource interface { // AddResourceEventHandler loop each mingleclient invoke AddResourceEventHandler AddResourceEventHandler(obj rtclient.Object, handler cache.ResourceEventHandler) error // TriggerSync just trigger each mingleclient cache resource without handler TriggerSync(obj rtclient.Object) error // SetIndexField loop each mingleclient invoke SetIndexField SetIndexField(obj rtclient.Object, field string, extractValue rtclient.IndexerFunc) error }
MultiMingleResource multi MingleClient Resource
type MultiProxyClient ¶
type MultiProxyClient interface {
GetAll() []MingleProxyClient
}
MultiProxyClient multi proxy client
type NeedRequeue ¶
type NeedRequeue bool
NeedRequeue need requeue
const ( Requeue NeedRequeue = true Done NeedRequeue = false )
Requeue requeue last Done mark this step don't need requeue
type ObjectTransformFunc ¶
ObjectTransformFunc EventHandler transform object
type Predicate ¶
type Predicate interface { // Create returns true if the Create event should be processed Create(obj rtclient.Object) bool // Delete returns true if the Delete event should be processed Delete(obj rtclient.Object) bool // Update returns true if the Update event should be processed Update(oldObj, newObj rtclient.Object) bool // Generic returns true if the Generic event should be processed Generic(obj rtclient.Object) bool }
Predicate filters events before enqueuing the keys.
type Reconciler ¶
type Reconciler interface { // Reconcile request name and namespace // returns requeue, after, error // 1. if error is not empty, will readd ratelimit queue // 2. if after > 0, will add queue after `after` time // 3. if requeue is true, readd ratelimit queue Reconcile(ctx context.Context, req types.NamespacedName) (requeue NeedRequeue, after time.Duration, err error) }
Reconciler interface, define Reconcile handle
type ResourceOperate ¶
type ResourceOperate interface { // GetInformer fetches or constructs an informer for the given object that corresponds to a single // API kind and resource. GetInformer(obj rtclient.Object) (rtcache.Informer, error) // AddResourceEventHandler // 1. GetInformer // 2. Adds an event handler to the shared informer using the shared informer's resync // period. Events to a single handler are delivered sequentially, but there is no coordination // between different handlers. AddResourceEventHandler(obj rtclient.Object, handler cache.ResourceEventHandler) error // IndexFields adds an index with the given field name on the given object type // by using the given function to extract the value for that field. If you want // compatibility with the Kubernetes API server, only return one key, and only use // fields that the API server supports. Otherwise, you can return multiple keys, // and "equality" in the field selector means that at least one key matches the value. // The FieldIndexer will automatically take care of indexing over namespace // and supporting efficient all-namespace queries. SetIndexField(obj rtclient.Object, field string, extractValue rtclient.IndexerFunc) error // HasSynced return true if all informers underlying store has synced // !import if informerlist is empty, will return true HasSynced() bool // Get retrieves an obj for the given object key from the Kubernetes Cluster with timeout. // obj must be a struct pointer so that obj can be updated with the response // returned by the Server. Get(key ktypes.NamespacedName, obj rtclient.Object) error // Create saves the object obj in the Kubernetes cluster with timeout. Create(obj rtclient.Object, opts ...rtclient.CreateOption) error // Delete deletes the given obj from Kubernetes cluster with timeout. Delete(obj rtclient.Object, opts ...rtclient.DeleteOption) error // Update updates the given obj in the Kubernetes cluster with timeout. obj must be a // struct pointer so that obj can be updated with the content returned by the Server. Update(obj rtclient.Object, opts ...rtclient.UpdateOption) error // Update updates the fields corresponding to the status subresource for the // given obj with timeout. obj must be a struct pointer so that obj can be updated // with the content returned by the Server. StatusUpdate(obj rtclient.Object, opts ...rtclient.SubResourceUpdateOption) error // Patch patches the given obj in the Kubernetes cluster with timeout. obj must be a // struct pointer so that obj can be updated with the content returned by the Server. Patch(obj rtclient.Object, patch rtclient.Patch, opts ...rtclient.PatchOption) error // DeleteAllOf deletes all objects of the given type matching the given options with timeout. DeleteAllOf(obj rtclient.Object, opts ...rtclient.DeleteAllOfOption) error // List retrieves list of objects for a given namespace and list options. On a // successful call, Items field in the list will be populated with the // result returned from the server. List(obj rtclient.ObjectList, opts ...rtclient.ListOption) error }
ResourceOperate Kubernetes resource CRUD operate.
type SetKubeRestConfig ¶
SetKubeRestConfig set rest config such as QPS Burst
type WrapNamespacedName ¶
type WrapNamespacedName struct { types.NamespacedName // queue name QName string }
WrapNamespacedName wrap standard namespacedname with queue name
type WrapReconciler ¶
type WrapReconciler interface { // Reconcile request name and namespace // returns requeue, after, error // 1. if error is not empty, will readd ratelimit queue // 2. if after > 0, will add queue after `after` time // 3. if requeue is true, readd ratelimit queue Reconcile(ctx context.Context, req WrapNamespacedName) (requeue NeedRequeue, after time.Duration, err error) }
WrapReconciler interface, define Reconcile handle