Documentation ¶
Overview ¶
Package resources contains various utilities for dealing with Kubernetes resources.
Index ¶
- func GetScaleResource(ctx context.Context, namespace string, ref corev1.ObjectReference, ...) (*pav1alpha1.PodScalable, error)
- func NotReadyAddressCount(endpoints *corev1.Endpoints) int
- func ReadyAddressCount(endpoints *corev1.Endpoints) int
- func ScaleResourceArguments(ref corev1.ObjectReference) (gvr *schema.GroupVersionResource, name string, err error)
- type EndpointsCounter
- type PodAccessor
- func (pa PodAccessor) NotReadyCount() (int, error)
- func (pa PodAccessor) PodCountsByState() (ready, notReady, pending, terminating int, err error)
- func (pa PodAccessor) PodIPsByAge() ([]string, error)
- func (pa PodAccessor) PodIPsSplitByAge(cutOff time.Duration, now time.Time) (older, younger []string, err error)
- func (pa PodAccessor) ProcessPods(pt PodTransformer, pfs ...PodFilter) error
- func (pa PodAccessor) ReadyCount() (int, error)
- type PodFilter
- type PodTransformer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetScaleResource ¶ added in v0.7.0
func GetScaleResource(ctx context.Context, namespace string, ref corev1.ObjectReference, psInformerFactory duck.InformerFactory) (*pav1alpha1.PodScalable, error)
GetScaleResource returns the current scale resource for the PA. TODO(markusthoemmes): We shouldn't need to pass namespace here.
func NotReadyAddressCount ¶ added in v0.13.0
NotReadyAddressCount returns the total number of not ready addresses for the given endpoint.
func ReadyAddressCount ¶
ReadyAddressCount returns the total number of addresses ready for the given endpoint.
func ScaleResourceArguments ¶ added in v0.7.0
func ScaleResourceArguments(ref corev1.ObjectReference) (gvr *schema.GroupVersionResource, name string, err error)
ScaleResourceArguments returns the GroupVersionResource and resource name from an ObjectReference.
Types ¶
type EndpointsCounter ¶ added in v0.13.0
EndpointsCounter provides a count of currently ready and notReady pods. This information, among other places, is used by UniScaler implementations to make scaling decisions. The interface prevents the UniScaler from needing to know how counts are performed. The int return value represents the number of pods that are ready to handle incoming requests. The error value is returned if the EndpointsCounter is unable to calculate a value.
func NewScopedEndpointsCounter ¶ added in v0.7.0
func NewScopedEndpointsCounter(lister corev1listers.EndpointsLister, namespace, serviceName string) EndpointsCounter
NewScopedEndpointsCounter creates a EndpointsCounter that uses a count of endpoints for a namespace/serviceName as the value of ready pods. The values returned by ReadyCount() will vary over time. lister is used to retrieve endpoints for counting with the scope of namespace/serviceName.
type PodAccessor ¶ added in v0.15.0
type PodAccessor struct {
// contains filtered or unexported fields
}
PodAccessor provides access to various dimensions of pods listing and querying for a given bound revision.
func NewPodAccessor ¶ added in v0.15.0
func NewPodAccessor(lister corev1listers.PodLister, namespace, revisionName string) PodAccessor
NewPodAccessor creates a PodAccessor implementation that counts pods for a namespace/revision.
func (PodAccessor) NotReadyCount ¶ added in v0.16.0
func (pa PodAccessor) NotReadyCount() (int, error)
NotReadyCount implements EndpointsCounter.
func (PodAccessor) PodCountsByState ¶ added in v0.17.0
func (pa PodAccessor) PodCountsByState() (ready, notReady, pending, terminating int, err error)
PodCountsByState returns number of pods for the revision grouped by their state, that is of interest to knative (e.g. ignoring failed or terminated pods).
func (PodAccessor) PodIPsByAge ¶ added in v0.15.0
func (pa PodAccessor) PodIPsByAge() ([]string, error)
PodIPsByAge returns the list of running pods (terminating and non-running are excluded) IP addresses, sorted descending by pod age.
func (PodAccessor) PodIPsSplitByAge ¶ added in v0.17.0
func (pa PodAccessor) PodIPsSplitByAge(cutOff time.Duration, now time.Time) (older, younger []string, err error)
PodIPsSplitByAge returns all the ready Pod IPs in two lists: older than cutoff and younger than cutoff.
func (PodAccessor) ProcessPods ¶ added in v0.17.0
func (pa PodAccessor) ProcessPods(pt PodTransformer, pfs ...PodFilter) error
ProcessPods filters all the pods using provided pod filters and then if the pod is selected, applies the transformer to it.
func (PodAccessor) ReadyCount ¶ added in v0.16.0
func (pa PodAccessor) ReadyCount() (int, error)
ReadyCount implements EndpointsCounter.
type PodFilter ¶ added in v0.17.0
PodFilter provides a way to filter pods for a revision. Returning true, means that pod should be kept.
type PodTransformer ¶ added in v0.17.0
PodTransformer provides a way to do something with the pod that has been selected by all the filters. For example pod transformer may extract a field and store it in internal state.