diff options
| author | KubeEdge Bot <48982446+kubeedge-bot@users.noreply.github.com> | 2024-01-15 21:18:26 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-01-15 21:18:26 +0800 |
| commit | 88e4b1ec243d9049de9be28c8ea4dd3c0612f07d (patch) | |
| tree | 770598173cdf13db42b9a61849e6651b2ad2749c /pkg | |
| parent | Merge pull request #5353 from WillardHu/approver (diff) | |
| parent | support enable imagePrePullController through helm (diff) | |
| download | kubeedge-88e4b1ec243d9049de9be28c8ea4dd3c0612f07d.tar.gz | |
Merge pull request #5331 from Shelley-BaoYue/image-prepull
support image prepull feature
Diffstat (limited to 'pkg')
15 files changed, 877 insertions, 0 deletions
diff --git a/pkg/apis/componentconfig/cloudcore/v1alpha1/default.go b/pkg/apis/componentconfig/cloudcore/v1alpha1/default.go index 31e0857e3..66128ec49 100644 --- a/pkg/apis/componentconfig/cloudcore/v1alpha1/default.go +++ b/pkg/apis/componentconfig/cloudcore/v1alpha1/default.go @@ -108,6 +108,16 @@ func NewDefaultCloudCoreConfig() *CloudCoreConfig { NodeUpgradeJobWorkers: constants.DefaultNodeUpgradeJobWorkers, }, }, + ImagePrePullController: &ImagePrePullController{ + Enable: false, + Buffer: &ImagePrePullControllerBuffer{ + ImagePrePullJobStatus: constants.DefaultImagePrePullJobStatusBuffer, + ImagePrePullJobEvent: constants.DefaultImagePrePullJobEventBuffer, + }, + Load: &ImagePrePullControllerLoad{ + ImagePrePullJobWorkers: constants.DefaultImagePrePullJobWorkers, + }, + }, SyncController: &SyncController{ Enable: true, }, diff --git a/pkg/apis/componentconfig/cloudcore/v1alpha1/types.go b/pkg/apis/componentconfig/cloudcore/v1alpha1/types.go index 8d04c9359..955960fe0 100644 --- a/pkg/apis/componentconfig/cloudcore/v1alpha1/types.go +++ b/pkg/apis/componentconfig/cloudcore/v1alpha1/types.go @@ -90,6 +90,8 @@ type Modules struct { DeviceController *DeviceController `json:"deviceController,omitempty"` // NodeUpgradeJobController indicates NodeUpgradeJobController module config NodeUpgradeJobController *NodeUpgradeJobController `json:"nodeUpgradeJobController,omitempty"` + // ImagePrePullController indicates ImagePrePullController module config + ImagePrePullController *ImagePrePullController `json:"imagePrePullController,omitempty"` // SyncController indicates SyncController module config SyncController *SyncController `json:"syncController,omitempty"` // DynamicController indicates DynamicController module config @@ -408,6 +410,35 @@ type NodeUpgradeJobControllerLoad struct { NodeUpgradeJobWorkers int32 `json:"nodeUpgradeJobWorkers,omitempty"` } +// ImagePrePullController indicates the operations controller +type ImagePrePullController struct { + // Enable indicates whether ImagePrePullController is enabled, + // if set to false (for debugging etc.), skip checking other ImagePrePullController configs. + // default false + Enable bool `json:"enable"` + // Buffer indicates Operation Controller buffer + Buffer *ImagePrePullControllerBuffer `json:"buffer,omitempty"` + // Load indicates Operation Controller Load + Load *ImagePrePullControllerLoad `json:"load,omitempty"` +} + +// ImagePrePullControllerBuffer indicates ImagePrePullController buffer +type ImagePrePullControllerBuffer struct { + // ImagePrePullJobStatus indicates the buffer of update ImagePrePullJob status + // default 1024 + ImagePrePullJobStatus int32 `json:"imagePrePullJobStatus,omitempty"` + // ImagePrePullJobEvent indicates the buffer of ImagePrePullJob event + // default 1 + ImagePrePullJobEvent int32 `json:"imagePrePullJobEvent,omitempty"` +} + +// ImagePrePullControllerLoad indicates the ImagePrePullController load +type ImagePrePullControllerLoad struct { + // ImagePrePullJobWorkers indicates the load of update ImagePrePullJob workers + // default 1 + ImagePrePullJobWorkers int32 `json:"imagePrePullJobWorkers,omitempty"` +} + // SyncController indicates the sync controller type SyncController struct { // Enable indicates whether syncController is enabled, diff --git a/pkg/apis/operations/v1alpha1/imageprepull_types.go b/pkg/apis/operations/v1alpha1/imageprepull_types.go new file mode 100644 index 000000000..0ac53a975 --- /dev/null +++ b/pkg/apis/operations/v1alpha1/imageprepull_types.go @@ -0,0 +1,158 @@ +/* +Copyright 2023 The KubeEdge Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package v1alpha1 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +// +genclient +// +genclient:nonNamespaced +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// ImagePrePullJob is used to prepull images on edge node. +// +k8s:openapi-gen=true +// +kubebuilder:subresource:status +// +kubebuilder:resource:scope=Cluster +type ImagePrePullJob struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + + // Spec represents the specification of the desired behavior of ImagePrePullJob. + // +required + Spec ImagePrePullJobSpec `json:"spec"` + + // Status represents the status of ImagePrePullJob. + // +optional + Status ImagePrePullJobStatus `json:"status,omitempty"` +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// ImagePrePullJobList is a list of ImagePrePullJob. +type ImagePrePullJobList struct { + // Standard type metadata. + metav1.TypeMeta `json:",inline"` + + // Standard list metadata. + metav1.ListMeta `json:"metadata,omitempty"` + + // List of ImagePrePullJob. + Items []ImagePrePullJob `json:"items"` +} + +// ImagePrePullSpec represents the specification of the desired behavior of ImagePrePullJob. +type ImagePrePullJobSpec struct { + // ImagePrepullTemplate represents original templates of imagePrePull + ImagePrePullTemplate ImagePrePullTemplate `json:"imagePrePullTemplate,omitempty"` +} + +// ImagePrePullTemplate represents original templates of imagePrePull +type ImagePrePullTemplate struct { + // Images is the image list to be prepull + Images []string `json:"images,omitempty"` + + // NodeNames is a request to select some specific nodes. If it is non-empty, + // the upgrade job simply select these edge nodes to do upgrade operation. + // Please note that sets of NodeNames and LabelSelector are ORed. + // Users must set one and can only set one. + // +optional + NodeNames []string `json:"nodeNames,omitempty"` + // LabelSelector is a filter to select member clusters by labels. + // It must match a node's labels for the NodeUpgradeJob to be operated on that node. + // Please note that sets of NodeNames and LabelSelector are ORed. + // Users must set one and can only set one. + // +optional + LabelSelector *metav1.LabelSelector `json:"labelSelector,omitempty"` + + // CheckItems specifies the items need to be checked before the task is executed. + // The default CheckItems value is disk. + // +optional + CheckItems []string `json:"checkItems,omitempty"` + + // ImageSecret specifies the secret for image pull if private registry used. + // Use {namespace}/{secretName} in format. + // +optional + ImageSecret string `json:"imageSecrets,omitempty"` + + // TimeoutSecondsOnEachNode limits the duration of the image prepull job on each edgenode. + // Default to 360. + // If set to 0, we'll use the default value 360. + // +optional + TimeoutSecondsOnEachNode *uint32 `json:"timeoutSecondsOnEachNode,omitempty"` + + // RetryTimes specifies the retry times if image pull failed on each edgenode. + // Default to 0 + // +optional + RetryTimes int32 `json:"retryTimes,omitempty"` +} + +// PrePullState describe the PrePullState of image prepull operation on edge nodes. +// +kubebuilder:validation:Enum=prepulling;successful;failed +type PrePullState string + +// Valid values of PrepullState +const ( + PrePullInitialValue PrePullState = "" + PrePulling PrePullState = "prepulling" + PrePullSuccessful PrePullState = "successful" + PrePullFailed PrePullState = "failed" +) + +// ImagePrePullJobStatus stores the status of ImagePrePullJob. +// contains images prepull status on multiple edge nodes. +// +kubebuilder:validation:Type=object +type ImagePrePullJobStatus struct { + // State represents for the state phase of the ImagePrePullJob. + // There are four possible state values: "", prechecking, prepulling, successful, failed. + State PrePullState `json:"state,omitempty"` + + // Status contains image prepull status for each edge node. + Status []ImagePrePullStatus `json:"status,omitempty"` +} + +// ImagePrePullStatus stores image prepull status for each edge node. +// +kubebuilder:validation:Type=object +type ImagePrePullStatus struct { + // NodeName is the name of edge node. + NodeName string `json:"nodeName,omitempty"` + + // State represents for the state phase of the ImagePrepullJob on the edge node. + // There are five possible state values: "", prepulling, successful, failed. + State PrePullState `json:"state,omitempty"` + + // Reason represents the fail reason if images prepull failed on the edge node + Reason string `json:"reason,omitempty"` + + // ImageStatus represents the prepull status for each image + ImageStatus []ImageStatus `json:"imageStatus,omitempty"` +} + +// ImageStatus stores the prepull status for each image. +// +kubebuilder:validation:Type=object +type ImageStatus struct { + // Image is the name of the image + Image string `json:"image,omitempty"` + + // State represents for the state phase of this image pull on the edge node + // There are two possible state values: successful, failed. + State PrePullState `json:"state,omitempty"` + + // Reason represents the fail reason if image pull failed + // +optional + Reason string `json:"reason,omitempty"` +} diff --git a/pkg/apis/operations/v1alpha1/register.go b/pkg/apis/operations/v1alpha1/register.go index c6aa1325e..d78a1013d 100644 --- a/pkg/apis/operations/v1alpha1/register.go +++ b/pkg/apis/operations/v1alpha1/register.go @@ -65,6 +65,8 @@ func addKnownTypes(scheme *runtime.Scheme) error { scheme.AddKnownTypes(SchemeGroupVersion, &NodeUpgradeJob{}, &NodeUpgradeJobList{}, + &ImagePrePullJob{}, + &ImagePrePullJobList{}, ) metav1.AddToGroupVersion(scheme, SchemeGroupVersion) return nil diff --git a/pkg/apis/operations/v1alpha1/zz_generated.deepcopy.go b/pkg/apis/operations/v1alpha1/zz_generated.deepcopy.go index fb9863292..8b38fd4ec 100644 --- a/pkg/apis/operations/v1alpha1/zz_generated.deepcopy.go +++ b/pkg/apis/operations/v1alpha1/zz_generated.deepcopy.go @@ -43,6 +43,185 @@ func (in *History) DeepCopy() *History { } // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ImagePrePullJob) DeepCopyInto(out *ImagePrePullJob) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + in.Status.DeepCopyInto(&out.Status) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ImagePrePullJob. +func (in *ImagePrePullJob) DeepCopy() *ImagePrePullJob { + if in == nil { + return nil + } + out := new(ImagePrePullJob) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *ImagePrePullJob) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ImagePrePullJobList) DeepCopyInto(out *ImagePrePullJobList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]ImagePrePullJob, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ImagePrePullJobList. +func (in *ImagePrePullJobList) DeepCopy() *ImagePrePullJobList { + if in == nil { + return nil + } + out := new(ImagePrePullJobList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *ImagePrePullJobList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ImagePrePullJobSpec) DeepCopyInto(out *ImagePrePullJobSpec) { + *out = *in + in.ImagePrePullTemplate.DeepCopyInto(&out.ImagePrePullTemplate) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ImagePrePullJobSpec. +func (in *ImagePrePullJobSpec) DeepCopy() *ImagePrePullJobSpec { + if in == nil { + return nil + } + out := new(ImagePrePullJobSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ImagePrePullJobStatus) DeepCopyInto(out *ImagePrePullJobStatus) { + *out = *in + if in.Status != nil { + in, out := &in.Status, &out.Status + *out = make([]ImagePrePullStatus, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ImagePrePullJobStatus. +func (in *ImagePrePullJobStatus) DeepCopy() *ImagePrePullJobStatus { + if in == nil { + return nil + } + out := new(ImagePrePullJobStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ImagePrePullStatus) DeepCopyInto(out *ImagePrePullStatus) { + *out = *in + if in.ImageStatus != nil { + in, out := &in.ImageStatus, &out.ImageStatus + *out = make([]ImageStatus, len(*in)) + copy(*out, *in) + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ImagePrePullStatus. +func (in *ImagePrePullStatus) DeepCopy() *ImagePrePullStatus { + if in == nil { + return nil + } + out := new(ImagePrePullStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ImagePrePullTemplate) DeepCopyInto(out *ImagePrePullTemplate) { + *out = *in + if in.Images != nil { + in, out := &in.Images, &out.Images + *out = make([]string, len(*in)) + copy(*out, *in) + } + if in.NodeNames != nil { + in, out := &in.NodeNames, &out.NodeNames + *out = make([]string, len(*in)) + copy(*out, *in) + } + if in.LabelSelector != nil { + in, out := &in.LabelSelector, &out.LabelSelector + *out = new(v1.LabelSelector) + (*in).DeepCopyInto(*out) + } + if in.CheckItems != nil { + in, out := &in.CheckItems, &out.CheckItems + *out = make([]string, len(*in)) + copy(*out, *in) + } + if in.TimeoutSecondsOnEachNode != nil { + in, out := &in.TimeoutSecondsOnEachNode, &out.TimeoutSecondsOnEachNode + *out = new(uint32) + **out = **in + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ImagePrePullTemplate. +func (in *ImagePrePullTemplate) DeepCopy() *ImagePrePullTemplate { + if in == nil { + return nil + } + out := new(ImagePrePullTemplate) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ImageStatus) DeepCopyInto(out *ImageStatus) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ImageStatus. +func (in *ImageStatus) DeepCopy() *ImageStatus { + if in == nil { + return nil + } + out := new(ImageStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *NodeUpgradeJob) DeepCopyInto(out *NodeUpgradeJob) { *out = *in out.TypeMeta = in.TypeMeta diff --git a/pkg/client/clientset/versioned/typed/operations/v1alpha1/fake/fake_imageprepulljob.go b/pkg/client/clientset/versioned/typed/operations/v1alpha1/fake/fake_imageprepulljob.go new file mode 100644 index 000000000..cb7a54910 --- /dev/null +++ b/pkg/client/clientset/versioned/typed/operations/v1alpha1/fake/fake_imageprepulljob.go @@ -0,0 +1,132 @@ +/* +Copyright The KubeEdge Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +package fake + +import ( + "context" + + v1alpha1 "github.com/kubeedge/kubeedge/pkg/apis/operations/v1alpha1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + labels "k8s.io/apimachinery/pkg/labels" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + testing "k8s.io/client-go/testing" +) + +// FakeImagePrePullJobs implements ImagePrePullJobInterface +type FakeImagePrePullJobs struct { + Fake *FakeOperationsV1alpha1 +} + +var imageprepulljobsResource = v1alpha1.SchemeGroupVersion.WithResource("imageprepulljobs") + +var imageprepulljobsKind = v1alpha1.SchemeGroupVersion.WithKind("ImagePrePullJob") + +// Get takes name of the imagePrePullJob, and returns the corresponding imagePrePullJob object, and an error if there is any. +func (c *FakeImagePrePullJobs) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.ImagePrePullJob, err error) { + obj, err := c.Fake. + Invokes(testing.NewRootGetAction(imageprepulljobsResource, name), &v1alpha1.ImagePrePullJob{}) + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.ImagePrePullJob), err +} + +// List takes label and field selectors, and returns the list of ImagePrePullJobs that match those selectors. +func (c *FakeImagePrePullJobs) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.ImagePrePullJobList, err error) { + obj, err := c.Fake. + Invokes(testing.NewRootListAction(imageprepulljobsResource, imageprepulljobsKind, opts), &v1alpha1.ImagePrePullJobList{}) + if obj == nil { + return nil, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &v1alpha1.ImagePrePullJobList{ListMeta: obj.(*v1alpha1.ImagePrePullJobList).ListMeta} + for _, item := range obj.(*v1alpha1.ImagePrePullJobList).Items { + if label.Matches(labels.Set(item.Labels)) { + list.Items = append(list.Items, item) + } + } + return list, err +} + +// Watch returns a watch.Interface that watches the requested imagePrePullJobs. +func (c *FakeImagePrePullJobs) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewRootWatchAction(imageprepulljobsResource, opts)) +} + +// Create takes the representation of a imagePrePullJob and creates it. Returns the server's representation of the imagePrePullJob, and an error, if there is any. +func (c *FakeImagePrePullJobs) Create(ctx context.Context, imagePrePullJob *v1alpha1.ImagePrePullJob, opts v1.CreateOptions) (result *v1alpha1.ImagePrePullJob, err error) { + obj, err := c.Fake. + Invokes(testing.NewRootCreateAction(imageprepulljobsResource, imagePrePullJob), &v1alpha1.ImagePrePullJob{}) + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.ImagePrePullJob), err +} + +// Update takes the representation of a imagePrePullJob and updates it. Returns the server's representation of the imagePrePullJob, and an error, if there is any. +func (c *FakeImagePrePullJobs) Update(ctx context.Context, imagePrePullJob *v1alpha1.ImagePrePullJob, opts v1.UpdateOptions) (result *v1alpha1.ImagePrePullJob, err error) { + obj, err := c.Fake. + Invokes(testing.NewRootUpdateAction(imageprepulljobsResource, imagePrePullJob), &v1alpha1.ImagePrePullJob{}) + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.ImagePrePullJob), err +} + +// UpdateStatus was generated because the type contains a Status member. +// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). +func (c *FakeImagePrePullJobs) UpdateStatus(ctx context.Context, imagePrePullJob *v1alpha1.ImagePrePullJob, opts v1.UpdateOptions) (*v1alpha1.ImagePrePullJob, error) { + obj, err := c.Fake. + Invokes(testing.NewRootUpdateSubresourceAction(imageprepulljobsResource, "status", imagePrePullJob), &v1alpha1.ImagePrePullJob{}) + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.ImagePrePullJob), err +} + +// Delete takes name of the imagePrePullJob and deletes it. Returns an error if one occurs. +func (c *FakeImagePrePullJobs) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewRootDeleteActionWithOptions(imageprepulljobsResource, name, opts), &v1alpha1.ImagePrePullJob{}) + return err +} + +// DeleteCollection deletes a collection of objects. +func (c *FakeImagePrePullJobs) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + action := testing.NewRootDeleteCollectionAction(imageprepulljobsResource, listOpts) + + _, err := c.Fake.Invokes(action, &v1alpha1.ImagePrePullJobList{}) + return err +} + +// Patch applies the patch and returns the patched imagePrePullJob. +func (c *FakeImagePrePullJobs) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.ImagePrePullJob, err error) { + obj, err := c.Fake. + Invokes(testing.NewRootPatchSubresourceAction(imageprepulljobsResource, name, pt, data, subresources...), &v1alpha1.ImagePrePullJob{}) + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.ImagePrePullJob), err +} diff --git a/pkg/client/clientset/versioned/typed/operations/v1alpha1/fake/fake_operations_client.go b/pkg/client/clientset/versioned/typed/operations/v1alpha1/fake/fake_operations_client.go index 7a6025ff5..4e898107d 100644 --- a/pkg/client/clientset/versioned/typed/operations/v1alpha1/fake/fake_operations_client.go +++ b/pkg/client/clientset/versioned/typed/operations/v1alpha1/fake/fake_operations_client.go @@ -28,6 +28,10 @@ type FakeOperationsV1alpha1 struct { *testing.Fake } +func (c *FakeOperationsV1alpha1) ImagePrePullJobs() v1alpha1.ImagePrePullJobInterface { + return &FakeImagePrePullJobs{c} +} + func (c *FakeOperationsV1alpha1) NodeUpgradeJobs() v1alpha1.NodeUpgradeJobInterface { return &FakeNodeUpgradeJobs{c} } diff --git a/pkg/client/clientset/versioned/typed/operations/v1alpha1/generated_expansion.go b/pkg/client/clientset/versioned/typed/operations/v1alpha1/generated_expansion.go index e664010bf..3f5448bb5 100644 --- a/pkg/client/clientset/versioned/typed/operations/v1alpha1/generated_expansion.go +++ b/pkg/client/clientset/versioned/typed/operations/v1alpha1/generated_expansion.go @@ -18,4 +18,6 @@ limitations under the License. package v1alpha1 +type ImagePrePullJobExpansion interface{} + type NodeUpgradeJobExpansion interface{} diff --git a/pkg/client/clientset/versioned/typed/operations/v1alpha1/imageprepulljob.go b/pkg/client/clientset/versioned/typed/operations/v1alpha1/imageprepulljob.go new file mode 100644 index 000000000..7dd77f40b --- /dev/null +++ b/pkg/client/clientset/versioned/typed/operations/v1alpha1/imageprepulljob.go @@ -0,0 +1,184 @@ +/* +Copyright The KubeEdge Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + "context" + "time" + + v1alpha1 "github.com/kubeedge/kubeedge/pkg/apis/operations/v1alpha1" + scheme "github.com/kubeedge/kubeedge/pkg/client/clientset/versioned/scheme" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + rest "k8s.io/client-go/rest" +) + +// ImagePrePullJobsGetter has a method to return a ImagePrePullJobInterface. +// A group's client should implement this interface. +type ImagePrePullJobsGetter interface { + ImagePrePullJobs() ImagePrePullJobInterface +} + +// ImagePrePullJobInterface has methods to work with ImagePrePullJob resources. +type ImagePrePullJobInterface interface { + Create(ctx context.Context, imagePrePullJob *v1alpha1.ImagePrePullJob, opts v1.CreateOptions) (*v1alpha1.ImagePrePullJob, error) + Update(ctx context.Context, imagePrePullJob *v1alpha1.ImagePrePullJob, opts v1.UpdateOptions) (*v1alpha1.ImagePrePullJob, error) + UpdateStatus(ctx context.Context, imagePrePullJob *v1alpha1.ImagePrePullJob, opts v1.UpdateOptions) (*v1alpha1.ImagePrePullJob, error) + Delete(ctx context.Context, name string, opts v1.DeleteOptions) error + DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error + Get(ctx context.Context, name string, opts v1.GetOptions) (*v1alpha1.ImagePrePullJob, error) + List(ctx context.Context, opts v1.ListOptions) (*v1alpha1.ImagePrePullJobList, error) + Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) + Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.ImagePrePullJob, err error) + ImagePrePullJobExpansion +} + +// imagePrePullJobs implements ImagePrePullJobInterface +type imagePrePullJobs struct { + client rest.Interface +} + +// newImagePrePullJobs returns a ImagePrePullJobs +func newImagePrePullJobs(c *OperationsV1alpha1Client) *imagePrePullJobs { + return &imagePrePullJobs{ + client: c.RESTClient(), + } +} + +// Get takes name of the imagePrePullJob, and returns the corresponding imagePrePullJob object, and an error if there is any. +func (c *imagePrePullJobs) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.ImagePrePullJob, err error) { + result = &v1alpha1.ImagePrePullJob{} + err = c.client.Get(). + Resource("imageprepulljobs"). + Name(name). + VersionedParams(&options, scheme.ParameterCodec). + Do(ctx). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of ImagePrePullJobs that match those selectors. +func (c *imagePrePullJobs) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.ImagePrePullJobList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1alpha1.ImagePrePullJobList{} + err = c.client.Get(). + Resource("imageprepulljobs"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Do(ctx). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested imagePrePullJobs. +func (c *imagePrePullJobs) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + opts.Watch = true + return c.client.Get(). + Resource("imageprepulljobs"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Watch(ctx) +} + +// Create takes the representation of a imagePrePullJob and creates it. Returns the server's representation of the imagePrePullJob, and an error, if there is any. +func (c *imagePrePullJobs) Create(ctx context.Context, imagePrePullJob *v1alpha1.ImagePrePullJob, opts v1.CreateOptions) (result *v1alpha1.ImagePrePullJob, err error) { + result = &v1alpha1.ImagePrePullJob{} + err = c.client.Post(). + Resource("imageprepulljobs"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(imagePrePullJob). + Do(ctx). + Into(result) + return +} + +// Update takes the representation of a imagePrePullJob and updates it. Returns the server's representation of the imagePrePullJob, and an error, if there is any. +func (c *imagePrePullJobs) Update(ctx context.Context, imagePrePullJob *v1alpha1.ImagePrePullJob, opts v1.UpdateOptions) (result *v1alpha1.ImagePrePullJob, err error) { + result = &v1alpha1.ImagePrePullJob{} + err = c.client.Put(). + Resource("imageprepulljobs"). + Name(imagePrePullJob.Name). + VersionedParams(&opts, scheme.ParameterCodec). + Body(imagePrePullJob). + Do(ctx). + Into(result) + return +} + +// UpdateStatus was generated because the type contains a Status member. +// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). +func (c *imagePrePullJobs) UpdateStatus(ctx context.Context, imagePrePullJob *v1alpha1.ImagePrePullJob, opts v1.UpdateOptions) (result *v1alpha1.ImagePrePullJob, err error) { + result = &v1alpha1.ImagePrePullJob{} + err = c.client.Put(). + Resource("imageprepulljobs"). + Name(imagePrePullJob.Name). + SubResource("status"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(imagePrePullJob). + Do(ctx). + Into(result) + return +} + +// Delete takes name of the imagePrePullJob and deletes it. Returns an error if one occurs. +func (c *imagePrePullJobs) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + return c.client.Delete(). + Resource("imageprepulljobs"). + Name(name). + Body(&opts). + Do(ctx). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *imagePrePullJobs) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + var timeout time.Duration + if listOpts.TimeoutSeconds != nil { + timeout = time.Duration(*listOpts.TimeoutSeconds) * time.Second + } + return c.client.Delete(). + Resource("imageprepulljobs"). + VersionedParams(&listOpts, scheme.ParameterCodec). + Timeout(timeout). + Body(&opts). + Do(ctx). + Error() +} + +// Patch applies the patch and returns the patched imagePrePullJob. +func (c *imagePrePullJobs) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.ImagePrePullJob, err error) { + result = &v1alpha1.ImagePrePullJob{} + err = c.client.Patch(pt). + Resource("imageprepulljobs"). + Name(name). + SubResource(subresources...). + VersionedParams(&opts, scheme.ParameterCodec). + Body(data). + Do(ctx). + Into(result) + return +} diff --git a/pkg/client/clientset/versioned/typed/operations/v1alpha1/operations_client.go b/pkg/client/clientset/versioned/typed/operations/v1alpha1/operations_client.go index 8d926b3cf..74af5f488 100644 --- a/pkg/client/clientset/versioned/typed/operations/v1alpha1/operations_client.go +++ b/pkg/client/clientset/versioned/typed/operations/v1alpha1/operations_client.go @@ -28,6 +28,7 @@ import ( type OperationsV1alpha1Interface interface { RESTClient() rest.Interface + ImagePrePullJobsGetter NodeUpgradeJobsGetter } @@ -36,6 +37,10 @@ type OperationsV1alpha1Client struct { restClient rest.Interface } +func (c *OperationsV1alpha1Client) ImagePrePullJobs() ImagePrePullJobInterface { + return newImagePrePullJobs(c) +} + func (c *OperationsV1alpha1Client) NodeUpgradeJobs() NodeUpgradeJobInterface { return newNodeUpgradeJobs(c) } diff --git a/pkg/client/informers/externalversions/generic.go b/pkg/client/informers/externalversions/generic.go index fa149a971..f56206105 100644 --- a/pkg/client/informers/externalversions/generic.go +++ b/pkg/client/informers/externalversions/generic.go @@ -70,6 +70,8 @@ func (f *sharedInformerFactory) ForResource(resource schema.GroupVersionResource return &genericInformer{resource: resource.GroupResource(), informer: f.Devices().V1beta1().DeviceModels().Informer()}, nil // Group=operations, Version=v1alpha1 + case operationsv1alpha1.SchemeGroupVersion.WithResource("imageprepulljobs"): + return &genericInformer{resource: resource.GroupResource(), informer: f.Operations().V1alpha1().ImagePrePullJobs().Informer()}, nil case operationsv1alpha1.SchemeGroupVersion.WithResource("nodeupgradejobs"): return &genericInformer{resource: resource.GroupResource(), informer: f.Operations().V1alpha1().NodeUpgradeJobs().Informer()}, nil diff --git a/pkg/client/informers/externalversions/operations/v1alpha1/imageprepulljob.go b/pkg/client/informers/externalversions/operations/v1alpha1/imageprepulljob.go new file mode 100644 index 000000000..511d627a6 --- /dev/null +++ b/pkg/client/informers/externalversions/operations/v1alpha1/imageprepulljob.go @@ -0,0 +1,89 @@ +/* +Copyright The KubeEdge Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by informer-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + "context" + time "time" + + operationsv1alpha1 "github.com/kubeedge/kubeedge/pkg/apis/operations/v1alpha1" + versioned "github.com/kubeedge/kubeedge/pkg/client/clientset/versioned" + internalinterfaces "github.com/kubeedge/kubeedge/pkg/client/informers/externalversions/internalinterfaces" + v1alpha1 "github.com/kubeedge/kubeedge/pkg/client/listers/operations/v1alpha1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + cache "k8s.io/client-go/tools/cache" +) + +// ImagePrePullJobInformer provides access to a shared informer and lister for +// ImagePrePullJobs. +type ImagePrePullJobInformer interface { + Informer() cache.SharedIndexInformer + Lister() v1alpha1.ImagePrePullJobLister +} + +type imagePrePullJobInformer struct { + factory internalinterfaces.SharedInformerFactory + tweakListOptions internalinterfaces.TweakListOptionsFunc +} + +// NewImagePrePullJobInformer constructs a new informer for ImagePrePullJob type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewImagePrePullJobInformer(client versioned.Interface, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { + return NewFilteredImagePrePullJobInformer(client, resyncPeriod, indexers, nil) +} + +// NewFilteredImagePrePullJobInformer constructs a new informer for ImagePrePullJob type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewFilteredImagePrePullJobInformer(client versioned.Interface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer { + return cache.NewSharedIndexInformer( + &cache.ListWatch{ + ListFunc: func(options v1.ListOptions) (runtime.Object, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.OperationsV1alpha1().ImagePrePullJobs().List(context.TODO(), options) + }, + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.OperationsV1alpha1().ImagePrePullJobs().Watch(context.TODO(), options) + }, + }, + &operationsv1alpha1.ImagePrePullJob{}, + resyncPeriod, + indexers, + ) +} + +func (f *imagePrePullJobInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { + return NewFilteredImagePrePullJobInformer(client, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) +} + +func (f *imagePrePullJobInformer) Informer() cache.SharedIndexInformer { + return f.factory.InformerFor(&operationsv1alpha1.ImagePrePullJob{}, f.defaultInformer) +} + +func (f *imagePrePullJobInformer) Lister() v1alpha1.ImagePrePullJobLister { + return v1alpha1.NewImagePrePullJobLister(f.Informer().GetIndexer()) +} diff --git a/pkg/client/informers/externalversions/operations/v1alpha1/interface.go b/pkg/client/informers/externalversions/operations/v1alpha1/interface.go index 10a3892ab..650ab553e 100644 --- a/pkg/client/informers/externalversions/operations/v1alpha1/interface.go +++ b/pkg/client/informers/externalversions/operations/v1alpha1/interface.go @@ -24,6 +24,8 @@ import ( // Interface provides access to all the informers in this group version. type Interface interface { + // ImagePrePullJobs returns a ImagePrePullJobInformer. + ImagePrePullJobs() ImagePrePullJobInformer // NodeUpgradeJobs returns a NodeUpgradeJobInformer. NodeUpgradeJobs() NodeUpgradeJobInformer } @@ -39,6 +41,11 @@ func New(f internalinterfaces.SharedInformerFactory, namespace string, tweakList return &version{factory: f, namespace: namespace, tweakListOptions: tweakListOptions} } +// ImagePrePullJobs returns a ImagePrePullJobInformer. +func (v *version) ImagePrePullJobs() ImagePrePullJobInformer { + return &imagePrePullJobInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} +} + // NodeUpgradeJobs returns a NodeUpgradeJobInformer. func (v *version) NodeUpgradeJobs() NodeUpgradeJobInformer { return &nodeUpgradeJobInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} diff --git a/pkg/client/listers/operations/v1alpha1/expansion_generated.go b/pkg/client/listers/operations/v1alpha1/expansion_generated.go index 7e83d432d..7ff435cd6 100644 --- a/pkg/client/listers/operations/v1alpha1/expansion_generated.go +++ b/pkg/client/listers/operations/v1alpha1/expansion_generated.go @@ -18,6 +18,10 @@ limitations under the License. package v1alpha1 +// ImagePrePullJobListerExpansion allows custom methods to be added to +// ImagePrePullJobLister. +type ImagePrePullJobListerExpansion interface{} + // NodeUpgradeJobListerExpansion allows custom methods to be added to // NodeUpgradeJobLister. type NodeUpgradeJobListerExpansion interface{} diff --git a/pkg/client/listers/operations/v1alpha1/imageprepulljob.go b/pkg/client/listers/operations/v1alpha1/imageprepulljob.go new file mode 100644 index 000000000..bb20ac4ac --- /dev/null +++ b/pkg/client/listers/operations/v1alpha1/imageprepulljob.go @@ -0,0 +1,68 @@ +/* +Copyright The KubeEdge Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by lister-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + v1alpha1 "github.com/kubeedge/kubeedge/pkg/apis/operations/v1alpha1" + "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/labels" + "k8s.io/client-go/tools/cache" +) + +// ImagePrePullJobLister helps list ImagePrePullJobs. +// All objects returned here must be treated as read-only. +type ImagePrePullJobLister interface { + // List lists all ImagePrePullJobs in the indexer. + // Objects returned here must be treated as read-only. + List(selector labels.Selector) (ret []*v1alpha1.ImagePrePullJob, err error) + // Get retrieves the ImagePrePullJob from the index for a given name. + // Objects returned here must be treated as read-only. + Get(name string) (*v1alpha1.ImagePrePullJob, error) + ImagePrePullJobListerExpansion +} + +// imagePrePullJobLister implements the ImagePrePullJobLister interface. +type imagePrePullJobLister struct { + indexer cache.Indexer +} + +// NewImagePrePullJobLister returns a new ImagePrePullJobLister. +func NewImagePrePullJobLister(indexer cache.Indexer) ImagePrePullJobLister { + return &imagePrePullJobLister{indexer: indexer} +} + +// List lists all ImagePrePullJobs in the indexer. +func (s *imagePrePullJobLister) List(selector labels.Selector) (ret []*v1alpha1.ImagePrePullJob, err error) { + err = cache.ListAll(s.indexer, selector, func(m interface{}) { + ret = append(ret, m.(*v1alpha1.ImagePrePullJob)) + }) + return ret, err +} + +// Get retrieves the ImagePrePullJob from the index for a given name. +func (s *imagePrePullJobLister) Get(name string) (*v1alpha1.ImagePrePullJob, error) { + obj, exists, err := s.indexer.GetByKey(name) + if err != nil { + return nil, err + } + if !exists { + return nil, errors.NewNotFound(v1alpha1.Resource("imageprepulljob"), name) + } + return obj.(*v1alpha1.ImagePrePullJob), nil +} |
