Documentation
¶
Overview ¶
Package k8s contains helpers for setting the IngressRoute status
Index ¶
- Constants
- func IsStatusEqual(objA, objB interface{}) bool
- func KindOf(obj interface{}) string
- type Clients
- func (c *Clients) ClientSet() *kubernetes.Clientset
- func (c *Clients) CoordinationClient() *coordinationv1.CoordinationV1Client
- func (c *Clients) DynamicClient() dynamic.Interface
- func (c *Clients) NewDynamicInformerFactory() dynamicinformer.DynamicSharedInformerFactory
- func (c *Clients) NewInformerFactory() informers.SharedInformerFactory
- func (c *Clients) NewInformerFactoryForNamespace(namespace string) informers.SharedInformerFactory
- type Converter
- type DynamicClientHandler
- type FullName
- type InformerSet
- type InformerSyncList
- type Object
- type ServiceStatusLoadBalancerWatcher
- type StatusAddressUpdater
- type StatusCacher
- type StatusClient
- type StatusMutator
- type StatusMutatorFunc
- type StatusUpdate
- type StatusUpdateCacher
- func (suc *StatusUpdateCacher) AddObject(name, namespace string, gvr schema.GroupVersionResource, obj interface{}) bool
- func (suc *StatusUpdateCacher) GetObject(name, namespace string, gvr schema.GroupVersionResource) interface{}
- func (suc *StatusUpdateCacher) Update(name, namespace string, gvr schema.GroupVersionResource, mutator StatusMutator)
- type StatusUpdateHandler
- type StatusUpdateWriter
- type StatusUpdater
- type StatusWriter
- type UnstructuredConverter
Constants ¶
const ( StatusValid = "valid" StatusInvalid = "invalid" StatusOrphaned = "orphaned" )
Variables ¶
This section is empty.
Functions ¶
func IsStatusEqual ¶ added in v1.5.0
func IsStatusEqual(objA, objB interface{}) bool
IsStatusEqual checks that two objects of supported Kubernetes types have equivalent Status structs. Currently supports: networking.k8s.io/ingress/v1beta1
Types ¶
type Clients ¶ added in v1.3.0
type Clients struct {
// contains filtered or unexported fields
}
Clients holds the various API clients required by Contour.
func NewClients ¶ added in v1.3.0
NewClients returns a new set of the various API clients required by Contour using the supplied kubeconfig path, or the cluster environment variables if inCluster is true.
func (*Clients) ClientSet ¶ added in v1.3.0
func (c *Clients) ClientSet() *kubernetes.Clientset
ClientSet returns the Kubernetes Core v1 ClientSet.
func (*Clients) CoordinationClient ¶ added in v1.3.0
func (c *Clients) CoordinationClient() *coordinationv1.CoordinationV1Client
CoordinationClient returns the Kubernets Core v1 coordination client.
func (*Clients) DynamicClient ¶ added in v1.3.0
DynamicClient returns the Dyanmic client.
func (*Clients) NewDynamicInformerFactory ¶ added in v1.3.0
func (c *Clients) NewDynamicInformerFactory() dynamicinformer.DynamicSharedInformerFactory
NewDynamicInformerFactory returns a new DynamicSharedInformerFactory for use with any registered Kubernetes API type.
func (*Clients) NewInformerFactory ¶ added in v1.3.0
func (c *Clients) NewInformerFactory() informers.SharedInformerFactory
NewInformerFactory returns a new SharedInformerFactory for the core Kubernetes API types.
func (*Clients) NewInformerFactoryForNamespace ¶ added in v1.3.0
func (c *Clients) NewInformerFactoryForNamespace(namespace string) informers.SharedInformerFactory
NewInformerFactoryForNamespace returns a new SharedInformerFactory for the core Kubernetes API types for the namespace supplied.
type Converter ¶ added in v1.2.0
type Converter interface { FromUnstructured(obj interface{}) (interface{}, error) ToUnstructured(obj interface{}) (*unstructured.Unstructured, error) }
type DynamicClientHandler ¶ added in v1.2.0
type DynamicClientHandler struct { // Next is the next handler in the chain. Next cache.ResourceEventHandler // Converter is the registered converter. Converter Converter Logger logrus.FieldLogger }
DynamicClientHandler converts *unstructured.Unstructured from the k8s dynamic client to the types registered with the supplied Converter and forwards them to the next Handler in the chain.
func (*DynamicClientHandler) OnAdd ¶ added in v1.2.0
func (d *DynamicClientHandler) OnAdd(obj interface{})
func (*DynamicClientHandler) OnDelete ¶ added in v1.2.0
func (d *DynamicClientHandler) OnDelete(obj interface{})
func (*DynamicClientHandler) OnUpdate ¶ added in v1.2.0
func (d *DynamicClientHandler) OnUpdate(oldObj, newObj interface{})
type FullName ¶ added in v1.4.0
type FullName struct {
Name, Namespace string
}
FullName holds the name and namespace of a Kubernetes object.
func ToFullName ¶ added in v1.4.0
ToFullName returns the FullName of any given Kubernetes object.
type InformerSet ¶ added in v1.4.0
type InformerSet struct {
Informers gvrmap
}
InformerSet stores a table of Kubernetes GVR objects to their associated informers.
func DefaultInformerSet ¶ added in v1.4.0
func DefaultInformerSet(inffactory dynamicinformer.DynamicSharedInformerFactory, serviceAPIs bool) InformerSet
DefaultInformerSet creates a new InformerSet lookup table and populates with the default GVRs that Contour will try to watch.
type InformerSyncList ¶ added in v1.3.0
type InformerSyncList struct {
// contains filtered or unexported fields
}
InformerSyncList holds the functions to call to check that an informer is synced.
func (*InformerSyncList) RegisterInformer ¶ added in v1.4.0
func (sl *InformerSyncList) RegisterInformer(inf cache.SharedIndexInformer, handler cache.ResourceEventHandler)
RegisterInformer adds the sync function from an informer to InformerSyncList and calls the informers AddEventHandler method.
func (*InformerSyncList) WaitForSync ¶ added in v1.3.0
func (sl *InformerSyncList) WaitForSync(stop <-chan struct{}) error
WaitForSync ensures that all the informers in the InformerSyncList are synced before returning.
type Object ¶ added in v1.4.0
type Object interface { metav1.ObjectMetaAccessor }
Object is any Kubernetes object that has an ObjectMeta. TODO(youngnick): Review references to this and replace them with straight metav1.ObjectMetaAccessor calls if we can.
type ServiceStatusLoadBalancerWatcher ¶ added in v1.4.0
type ServiceStatusLoadBalancerWatcher struct { ServiceName string LBStatus chan v1.LoadBalancerStatus }
ServiceStatusLoadBalancerWatcher implements ResourceEventHandler and watches for changes to the status.loadbalancer field Note that we specifically *don't* inspect inside the struct, as sending empty values is desirable to clear the status.
func (*ServiceStatusLoadBalancerWatcher) OnAdd ¶ added in v1.4.0
func (s *ServiceStatusLoadBalancerWatcher) OnAdd(obj interface{})
func (*ServiceStatusLoadBalancerWatcher) OnDelete ¶ added in v1.4.0
func (s *ServiceStatusLoadBalancerWatcher) OnDelete(obj interface{})
func (*ServiceStatusLoadBalancerWatcher) OnUpdate ¶ added in v1.4.0
func (s *ServiceStatusLoadBalancerWatcher) OnUpdate(oldObj, newObj interface{})
type StatusAddressUpdater ¶ added in v1.5.0
type StatusAddressUpdater struct { Logger logrus.FieldLogger LBStatus v1.LoadBalancerStatus IngressClass string StatusUpdater StatusUpdater Converter Converter }
StatusAddressUpdater observes informer OnAdd and OnUpdate events and updates the ingress.status.loadBalancer field on all Ingress objects that match the ingress class (if used). Note that this is intended to handle updating the status.loadBalancer struct only, not more general status updates. That's a job for the StatusUpdater.
func (*StatusAddressUpdater) OnAdd ¶ added in v1.5.0
func (s *StatusAddressUpdater) OnAdd(obj interface{})
func (*StatusAddressUpdater) OnDelete ¶ added in v1.5.0
func (s *StatusAddressUpdater) OnDelete(obj interface{})
func (*StatusAddressUpdater) OnUpdate ¶ added in v1.5.0
func (s *StatusAddressUpdater) OnUpdate(oldObj, newObj interface{})
type StatusCacher ¶ added in v1.1.0
type StatusCacher struct {
// contains filtered or unexported fields
}
StatusCacher keeps a cache of the latest status updates for Kubernetes objects.
func (*StatusCacher) Delete ¶ added in v1.1.0
func (c *StatusCacher) Delete(obj interface{})
Delete removes an object from the status cache.
func (*StatusCacher) GetStatus ¶ added in v1.1.0
func (c *StatusCacher) GetStatus(obj interface{}) (*projcontour.Status, error)
GetStatus returns the status (if any) for this given object.
func (*StatusCacher) IsCacheable ¶ added in v1.2.0
func (c *StatusCacher) IsCacheable(obj interface{}) bool
IsCacheable returns whether this type of object can be stored in the status cache.
func (*StatusCacher) SetStatus ¶ added in v1.1.0
func (c *StatusCacher) SetStatus(status, desc string, obj interface{}) error
SetStatus sets the IngressRoute status field to an Valid or Invalid status
type StatusClient ¶ added in v1.1.0
type StatusClient interface { SetStatus(status string, desc string, obj interface{}) error GetStatus(obj interface{}) (*projcontour.Status, error) }
StatusClient updates the Status on a Kubernetes object.
type StatusMutator ¶ added in v1.5.0
type StatusMutator interface {
Mutate(obj interface{}) interface{}
}
StatusMutator is an interface to hold mutator functions for status updates.
type StatusMutatorFunc ¶ added in v1.5.0
type StatusMutatorFunc func(interface{}) interface{}
StatusMutatorFunc is a function adaptor for StatusMutators.
func (StatusMutatorFunc) Mutate ¶ added in v1.5.0
func (m StatusMutatorFunc) Mutate(old interface{}) interface{}
Mutate adapts the StatusMutatorFunc to fit through the StatusMutator inferface.
type StatusUpdate ¶ added in v1.5.0
type StatusUpdate struct { FullName FullName Resource schema.GroupVersionResource Mutator StatusMutator }
StatusUpdate contains an all the information needed to change an object's status to perform a specific update. Send down a channel to the goroutine that actually writes the changes back.
type StatusUpdateCacher ¶ added in v1.5.0
type StatusUpdateCacher struct {
// contains filtered or unexported fields
}
StatusUpdateCacher takes status updates and applies them to a cache, to be used for testing.
func (*StatusUpdateCacher) AddObject ¶ added in v1.5.0
func (suc *StatusUpdateCacher) AddObject(name, namespace string, gvr schema.GroupVersionResource, obj interface{}) bool
func (*StatusUpdateCacher) GetObject ¶ added in v1.5.0
func (suc *StatusUpdateCacher) GetObject(name, namespace string, gvr schema.GroupVersionResource) interface{}
GetObject allows retrieval of objects from the cache.
func (*StatusUpdateCacher) Update ¶ added in v1.5.0
func (suc *StatusUpdateCacher) Update(name, namespace string, gvr schema.GroupVersionResource, mutator StatusMutator)
Update updates the cache with the requested update.
type StatusUpdateHandler ¶ added in v1.5.0
type StatusUpdateHandler struct { Log logrus.FieldLogger Clients *Clients UpdateChannel chan StatusUpdate LeaderElected chan struct{} IsLeader bool Converter *UnstructuredConverter }
StatusUpdateHandler holds the details required to actually write an Update back to the referenced object.
func (*StatusUpdateHandler) Start ¶ added in v1.5.0
func (suh *StatusUpdateHandler) Start(stop <-chan struct{}) error
Start runs the goroutine to perform status writes. Until the Contour is elected leader, will drop updates on the floor.
func (*StatusUpdateHandler) Writer ¶ added in v1.5.0
func (suh *StatusUpdateHandler) Writer() StatusUpdater
Writer retrieves the interface that should be used to write to the StatusUpdateHandler.
type StatusUpdateWriter ¶ added in v1.5.0
type StatusUpdateWriter struct {
UpdateChannel chan StatusUpdate
}
StatusUpdateWriter takes status updates and sends these to the StatusUpdateHandler via a channel.
func (*StatusUpdateWriter) Update ¶ added in v1.5.0
func (suw *StatusUpdateWriter) Update(name, namespace string, gvr schema.GroupVersionResource, mutator StatusMutator)
Update sends the update to the StatusUpdateHandler for delivery to the apiserver. The StatusUpdateHandler will retrieve the object, update it with the mutator, then put it back if it's different.
type StatusUpdater ¶ added in v1.5.0
type StatusUpdater interface {
Update(name, namespace string, gvr schema.GroupVersionResource, mutator StatusMutator)
}
StatusUpdater describes an interface to send status updates somewhere.
type StatusWriter ¶ added in v1.1.0
StatusWriter updates the object's Status field.
func (*StatusWriter) GetStatus ¶ added in v1.1.0
func (irs *StatusWriter) GetStatus(obj interface{}) (*projcontour.Status, error)
GetStatus is not implemented for StatusWriter.
func (*StatusWriter) SetStatus ¶ added in v1.1.0
func (irs *StatusWriter) SetStatus(status, desc string, existing interface{}) error
SetStatus sets the IngressRoute status field to an Valid or Invalid status
type UnstructuredConverter ¶ added in v1.2.0
type UnstructuredConverter struct {
// contains filtered or unexported fields
}
UnstructuredConverter handles conversions between unstructured.Unstructured and Contour types
func NewUnstructuredConverter ¶ added in v1.2.0
func NewUnstructuredConverter() (*UnstructuredConverter, error)
NewUnstructuredConverter returns a new UnstructuredConverter initialized
func (*UnstructuredConverter) FromUnstructured ¶ added in v1.5.0
func (c *UnstructuredConverter) FromUnstructured(obj interface{}) (interface{}, error)
FromUnstructured converts an unstructured.Unstructured to typed struct. If obj is not an unstructured.Unstructured it is returned without further processing.
func (*UnstructuredConverter) ToUnstructured ¶ added in v1.5.0
func (c *UnstructuredConverter) ToUnstructured(obj interface{}) (*unstructured.Unstructured, error)
ToUnstructured converts the supplied object to Unstructured, provided it's one of the types registered in the UnstructuredConverter's Scheme.