|
| 1 | +package v1 |
| 2 | + |
| 3 | +import ( |
| 4 | + corev1 "k8s.io/api/core/v1" |
| 5 | + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" |
| 6 | +) |
| 7 | + |
| 8 | +// ImagePrefetchSpec defines the desired state of ImagePrefetch |
| 9 | +type ImagePrefetchSpec struct { |
| 10 | + // Images is a list of container images that will be pre-downloaded to the target nodes |
| 11 | + Images []string `json:"images"` |
| 12 | + |
| 13 | + // NodeSelector is a map of key-value pairs that specify which nodes should have the images pre-downloaded |
| 14 | + // +optional |
| 15 | + NodeSelector map[string]string `json:"nodeSelector,omitempty"` |
| 16 | + |
| 17 | + // Replicas is the number of nodes that should download the specified images |
| 18 | + // +optional |
| 19 | + Replicas int `json:"replicas,omitempty"` |
| 20 | + |
| 21 | + // ImagePullSecrets is a list of secret names that contain credentials for authenticating with container registries |
| 22 | + // +optional |
| 23 | + ImagePullSecrets []corev1.LocalObjectReference `json:"imagePullSecrets,omitempty"` |
| 24 | +} |
| 25 | + |
| 26 | +// ImagePrefetchStatus defines the observed state of ImagePrefetch |
| 27 | +type ImagePrefetchStatus struct { |
| 28 | + // The generation observed by the controller. |
| 29 | + // +optional |
| 30 | + ObservedGeneration int64 `json:"observedGeneration,omitempty"` |
| 31 | + |
| 32 | + // Conditions represent the latest available observations of an object's state |
| 33 | + // +listType=map |
| 34 | + // +listMapKey=type |
| 35 | + // +optional |
| 36 | + Conditions []metav1.Condition `json:"conditions,omitempty"` |
| 37 | + |
| 38 | + // DesiredNodes represents the number of nodes that should have the images pre-downloaded |
| 39 | + // +optional |
| 40 | + // +kubebuilder:default:=0 |
| 41 | + DesiredNodes int `json:"desiredNodes,omitempty"` |
| 42 | + |
| 43 | + // ImagePulledNodes represents the number of nodes that have successfully pre-downloaded the images |
| 44 | + // +optional |
| 45 | + // +kubebuilder:default:=0 |
| 46 | + ImagePulledNodes int `json:"imagePulledNodes,omitempty"` |
| 47 | + |
| 48 | + // ImagePullingNodes represents the number of nodes that are currently downloading the images |
| 49 | + // +optional |
| 50 | + // +kubebuilder:default:=0 |
| 51 | + ImagePullingNodes int `json:"imagePullingNodes,omitempty"` |
| 52 | + |
| 53 | + // ImagePullFailedNodes represents the number of nodes that failed to download the images |
| 54 | + // +optional |
| 55 | + // +kubebuilder:default:=0 |
| 56 | + ImagePullFailedNodes int `json:"imagePullFailedNodes,omitempty"` |
| 57 | +} |
| 58 | + |
| 59 | +const ( |
| 60 | + ConditionReady = "Ready" |
| 61 | + ConditionProgressing = "Progressing" |
| 62 | + ConditionImageDownloadFailed = "ImageDownloadFailed" |
| 63 | +) |
| 64 | + |
| 65 | +// +kubebuilder:object:root=true |
| 66 | +// +kubebuilder:subresource:status |
| 67 | + |
| 68 | +// ImagePrefetch is the Schema for the imageprefetches API |
| 69 | +type ImagePrefetch struct { |
| 70 | + metav1.TypeMeta `json:",inline"` |
| 71 | + metav1.ObjectMeta `json:"metadata,omitempty"` |
| 72 | + |
| 73 | + Spec ImagePrefetchSpec `json:"spec,omitempty"` |
| 74 | + Status ImagePrefetchStatus `json:"status,omitempty"` |
| 75 | +} |
| 76 | + |
| 77 | +// +kubebuilder:object:root=true |
| 78 | + |
| 79 | +// ImagePrefetchList contains a list of ImagePrefetch |
| 80 | +type ImagePrefetchList struct { |
| 81 | + metav1.TypeMeta `json:",inline"` |
| 82 | + metav1.ListMeta `json:"metadata,omitempty"` |
| 83 | + Items []ImagePrefetch `json:"items"` |
| 84 | +} |
| 85 | + |
| 86 | +func init() { |
| 87 | + SchemeBuilder.Register(&ImagePrefetch{}, &ImagePrefetchList{}) |
| 88 | +} |
0 commit comments