Documentation
¶
Overview ¶
nolint:staticcheck
Index ¶
- Constants
- Variables
- func DaemonSet(overrides ...DaemonSetOptions) *appsv1.DaemonSet
- func Deployment(overrides ...DeploymentOptions) *appsv1.Deployment
- func MustMerge[T interface{}](dest T, srcs ...T) T
- func Namespace(overrides ...NamespaceOptions) *corev1.Namespace
- func NamespacedObjectMeta(overrides ...metav1.ObjectMeta) metav1.ObjectMeta
- func Node(overrides ...NodeOptions) *corev1.Node
- func NodeClaim(overrides ...v1.NodeClaim) *v1.NodeClaim
- func NodeClaimAndNode(overrides ...v1.NodeClaim) (*v1.NodeClaim, *corev1.Node)
- func NodeClaimLinkedNode(nodeClaim *v1.NodeClaim) *corev1.Node
- func NodeClaimNodeClassRefFieldIndexer(ctx context.Context) func(cache.Cache) error
- func NodeClaimProviderIDFieldIndexer(ctx context.Context) func(cache.Cache) error
- func NodeClaimsAndNodes(total int, options ...v1.NodeClaim) ([]*v1.NodeClaim, []*corev1.Node)
- func NodeClass(overrides ...v1alpha1.TestNodeClass) *v1alpha1.TestNodeClass
- func NodePool(overrides ...v1.NodePool) *v1.NodePool
- func NodePools(total int, options ...v1.NodePool) []*v1.NodePool
- func NodeProviderIDFieldIndexer(ctx context.Context) func(cache.Cache) error
- func ObjectMeta(overrides ...metav1.ObjectMeta) metav1.ObjectMeta
- func Options(overrides ...OptionsFields) *options.Options
- func PersistentVolume(overrides ...PersistentVolumeOptions) *v1.PersistentVolume
- func PersistentVolumeClaim(overrides ...PersistentVolumeClaimOptions) *v1.PersistentVolumeClaim
- func Pod(overrides ...PodOptions) *v1.Pod
- func PodDisruptionBudget(overrides ...PDBOptions) *policyv1.PodDisruptionBudget
- func Pods(total int, options ...PodOptions) []*v1.Pod
- func ProviderID(base string) string
- func RandomAffinityLabels() map[string]string
- func RandomCPU() resource.Quantity
- func RandomLabelValue() string
- func RandomLabels() map[string]string
- func RandomMemory() resource.Quantity
- func RandomName() string
- func RandomProviderID() string
- func ReplaceRequirements(nodePool *v1.NodePool, reqs ...v1.NodeSelectorRequirementWithMinValues) *v1.NodePool
- func ReplicaSet(overrides ...ReplicaSetOptions) *appsv1.ReplicaSet
- func SetDefaultNodeClassType(nc status.Object)
- func StatefulSet(overrides ...StatefulSetOptions) *appsv1.StatefulSet
- func StorageClass(overrides ...StorageClassOptions) *storagev1.StorageClass
- func TemplateObjectMeta(overrides ...v1.ObjectMeta) v1.ObjectMeta
- func UnschedulablePod(options ...PodOptions) *v1.Pod
- func UnschedulablePods(options PodOptions, num int) []*v1.Pod
- func VolumeAttachment(overrides ...VolumeAttachmentOptions) *storagev1.VolumeAttachment
- func VolumeAttachmentFieldIndexer(ctx context.Context) func(cache.Cache) error
- func WithCRDs(crds ...*apiextensionsv1.CustomResourceDefinition) option.Function[EnvironmentOptions]
- func WithFieldIndexers(fieldIndexers ...func(cache.Cache) error) option.Function[EnvironmentOptions]
- type CacheSyncingClient
- func (c *CacheSyncingClient) Create(ctx context.Context, obj client.Object, opts ...client.CreateOption) error
- func (c *CacheSyncingClient) Delete(ctx context.Context, obj client.Object, opts ...client.DeleteOption) error
- func (c *CacheSyncingClient) DeleteAllOf(ctx context.Context, obj client.Object, opts ...client.DeleteAllOfOption) error
- func (c *CacheSyncingClient) Patch(ctx context.Context, obj client.Object, patch client.Patch, ...) error
- func (c *CacheSyncingClient) Status() client.StatusWriter
- func (c *CacheSyncingClient) Update(ctx context.Context, obj client.Object, opts ...client.UpdateOption) error
- type DaemonSetOptions
- type DeploymentOptions
- type Environment
- type EnvironmentOptions
- type EphemeralVolumeTemplateOptions
- type EventRecorder
- func (e *EventRecorder) Calls(reason string) int
- func (e *EventRecorder) DetectedEvent(msg string) bool
- func (e *EventRecorder) Events() (res []events.Event)
- func (e *EventRecorder) ForEachEvent(f func(evt events.Event))
- func (e *EventRecorder) Publish(evts ...events.Event)
- func (e *EventRecorder) Reset()
- type FeatureGates
- type NamespaceOptions
- type NodeOptions
- type OptionsFields
- type PDBOptions
- type PersistentVolumeClaimOptions
- type PersistentVolumeOptions
- type PodOptions
- func MakeDiversePodOptions() []PodOptions
- func MakeGenericPodOptions() PodOptions
- func MakePodAffinityPodOptions(key string) PodOptions
- func MakePodAntiAffinityPodOptions(key string) PodOptions
- func MakeTopologySpreadPodOptions(key string) PodOptions
- func UnscheduleablePodOptions(overrides ...PodOptions) PodOptions
- type RateLimitingInterface
- type ReplicaSetOptions
- type StatefulSetOptions
- type StorageClassOptions
- type VolumeAttachmentOptions
Constants ¶
const DiscoveryLabel = "testing/cluster"
Variables ¶
var (
DefaultImage = "public.ecr.aws/eks-distro/kubernetes/pause:3.2"
)
Functions ¶
func DaemonSet ¶
func DaemonSet(overrides ...DaemonSetOptions) *appsv1.DaemonSet
DaemonSet creates a test pod with defaults that can be overridden by DaemonSetOptions. Overrides are applied in order, with a last write wins semantic.
func Deployment ¶
func Deployment(overrides ...DeploymentOptions) *appsv1.Deployment
func Namespace ¶
func Namespace(overrides ...NamespaceOptions) *corev1.Namespace
Namespace creates a Namespace.
func NamespacedObjectMeta ¶
func NamespacedObjectMeta(overrides ...metav1.ObjectMeta) metav1.ObjectMeta
func Node ¶
func Node(overrides ...NodeOptions) *corev1.Node
func NodeClaim ¶
NodeClaim creates a test NodeClaim with defaults that can be overridden by overrides. Overrides are applied in order, with a last write wins semantic.
func NodeClaimAndNode ¶
func NodeClaimNodeClassRefFieldIndexer ¶ added in v1.1.0
func NodeClaimProviderIDFieldIndexer ¶ added in v1.1.0
func NodeClaimsAndNodes ¶
NodeClaimsAndNodes creates homogeneous groups of NodeClaims and Nodes based on the passed in options, evenly divided by the total nodeclaims requested
func NodeClass ¶ added in v1.0.0
func NodeClass(overrides ...v1alpha1.TestNodeClass) *v1alpha1.TestNodeClass
NodeClass creates a test NodeClass with defaults that can be overridden by overrides. Overrides are applied in order, with a last write wins semantic.
func NodePool ¶
NodePool creates a test NodePool with defaults that can be overridden by overrides. Overrides are applied in order, with a last write wins semantic.
func NodePools ¶ added in v0.34.0
NodePools creates homogeneous groups of NodePools based on the passed in options, evenly divided by the total NodePools requested
func NodeProviderIDFieldIndexer ¶ added in v1.1.0
func ObjectMeta ¶
func ObjectMeta(overrides ...metav1.ObjectMeta) metav1.ObjectMeta
func Options ¶
func Options(overrides ...OptionsFields) *options.Options
func PersistentVolume ¶
func PersistentVolume(overrides ...PersistentVolumeOptions) *v1.PersistentVolume
func PersistentVolumeClaim ¶
func PersistentVolumeClaim(overrides ...PersistentVolumeClaimOptions) *v1.PersistentVolumeClaim
func Pod ¶
func Pod(overrides ...PodOptions) *v1.Pod
Pod creates a test pod with defaults that can be overridden by PodOptions. Overrides are applied in order, with a last write wins semantic. nolint:gocyclo
func PodDisruptionBudget ¶
func PodDisruptionBudget(overrides ...PDBOptions) *policyv1.PodDisruptionBudget
PodDisruptionBudget creates a PodDisruptionBudget. To function properly, it should have its status applied
func Pods ¶
func Pods(total int, options ...PodOptions) []*v1.Pod
Pods creates homogeneous groups of pods based on the passed in options, evenly divided by the total pods requested
func ProviderID ¶
func RandomAffinityLabels ¶ added in v1.0.0
func RandomLabelValue ¶ added in v1.0.0
func RandomLabelValue() string
func RandomLabels ¶ added in v1.0.0
func RandomMemory ¶ added in v1.0.0
func RandomName ¶
func RandomName() string
func RandomProviderID ¶
func RandomProviderID() string
func ReplaceRequirements ¶
func ReplaceRequirements(nodePool *v1.NodePool, reqs ...v1.NodeSelectorRequirementWithMinValues) *v1.NodePool
ReplaceRequirements any current requirements on the passed through NodePool with the passed in requirements If any of the keys match between the existing requirements and the new requirements, the new requirement with the same key will replace the old requirement with that key
func ReplicaSet ¶
func ReplicaSet(overrides ...ReplicaSetOptions) *appsv1.ReplicaSet
ReplicaSet creates a test ReplicaSet with defaults that can be overridden by ReplicaSetOptions. Overrides are applied in order, with a last write wins semantic.
func SetDefaultNodeClassType ¶ added in v1.1.0
SetDefaultNodeClassType configures the default NodeClass type used when generating NodeClassRefs for test NodePools and NodeClaims.
func StatefulSet ¶ added in v0.33.3
func StatefulSet(overrides ...StatefulSetOptions) *appsv1.StatefulSet
func StorageClass ¶
func StorageClass(overrides ...StorageClassOptions) *storagev1.StorageClass
func TemplateObjectMeta ¶
func TemplateObjectMeta(overrides ...v1.ObjectMeta) v1.ObjectMeta
func UnschedulablePod ¶
func UnschedulablePod(options ...PodOptions) *v1.Pod
UnschedulablePod creates a test pod with a pending scheduling status condition
func UnschedulablePods ¶
func UnschedulablePods(options PodOptions, num int) []*v1.Pod
UnschedulablePods returns slice of configurable length of identical test pods with a pending scheduling status condition
func VolumeAttachment ¶ added in v1.0.0
func VolumeAttachment(overrides ...VolumeAttachmentOptions) *storagev1.VolumeAttachment
func VolumeAttachmentFieldIndexer ¶ added in v1.0.0
func WithCRDs ¶
func WithCRDs(crds ...*apiextensionsv1.CustomResourceDefinition) option.Function[EnvironmentOptions]
WithCRDs registers the specified CRDs to the apiserver for use in testing
func WithFieldIndexers ¶
func WithFieldIndexers(fieldIndexers ...func(cache.Cache) error) option.Function[EnvironmentOptions]
WithFieldIndexers expects a function that indexes fields against the cache such as cache.IndexField(...).
Note: Only use when necessary, the use of field indexers in functional tests requires the use of the cache syncing client, which can have significant drawbacks for test performance.
Types ¶
type CacheSyncingClient ¶
CacheSyncingClient exists for tests that need to use custom fieldSelectors (thus, they need a client cache) and also need consistency in their testing by waiting for caches to sync after performing WRITE operations NOTE: This cache sync doesn't sync with third-party operations on the api-server
func (*CacheSyncingClient) Create ¶
func (c *CacheSyncingClient) Create(ctx context.Context, obj client.Object, opts ...client.CreateOption) error
func (*CacheSyncingClient) Delete ¶
func (c *CacheSyncingClient) Delete(ctx context.Context, obj client.Object, opts ...client.DeleteOption) error
func (*CacheSyncingClient) DeleteAllOf ¶
func (c *CacheSyncingClient) DeleteAllOf(ctx context.Context, obj client.Object, opts ...client.DeleteAllOfOption) error
func (*CacheSyncingClient) Patch ¶
func (c *CacheSyncingClient) Patch(ctx context.Context, obj client.Object, patch client.Patch, opts ...client.PatchOption) error
func (*CacheSyncingClient) Status ¶
func (c *CacheSyncingClient) Status() client.StatusWriter
func (*CacheSyncingClient) Update ¶
func (c *CacheSyncingClient) Update(ctx context.Context, obj client.Object, opts ...client.UpdateOption) error
type DaemonSetOptions ¶
type DaemonSetOptions struct { metav1.ObjectMeta Selector map[string]string PodOptions PodOptions }
DaemonSetOptions customizes a DaemonSet.
type DeploymentOptions ¶
type DeploymentOptions struct { metav1.ObjectMeta Labels map[string]string Replicas int32 PodOptions PodOptions }
type Environment ¶
type Environment struct { envtest.Environment Client client.Client KubernetesInterface kubernetes.Interface Version *version.Version Done chan struct{} Cancel context.CancelFunc }
func NewEnvironment ¶
func NewEnvironment(options ...option.Function[EnvironmentOptions]) *Environment
func (*Environment) Stop ¶
func (e *Environment) Stop() error
type EnvironmentOptions ¶
type EnvironmentOptions struct {
// contains filtered or unexported fields
}
type EphemeralVolumeTemplateOptions ¶
type EphemeralVolumeTemplateOptions struct {
StorageClassName *string
}
type EventRecorder ¶
type EventRecorder struct {
// contains filtered or unexported fields
}
EventRecorder is a mock event recorder that is used to facilitate testing.
func NewEventRecorder ¶
func NewEventRecorder() *EventRecorder
func (*EventRecorder) Calls ¶
func (e *EventRecorder) Calls(reason string) int
func (*EventRecorder) DetectedEvent ¶
func (e *EventRecorder) DetectedEvent(msg string) bool
func (*EventRecorder) Events ¶
func (e *EventRecorder) Events() (res []events.Event)
func (*EventRecorder) ForEachEvent ¶
func (e *EventRecorder) ForEachEvent(f func(evt events.Event))
func (*EventRecorder) Publish ¶
func (e *EventRecorder) Publish(evts ...events.Event)
func (*EventRecorder) Reset ¶
func (e *EventRecorder) Reset()
type FeatureGates ¶
type NamespaceOptions ¶
type NamespaceOptions struct {
metav1.ObjectMeta
}
PodOptions customizes a Pod.
type NodeOptions ¶
type NodeOptions struct { metav1.ObjectMeta ReadyStatus corev1.ConditionStatus ReadyReason string Conditions []corev1.NodeCondition Unschedulable bool ProviderID string Taints []corev1.Taint Allocatable corev1.ResourceList Capacity corev1.ResourceList }
type OptionsFields ¶
type OptionsFields struct { // Vendor Neutral ServiceName *string MetricsPort *int HealthProbePort *int KubeClientQPS *int KubeClientBurst *int EnableProfiling *bool DisableLeaderElection *bool LeaderElectionName *string LeaderElectionNamespace *string MemoryLimit *int64 LogLevel *string LogOutputPaths *string LogErrorOutputPaths *string BatchMaxDuration *time.Duration BatchIdleDuration *time.Duration FeatureGates FeatureGates }
type PDBOptions ¶
type PDBOptions struct { metav1.ObjectMeta Labels map[string]string MinAvailable *intstr.IntOrString Status *policyv1.PodDisruptionBudgetStatus }
type PersistentVolumeClaimOptions ¶
type PersistentVolumeClaimOptions struct { metav1.ObjectMeta StorageClassName *string VolumeName string Resources v1.VolumeResourceRequirements }
type PersistentVolumeOptions ¶
type PodOptions ¶
type PodOptions struct { metav1.ObjectMeta Image string NodeName string Overhead v1.ResourceList PriorityClassName string InitContainers []v1.Container ResourceRequirements v1.ResourceRequirements NodeSelector map[string]string NodeRequirements []v1.NodeSelectorRequirement NodePreferences []v1.NodeSelectorRequirement PodRequirements []v1.PodAffinityTerm PodPreferences []v1.WeightedPodAffinityTerm PodAntiRequirements []v1.PodAffinityTerm PodAntiPreferences []v1.WeightedPodAffinityTerm TopologySpreadConstraints []v1.TopologySpreadConstraint Tolerations []v1.Toleration PersistentVolumeClaims []string EphemeralVolumeTemplates []EphemeralVolumeTemplateOptions HostPorts []int32 Conditions []v1.PodCondition Phase v1.PodPhase RestartPolicy v1.RestartPolicy TerminationGracePeriodSeconds *int64 ReadinessProbe *v1.Probe LivenessProbe *v1.Probe PreStopSleep *int64 Command []string }
PodOptions customizes a Pod.
func MakeDiversePodOptions ¶ added in v1.0.0
func MakeDiversePodOptions() []PodOptions
func MakeGenericPodOptions ¶ added in v1.0.0
func MakeGenericPodOptions() PodOptions
func MakePodAffinityPodOptions ¶ added in v1.0.0
func MakePodAffinityPodOptions(key string) PodOptions
func MakePodAntiAffinityPodOptions ¶ added in v1.0.0
func MakePodAntiAffinityPodOptions(key string) PodOptions
func MakeTopologySpreadPodOptions ¶ added in v1.0.0
func MakeTopologySpreadPodOptions(key string) PodOptions
func UnscheduleablePodOptions ¶
func UnscheduleablePodOptions(overrides ...PodOptions) PodOptions
type RateLimitingInterface ¶ added in v1.1.0
type RateLimitingInterface struct { workqueue.Interface AddedRateLimitedLock sync.Mutex AddedRatelimited []any }
RateLimitingInterface implements a RateLimiting queue as a non-ratelimited queue for testing. This helps testing by having functions that use a RateLimiting queue synchronously add items to the queue.
func NewRateLimitingInterface ¶ added in v1.1.0
func NewRateLimitingInterface(queueConfig workqueue.QueueConfig) *RateLimitingInterface
func (*RateLimitingInterface) AddAfter ¶ added in v1.1.0
func (q *RateLimitingInterface) AddAfter(item interface{}, duration time.Duration)
AddAfter implements RateLimitingInterface.
func (*RateLimitingInterface) AddRateLimited ¶ added in v1.1.0
func (q *RateLimitingInterface) AddRateLimited(item interface{})
AddRateLimited implements RateLimitingInterface.
func (*RateLimitingInterface) Forget ¶ added in v1.1.0
func (q *RateLimitingInterface) Forget(item interface{})
Forget implements RateLimitingInterface.
func (*RateLimitingInterface) NumRequeues ¶ added in v1.1.0
func (q *RateLimitingInterface) NumRequeues(item interface{}) int
NumRequeues implements RateLimitingInterface.
type ReplicaSetOptions ¶
type ReplicaSetOptions struct { metav1.ObjectMeta Selector map[string]string PodOptions PodOptions }
ReplicaSetOptions customizes a ReplicaSet.
type StatefulSetOptions ¶ added in v0.33.3
type StatefulSetOptions struct { metav1.ObjectMeta Labels map[string]string Replicas int32 PodOptions PodOptions }
type StorageClassOptions ¶
type StorageClassOptions struct { metav1.ObjectMeta Zones []string Provisioner *string VolumeBindingMode *storagev1.VolumeBindingMode }
type VolumeAttachmentOptions ¶ added in v1.0.0
type VolumeAttachmentOptions struct { metav1.ObjectMeta NodeName string VolumeName string }
Source Files
¶
Directories
¶
Path | Synopsis |
---|---|
+k8s:openapi-gen=true +k8s:deepcopy-gen=package,register +k8s:defaulter-gen=TypeMeta +groupName=karpenter.test.sh
|
+k8s:openapi-gen=true +k8s:deepcopy-gen=package,register +k8s:defaulter-gen=TypeMeta +groupName=karpenter.test.sh |