diff --git a/apis/apps/v1alpha1/node_pod_probe_types.go b/apis/apps/v1alpha1/node_pod_probe_types.go new file mode 100644 index 0000000000..0f7fdaa0ff --- /dev/null +++ b/apis/apps/v1alpha1/node_pod_probe_types.go @@ -0,0 +1,117 @@ +/* +Copyright 2022 The Kruise 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 persistent 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" +) + +// NodePodProbeSpec defines the desired state of NodePodProbe +type NodePodProbeSpec struct { + PodProbes []PodProbe `json:"podProbes,omitempty"` +} + +type PodProbe struct { + // pod name + Name string `json:"name"` + // pod namespace + Namespace string `json:"namespace"` + // pod uid + UID string `json:"uid"` + // Custom container probe, supports Exec, Tcp, and returns the result to Pod yaml + Probes []ContainerProbe `json:"probes,omitempty"` +} + +type ContainerProbe struct { + // probe name, unique within the Pod(Even between different containers, they cannot be the same) + Name string `json:"name"` + // container name + ContainerName string `json:"containerName"` + // container probe spec + Probe ContainerProbeSpec `json:"probe"` + // Used for NodeProbeProbe to quickly find the corresponding PodProbeMarker resource. + PodProbeMarkerName string `json:"podProbeMarkerName,omitempty"` +} + +type NodePodProbeStatus struct { + // pod probe results + PodProbeStatuses []PodProbeStatus `json:"podProbeStatuses,omitempty"` +} + +type PodProbeStatus struct { + // pod name + Name string `json:"name"` + // pod namespace + Namespace string `json:"namespace"` + // pod uid + UID string `json:"uid"` + // pod probe result + ProbeStates []ContainerProbeState `json:"probeStates,omitempty"` +} + +type ContainerProbeState struct { + // probe name + Name string `json:"name"` + // container probe exec state, True or False + State ProbeState `json:"state"` + // Last time we probed the condition. + // +optional + LastProbeTime metav1.Time `json:"lastProbeTime,omitempty"` + // Last time the condition transitioned from one status to another. + // +optional + LastTransitionTime metav1.Time `json:"lastTransitionTime,omitempty"` + // If Status=True, Message records the return result of Probe. + // If Status=False, Message records Probe's error message + Message string `json:"message,omitempty"` +} + +type ProbeState string + +const ( + ProbeSucceeded ProbeState = "Succeeded" + ProbeFailed ProbeState = "Failed" + ProbeUnknown ProbeState = "Unknown" +) + +// +genclient +// +genclient:nonNamespaced +// +k8s:openapi-gen=true +// +kubebuilder:object:root=true +// +kubebuilder:resource:scope=Cluster +// +kubebuilder:subresource:status + +// NodePodProbe is the Schema for the NodePodProbe API +type NodePodProbe struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + + Spec NodePodProbeSpec `json:"spec,omitempty"` + Status NodePodProbeStatus `json:"status,omitempty"` +} + +// +kubebuilder:object:root=true + +// NodePodProbeList contains a list of NodePodProbe +type NodePodProbeList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata,omitempty"` + Items []NodePodProbe `json:"items"` +} + +func init() { + SchemeBuilder.Register(&NodePodProbe{}, &NodePodProbeList{}) +} diff --git a/apis/apps/v1alpha1/pod_probe_marker_types.go b/apis/apps/v1alpha1/pod_probe_marker_types.go new file mode 100644 index 0000000000..722efb48b8 --- /dev/null +++ b/apis/apps/v1alpha1/pod_probe_marker_types.go @@ -0,0 +1,97 @@ +/* +Copyright 2022 The Kruise 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 persistent 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 ( + v1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +// PodProbeMarkerSpec defines the desired state of PodProbeMarker +type PodProbeMarkerSpec struct { + // Selector is a label query over pods that should exec custom probe + // It must match the pod template's labels. + // More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/#label-selectors + Selector *metav1.LabelSelector `json:"selector"` + // Custom container probe, current only support Exec(). + // Probe Result will record in Pod.Status.Conditions, and condition.type=probe.name. + // condition.status=True indicates probe success + // condition.status=False indicates probe fails + Probes []PodContainerProbe `json:"probes"` +} + +type PodContainerProbe struct { + // probe name, unique within the Pod(Even between different containers, they cannot be the same) + Name string `json:"name"` + // container name + ContainerName string `json:"containerName"` + // container probe spec + Probe ContainerProbeSpec `json:"probe"` + // According to the execution result of ContainerProbe, perform specific actions, + // such as: patch Pod labels, annotations, ReadinessGate Condition + MarkerPolicy []ProbeMarkerPolicy `json:"markerPolicy,omitempty"` +} + +type ContainerProbeSpec struct { + v1.Probe `json:",inline"` +} + +type ProbeMarkerPolicy struct { + // probe status, True or False + // For example: State=Succeeded, annotations[controller.kubernetes.io/pod-deletion-cost] = '10'. + // State=Failed, annotations[controller.kubernetes.io/pod-deletion-cost] = '-10'. + // In addition, if State=Failed is not defined, Exec execution fails, and the annotations[controller.kubernetes.io/pod-deletion-cost] will be Deleted + State ProbeState `json:"state"` + // Patch Labels pod.labels + Labels map[string]string `json:"labels,omitempty"` + // Patch annotations pod.annotations + Annotations map[string]string `json:"annotations,omitempty"` +} + +type PodProbeMarkerStatus struct { + // observedGeneration is the most recent generation observed for this PodProbeMarker. It corresponds to the + // PodProbeMarker's generation, which is updated on mutation by the API Server. + ObservedGeneration int64 `json:"observedGeneration"` + // matched Pods + MatchedPods int64 `json:"matchedPods,omitempty"` +} + +// +genclient +// +kubebuilder:object:root=true +// +kubebuilder:subresource:status + +// PodProbeMarker is the Schema for the PodProbeMarker API +type PodProbeMarker struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + + Spec PodProbeMarkerSpec `json:"spec,omitempty"` + Status PodProbeMarkerStatus `json:"status,omitempty"` +} + +// +kubebuilder:object:root=true + +// PodProbeMarkerList contains a list of PodProbeMarker +type PodProbeMarkerList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata,omitempty"` + Items []PodProbeMarker `json:"items"` +} + +func init() { + SchemeBuilder.Register(&PodProbeMarker{}, &PodProbeMarkerList{}) +} diff --git a/apis/apps/v1alpha1/zz_generated.deepcopy.go b/apis/apps/v1alpha1/zz_generated.deepcopy.go index 421c2bdd88..3045f984ab 100644 --- a/apis/apps/v1alpha1/zz_generated.deepcopy.go +++ b/apis/apps/v1alpha1/zz_generated.deepcopy.go @@ -580,6 +580,55 @@ func (in *CompletionPolicy) DeepCopy() *CompletionPolicy { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ContainerProbe) DeepCopyInto(out *ContainerProbe) { + *out = *in + in.Probe.DeepCopyInto(&out.Probe) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ContainerProbe. +func (in *ContainerProbe) DeepCopy() *ContainerProbe { + if in == nil { + return nil + } + out := new(ContainerProbe) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ContainerProbeSpec) DeepCopyInto(out *ContainerProbeSpec) { + *out = *in + in.Probe.DeepCopyInto(&out.Probe) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ContainerProbeSpec. +func (in *ContainerProbeSpec) DeepCopy() *ContainerProbeSpec { + if in == nil { + return nil + } + out := new(ContainerProbeSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ContainerProbeState) DeepCopyInto(out *ContainerProbeState) { + *out = *in + in.LastProbeTime.DeepCopyInto(&out.LastProbeTime) + in.LastTransitionTime.DeepCopyInto(&out.LastTransitionTime) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ContainerProbeState. +func (in *ContainerProbeState) DeepCopy() *ContainerProbeState { + if in == nil { + return nil + } + out := new(ContainerProbeState) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ContainerRecreateRequest) DeepCopyInto(out *ContainerRecreateRequest) { *out = *in @@ -1617,6 +1666,109 @@ func (in *NodeImageStatus) DeepCopy() *NodeImageStatus { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *NodePodProbe) DeepCopyInto(out *NodePodProbe) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + in.Status.DeepCopyInto(&out.Status) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NodePodProbe. +func (in *NodePodProbe) DeepCopy() *NodePodProbe { + if in == nil { + return nil + } + out := new(NodePodProbe) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *NodePodProbe) 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 *NodePodProbeList) DeepCopyInto(out *NodePodProbeList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]NodePodProbe, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NodePodProbeList. +func (in *NodePodProbeList) DeepCopy() *NodePodProbeList { + if in == nil { + return nil + } + out := new(NodePodProbeList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *NodePodProbeList) 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 *NodePodProbeSpec) DeepCopyInto(out *NodePodProbeSpec) { + *out = *in + if in.PodProbes != nil { + in, out := &in.PodProbes, &out.PodProbes + *out = make([]PodProbe, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NodePodProbeSpec. +func (in *NodePodProbeSpec) DeepCopy() *NodePodProbeSpec { + if in == nil { + return nil + } + out := new(NodePodProbeSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *NodePodProbeStatus) DeepCopyInto(out *NodePodProbeStatus) { + *out = *in + if in.PodProbeStatuses != nil { + in, out := &in.PodProbeStatuses, &out.PodProbeStatuses + *out = make([]PodProbeStatus, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NodePodProbeStatus. +func (in *NodePodProbeStatus) DeepCopy() *NodePodProbeStatus { + if in == nil { + return nil + } + out := new(NodePodProbeStatus) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *NodeTopologyTerm) DeepCopyInto(out *NodeTopologyTerm) { *out = *in @@ -1746,6 +1898,174 @@ func (in *PersistentPodStateStatus) DeepCopy() *PersistentPodStateStatus { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *PodContainerProbe) DeepCopyInto(out *PodContainerProbe) { + *out = *in + in.Probe.DeepCopyInto(&out.Probe) + if in.MarkerPolicy != nil { + in, out := &in.MarkerPolicy, &out.MarkerPolicy + *out = make([]ProbeMarkerPolicy, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PodContainerProbe. +func (in *PodContainerProbe) DeepCopy() *PodContainerProbe { + if in == nil { + return nil + } + out := new(PodContainerProbe) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *PodProbe) DeepCopyInto(out *PodProbe) { + *out = *in + if in.Probes != nil { + in, out := &in.Probes, &out.Probes + *out = make([]ContainerProbe, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PodProbe. +func (in *PodProbe) DeepCopy() *PodProbe { + if in == nil { + return nil + } + out := new(PodProbe) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *PodProbeMarker) DeepCopyInto(out *PodProbeMarker) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + out.Status = in.Status +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PodProbeMarker. +func (in *PodProbeMarker) DeepCopy() *PodProbeMarker { + if in == nil { + return nil + } + out := new(PodProbeMarker) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *PodProbeMarker) 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 *PodProbeMarkerList) DeepCopyInto(out *PodProbeMarkerList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]PodProbeMarker, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PodProbeMarkerList. +func (in *PodProbeMarkerList) DeepCopy() *PodProbeMarkerList { + if in == nil { + return nil + } + out := new(PodProbeMarkerList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *PodProbeMarkerList) 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 *PodProbeMarkerSpec) DeepCopyInto(out *PodProbeMarkerSpec) { + *out = *in + if in.Selector != nil { + in, out := &in.Selector, &out.Selector + *out = new(metav1.LabelSelector) + (*in).DeepCopyInto(*out) + } + if in.Probes != nil { + in, out := &in.Probes, &out.Probes + *out = make([]PodContainerProbe, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PodProbeMarkerSpec. +func (in *PodProbeMarkerSpec) DeepCopy() *PodProbeMarkerSpec { + if in == nil { + return nil + } + out := new(PodProbeMarkerSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *PodProbeMarkerStatus) DeepCopyInto(out *PodProbeMarkerStatus) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PodProbeMarkerStatus. +func (in *PodProbeMarkerStatus) DeepCopy() *PodProbeMarkerStatus { + if in == nil { + return nil + } + out := new(PodProbeMarkerStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *PodProbeStatus) DeepCopyInto(out *PodProbeStatus) { + *out = *in + if in.ProbeStates != nil { + in, out := &in.ProbeStates, &out.ProbeStates + *out = make([]ContainerProbeState, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PodProbeStatus. +func (in *PodProbeStatus) DeepCopy() *PodProbeStatus { + if in == nil { + return nil + } + out := new(PodProbeStatus) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *PodState) DeepCopyInto(out *PodState) { *out = *in @@ -1814,6 +2134,35 @@ func (in *ProbeHandler) DeepCopy() *ProbeHandler { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ProbeMarkerPolicy) DeepCopyInto(out *ProbeMarkerPolicy) { + *out = *in + if in.Labels != nil { + in, out := &in.Labels, &out.Labels + *out = make(map[string]string, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + } + if in.Annotations != nil { + in, out := &in.Annotations, &out.Annotations + *out = make(map[string]string, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ProbeMarkerPolicy. +func (in *ProbeMarkerPolicy) DeepCopy() *ProbeMarkerPolicy { + if in == nil { + return nil + } + out := new(ProbeMarkerPolicy) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *PullPolicy) DeepCopyInto(out *PullPolicy) { *out = *in diff --git a/config/crd/bases/apps.kruise.io_nodepodprobes.yaml b/config/crd/bases/apps.kruise.io_nodepodprobes.yaml new file mode 100644 index 0000000000..2b34e034a4 --- /dev/null +++ b/config/crd/bases/apps.kruise.io_nodepodprobes.yaml @@ -0,0 +1,276 @@ + +--- +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + annotations: + controller-gen.kubebuilder.io/version: v0.7.0 + creationTimestamp: null + name: nodepodprobes.apps.kruise.io +spec: + group: apps.kruise.io + names: + kind: NodePodProbe + listKind: NodePodProbeList + plural: nodepodprobes + singular: nodepodprobe + scope: Cluster + versions: + - name: v1alpha1 + schema: + openAPIV3Schema: + description: NodePodProbe is the Schema for the NodePodProbe API + properties: + apiVersion: + description: 'APIVersion defines the versioned schema of this representation + of an object. Servers should convert recognized schemas to the latest + internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources' + type: string + kind: + description: 'Kind is a string value representing the REST resource this + object represents. Servers may infer this from the endpoint the client + submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds' + type: string + metadata: + type: object + spec: + description: NodePodProbeSpec defines the desired state of NodePodProbe + properties: + podProbes: + items: + properties: + name: + description: pod name + type: string + namespace: + description: pod namespace + type: string + probes: + description: Custom container probe, supports Exec, Tcp, and + returns the result to Pod yaml + items: + properties: + containerName: + description: container name + type: string + name: + description: probe name, unique within the Pod(Even between + different containers, they cannot be the same) + type: string + podProbeMarkerName: + description: Used for NodeProbeProbe to quickly find the + corresponding PodProbeMarker resource. + type: string + probe: + description: container probe spec + properties: + exec: + description: One and only one of the following should + be specified. Exec specifies the action to take. + properties: + command: + description: Command is the command line to execute + inside the container, the working directory + for the command is root ('/') in the container's + filesystem. The command is simply exec'd, it + is not run inside a shell, so traditional shell + instructions ('|', etc) won't work. To use a + shell, you need to explicitly call out to that + shell. Exit status of 0 is treated as live/healthy + and non-zero is unhealthy. + items: + type: string + type: array + type: object + failureThreshold: + description: Minimum consecutive failures for the + probe to be considered failed after having succeeded. + Defaults to 3. Minimum value is 1. + format: int32 + type: integer + httpGet: + description: HTTPGet specifies the http request to + perform. + properties: + host: + description: Host name to connect to, defaults + to the pod IP. You probably want to set "Host" + in httpHeaders instead. + type: string + httpHeaders: + description: Custom headers to set in the request. + HTTP allows repeated headers. + items: + description: HTTPHeader describes a custom header + to be used in HTTP probes + properties: + name: + description: The header field name + type: string + value: + description: The header field value + type: string + required: + - name + - value + type: object + type: array + path: + description: Path to access on the HTTP server. + type: string + port: + anyOf: + - type: integer + - type: string + description: Name or number of the port to access + on the container. Number must be in the range + 1 to 65535. Name must be an IANA_SVC_NAME. + x-kubernetes-int-or-string: true + scheme: + description: Scheme to use for connecting to the + host. Defaults to HTTP. + type: string + required: + - port + type: object + initialDelaySeconds: + description: 'Number of seconds after the container + has started before liveness probes are initiated. + More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes' + format: int32 + type: integer + periodSeconds: + description: How often (in seconds) to perform the + probe. Default to 10 seconds. Minimum value is 1. + format: int32 + type: integer + successThreshold: + description: Minimum consecutive successes for the + probe to be considered successful after having failed. + Defaults to 1. Must be 1 for liveness and startup. + Minimum value is 1. + format: int32 + type: integer + tcpSocket: + description: 'TCPSocket specifies an action involving + a TCP port. TCP hooks not yet supported TODO: implement + a realistic TCP lifecycle hook' + properties: + host: + description: 'Optional: Host name to connect to, + defaults to the pod IP.' + type: string + port: + anyOf: + - type: integer + - type: string + description: Number or name of the port to access + on the container. Number must be in the range + 1 to 65535. Name must be an IANA_SVC_NAME. + x-kubernetes-int-or-string: true + required: + - port + type: object + terminationGracePeriodSeconds: + description: Optional duration in seconds the pod + needs to terminate gracefully upon probe failure. + The grace period is the duration in seconds after + the processes running in the pod are sent a termination + signal and the time when the processes are forcibly + halted with a kill signal. Set this value longer + than the expected cleanup time for your process. + If this value is nil, the pod's terminationGracePeriodSeconds + will be used. Otherwise, this value overrides the + value provided by the pod spec. Value must be non-negative + integer. The value zero indicates stop immediately + via the kill signal (no opportunity to shut down). + This is a beta field and requires enabling ProbeTerminationGracePeriod + feature gate. Minimum value is 1. spec.terminationGracePeriodSeconds + is used if unset. + format: int64 + type: integer + timeoutSeconds: + description: 'Number of seconds after which the probe + times out. Defaults to 1 second. Minimum value is + 1. More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes' + format: int32 + type: integer + type: object + required: + - containerName + - name + - probe + type: object + type: array + uid: + description: pod uid + type: string + required: + - name + - namespace + - uid + type: object + type: array + type: object + status: + properties: + podProbeStatuses: + description: pod probe results + items: + properties: + name: + description: pod name + type: string + namespace: + description: pod namespace + type: string + probeStates: + description: pod probe result + items: + properties: + lastProbeTime: + description: Last time we probed the condition. + format: date-time + type: string + lastTransitionTime: + description: Last time the condition transitioned from + one status to another. + format: date-time + type: string + message: + description: If Status=True, Message records the return + result of Probe. If Status=False, Message records Probe's + error message + type: string + name: + description: probe name + type: string + state: + description: container probe exec state, True or False + type: string + required: + - name + - state + type: object + type: array + uid: + description: pod uid + type: string + required: + - name + - namespace + - uid + type: object + type: array + type: object + type: object + served: true + storage: true + subresources: + status: {} +status: + acceptedNames: + kind: "" + plural: "" + conditions: [] + storedVersions: [] diff --git a/config/crd/bases/apps.kruise.io_podprobemarkers.yaml b/config/crd/bases/apps.kruise.io_podprobemarkers.yaml new file mode 100644 index 0000000000..a1f88a76cc --- /dev/null +++ b/config/crd/bases/apps.kruise.io_podprobemarkers.yaml @@ -0,0 +1,294 @@ + +--- +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + annotations: + controller-gen.kubebuilder.io/version: v0.7.0 + creationTimestamp: null + name: podprobemarkers.apps.kruise.io +spec: + group: apps.kruise.io + names: + kind: PodProbeMarker + listKind: PodProbeMarkerList + plural: podprobemarkers + singular: podprobemarker + scope: Namespaced + versions: + - name: v1alpha1 + schema: + openAPIV3Schema: + description: PodProbeMarker is the Schema for the PodProbeMarker API + properties: + apiVersion: + description: 'APIVersion defines the versioned schema of this representation + of an object. Servers should convert recognized schemas to the latest + internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources' + type: string + kind: + description: 'Kind is a string value representing the REST resource this + object represents. Servers may infer this from the endpoint the client + submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds' + type: string + metadata: + type: object + spec: + description: PodProbeMarkerSpec defines the desired state of PodProbeMarker + properties: + probes: + description: Custom container probe, current only support Exec(). + Probe Result will record in Pod.Status.Conditions, and condition.type=probe.name. + condition.status=True indicates probe success condition.status=False + indicates probe fails + items: + properties: + containerName: + description: container name + type: string + markerPolicy: + description: 'According to the execution result of ContainerProbe, + perform specific actions, such as: patch Pod labels, annotations, + ReadinessGate Condition' + items: + properties: + annotations: + additionalProperties: + type: string + description: Patch annotations pod.annotations + type: object + labels: + additionalProperties: + type: string + description: Patch Labels pod.labels + type: object + state: + description: 'probe status, True or False For example: + State=Succeeded, annotations[controller.kubernetes.io/pod-deletion-cost] + = ''10''. State=Failed, annotations[controller.kubernetes.io/pod-deletion-cost] + = ''-10''. In addition, if State=Failed is not defined, + Exec execution fails, and the annotations[controller.kubernetes.io/pod-deletion-cost] + will be Deleted' + type: string + required: + - state + type: object + type: array + name: + description: probe name, unique within the Pod(Even between + different containers, they cannot be the same) + type: string + probe: + description: container probe spec + properties: + exec: + description: One and only one of the following should be + specified. Exec specifies the action to take. + properties: + command: + description: Command is the command line to execute + inside the container, the working directory for the + command is root ('/') in the container's filesystem. + The command is simply exec'd, it is not run inside + a shell, so traditional shell instructions ('|', etc) + won't work. To use a shell, you need to explicitly + call out to that shell. Exit status of 0 is treated + as live/healthy and non-zero is unhealthy. + items: + type: string + type: array + type: object + failureThreshold: + description: Minimum consecutive failures for the probe + to be considered failed after having succeeded. Defaults + to 3. Minimum value is 1. + format: int32 + type: integer + httpGet: + description: HTTPGet specifies the http request to perform. + properties: + host: + description: Host name to connect to, defaults to the + pod IP. You probably want to set "Host" in httpHeaders + instead. + type: string + httpHeaders: + description: Custom headers to set in the request. HTTP + allows repeated headers. + items: + description: HTTPHeader describes a custom header + to be used in HTTP probes + properties: + name: + description: The header field name + type: string + value: + description: The header field value + type: string + required: + - name + - value + type: object + type: array + path: + description: Path to access on the HTTP server. + type: string + port: + anyOf: + - type: integer + - type: string + description: Name or number of the port to access on + the container. Number must be in the range 1 to 65535. + Name must be an IANA_SVC_NAME. + x-kubernetes-int-or-string: true + scheme: + description: Scheme to use for connecting to the host. + Defaults to HTTP. + type: string + required: + - port + type: object + initialDelaySeconds: + description: 'Number of seconds after the container has + started before liveness probes are initiated. More info: + https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes' + format: int32 + type: integer + periodSeconds: + description: How often (in seconds) to perform the probe. + Default to 10 seconds. Minimum value is 1. + format: int32 + type: integer + successThreshold: + description: Minimum consecutive successes for the probe + to be considered successful after having failed. Defaults + to 1. Must be 1 for liveness and startup. Minimum value + is 1. + format: int32 + type: integer + tcpSocket: + description: 'TCPSocket specifies an action involving a + TCP port. TCP hooks not yet supported TODO: implement + a realistic TCP lifecycle hook' + properties: + host: + description: 'Optional: Host name to connect to, defaults + to the pod IP.' + type: string + port: + anyOf: + - type: integer + - type: string + description: Number or name of the port to access on + the container. Number must be in the range 1 to 65535. + Name must be an IANA_SVC_NAME. + x-kubernetes-int-or-string: true + required: + - port + type: object + terminationGracePeriodSeconds: + description: Optional duration in seconds the pod needs + to terminate gracefully upon probe failure. The grace + period is the duration in seconds after the processes + running in the pod are sent a termination signal and the + time when the processes are forcibly halted with a kill + signal. Set this value longer than the expected cleanup + time for your process. If this value is nil, the pod's + terminationGracePeriodSeconds will be used. Otherwise, + this value overrides the value provided by the pod spec. + Value must be non-negative integer. The value zero indicates + stop immediately via the kill signal (no opportunity to + shut down). This is a beta field and requires enabling + ProbeTerminationGracePeriod feature gate. Minimum value + is 1. spec.terminationGracePeriodSeconds is used if unset. + format: int64 + type: integer + timeoutSeconds: + description: 'Number of seconds after which the probe times + out. Defaults to 1 second. Minimum value is 1. More info: + https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes' + format: int32 + type: integer + type: object + required: + - containerName + - name + - probe + type: object + type: array + selector: + description: 'Selector is a label query over pods that should exec + custom probe It must match the pod template''s labels. More info: + https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/#label-selectors' + properties: + matchExpressions: + description: matchExpressions is a list of label selector requirements. + The requirements are ANDed. + items: + description: A label selector requirement is a selector that + contains values, a key, and an operator that relates the key + and values. + properties: + key: + description: key is the label key that the selector applies + to. + type: string + operator: + description: operator represents a key's relationship to + a set of values. Valid operators are In, NotIn, Exists + and DoesNotExist. + type: string + values: + description: values is an array of string values. If the + operator is In or NotIn, the values array must be non-empty. + If the operator is Exists or DoesNotExist, the values + array must be empty. This array is replaced during a strategic + merge patch. + items: + type: string + type: array + required: + - key + - operator + type: object + type: array + matchLabels: + additionalProperties: + type: string + description: matchLabels is a map of {key,value} pairs. A single + {key,value} in the matchLabels map is equivalent to an element + of matchExpressions, whose key field is "key", the operator + is "In", and the values array contains only "value". The requirements + are ANDed. + type: object + type: object + required: + - probes + - selector + type: object + status: + properties: + matchedPods: + description: matched Pods + format: int64 + type: integer + observedGeneration: + description: observedGeneration is the most recent generation observed + for this PodProbeMarker. It corresponds to the PodProbeMarker's + generation, which is updated on mutation by the API Server. + format: int64 + type: integer + required: + - observedGeneration + type: object + type: object + served: true + storage: true + subresources: + status: {} +status: + acceptedNames: + kind: "" + plural: "" + conditions: [] + storedVersions: [] diff --git a/pkg/client/clientset/versioned/typed/apps/v1alpha1/apps_client.go b/pkg/client/clientset/versioned/typed/apps/v1alpha1/apps_client.go index 095e32f4e5..80f3fe8c3d 100644 --- a/pkg/client/clientset/versioned/typed/apps/v1alpha1/apps_client.go +++ b/pkg/client/clientset/versioned/typed/apps/v1alpha1/apps_client.go @@ -33,7 +33,9 @@ type AppsV1alpha1Interface interface { EphemeralJobsGetter ImagePullJobsGetter NodeImagesGetter + NodePodProbesGetter PersistentPodStatesGetter + PodProbeMarkersGetter ResourceDistributionsGetter SidecarSetsGetter StatefulSetsGetter @@ -78,10 +80,18 @@ func (c *AppsV1alpha1Client) NodeImages() NodeImageInterface { return newNodeImages(c) } +func (c *AppsV1alpha1Client) NodePodProbes() NodePodProbeInterface { + return newNodePodProbes(c) +} + func (c *AppsV1alpha1Client) PersistentPodStates(namespace string) PersistentPodStateInterface { return newPersistentPodStates(c, namespace) } +func (c *AppsV1alpha1Client) PodProbeMarkers(namespace string) PodProbeMarkerInterface { + return newPodProbeMarkers(c, namespace) +} + func (c *AppsV1alpha1Client) ResourceDistributions() ResourceDistributionInterface { return newResourceDistributions(c) } diff --git a/pkg/client/clientset/versioned/typed/apps/v1alpha1/fake/fake_apps_client.go b/pkg/client/clientset/versioned/typed/apps/v1alpha1/fake/fake_apps_client.go index 949648129c..7a17b0192e 100644 --- a/pkg/client/clientset/versioned/typed/apps/v1alpha1/fake/fake_apps_client.go +++ b/pkg/client/clientset/versioned/typed/apps/v1alpha1/fake/fake_apps_client.go @@ -59,10 +59,18 @@ func (c *FakeAppsV1alpha1) NodeImages() v1alpha1.NodeImageInterface { return &FakeNodeImages{c} } +func (c *FakeAppsV1alpha1) NodePodProbes() v1alpha1.NodePodProbeInterface { + return &FakeNodePodProbes{c} +} + func (c *FakeAppsV1alpha1) PersistentPodStates(namespace string) v1alpha1.PersistentPodStateInterface { return &FakePersistentPodStates{c, namespace} } +func (c *FakeAppsV1alpha1) PodProbeMarkers(namespace string) v1alpha1.PodProbeMarkerInterface { + return &FakePodProbeMarkers{c, namespace} +} + func (c *FakeAppsV1alpha1) ResourceDistributions() v1alpha1.ResourceDistributionInterface { return &FakeResourceDistributions{c} } diff --git a/pkg/client/clientset/versioned/typed/apps/v1alpha1/fake/fake_nodepodprobe.go b/pkg/client/clientset/versioned/typed/apps/v1alpha1/fake/fake_nodepodprobe.go new file mode 100644 index 0000000000..1d2ff38eb3 --- /dev/null +++ b/pkg/client/clientset/versioned/typed/apps/v1alpha1/fake/fake_nodepodprobe.go @@ -0,0 +1,132 @@ +/* +Copyright 2021 The Kruise 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/openkruise/kruise/apis/apps/v1alpha1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + labels "k8s.io/apimachinery/pkg/labels" + schema "k8s.io/apimachinery/pkg/runtime/schema" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + testing "k8s.io/client-go/testing" +) + +// FakeNodePodProbes implements NodePodProbeInterface +type FakeNodePodProbes struct { + Fake *FakeAppsV1alpha1 +} + +var nodepodprobesResource = schema.GroupVersionResource{Group: "apps.kruise.io", Version: "v1alpha1", Resource: "nodepodprobes"} + +var nodepodprobesKind = schema.GroupVersionKind{Group: "apps.kruise.io", Version: "v1alpha1", Kind: "NodePodProbe"} + +// Get takes name of the nodePodProbe, and returns the corresponding nodePodProbe object, and an error if there is any. +func (c *FakeNodePodProbes) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.NodePodProbe, err error) { + obj, err := c.Fake. + Invokes(testing.NewRootGetAction(nodepodprobesResource, name), &v1alpha1.NodePodProbe{}) + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.NodePodProbe), err +} + +// List takes label and field selectors, and returns the list of NodePodProbes that match those selectors. +func (c *FakeNodePodProbes) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.NodePodProbeList, err error) { + obj, err := c.Fake. + Invokes(testing.NewRootListAction(nodepodprobesResource, nodepodprobesKind, opts), &v1alpha1.NodePodProbeList{}) + if obj == nil { + return nil, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &v1alpha1.NodePodProbeList{ListMeta: obj.(*v1alpha1.NodePodProbeList).ListMeta} + for _, item := range obj.(*v1alpha1.NodePodProbeList).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 nodePodProbes. +func (c *FakeNodePodProbes) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewRootWatchAction(nodepodprobesResource, opts)) +} + +// Create takes the representation of a nodePodProbe and creates it. Returns the server's representation of the nodePodProbe, and an error, if there is any. +func (c *FakeNodePodProbes) Create(ctx context.Context, nodePodProbe *v1alpha1.NodePodProbe, opts v1.CreateOptions) (result *v1alpha1.NodePodProbe, err error) { + obj, err := c.Fake. + Invokes(testing.NewRootCreateAction(nodepodprobesResource, nodePodProbe), &v1alpha1.NodePodProbe{}) + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.NodePodProbe), err +} + +// Update takes the representation of a nodePodProbe and updates it. Returns the server's representation of the nodePodProbe, and an error, if there is any. +func (c *FakeNodePodProbes) Update(ctx context.Context, nodePodProbe *v1alpha1.NodePodProbe, opts v1.UpdateOptions) (result *v1alpha1.NodePodProbe, err error) { + obj, err := c.Fake. + Invokes(testing.NewRootUpdateAction(nodepodprobesResource, nodePodProbe), &v1alpha1.NodePodProbe{}) + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.NodePodProbe), 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 *FakeNodePodProbes) UpdateStatus(ctx context.Context, nodePodProbe *v1alpha1.NodePodProbe, opts v1.UpdateOptions) (*v1alpha1.NodePodProbe, error) { + obj, err := c.Fake. + Invokes(testing.NewRootUpdateSubresourceAction(nodepodprobesResource, "status", nodePodProbe), &v1alpha1.NodePodProbe{}) + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.NodePodProbe), err +} + +// Delete takes name of the nodePodProbe and deletes it. Returns an error if one occurs. +func (c *FakeNodePodProbes) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewRootDeleteAction(nodepodprobesResource, name), &v1alpha1.NodePodProbe{}) + return err +} + +// DeleteCollection deletes a collection of objects. +func (c *FakeNodePodProbes) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + action := testing.NewRootDeleteCollectionAction(nodepodprobesResource, listOpts) + + _, err := c.Fake.Invokes(action, &v1alpha1.NodePodProbeList{}) + return err +} + +// Patch applies the patch and returns the patched nodePodProbe. +func (c *FakeNodePodProbes) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.NodePodProbe, err error) { + obj, err := c.Fake. + Invokes(testing.NewRootPatchSubresourceAction(nodepodprobesResource, name, pt, data, subresources...), &v1alpha1.NodePodProbe{}) + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.NodePodProbe), err +} diff --git a/pkg/client/clientset/versioned/typed/apps/v1alpha1/fake/fake_podprobemarker.go b/pkg/client/clientset/versioned/typed/apps/v1alpha1/fake/fake_podprobemarker.go new file mode 100644 index 0000000000..973d3bc708 --- /dev/null +++ b/pkg/client/clientset/versioned/typed/apps/v1alpha1/fake/fake_podprobemarker.go @@ -0,0 +1,141 @@ +/* +Copyright 2021 The Kruise 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/openkruise/kruise/apis/apps/v1alpha1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + labels "k8s.io/apimachinery/pkg/labels" + schema "k8s.io/apimachinery/pkg/runtime/schema" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + testing "k8s.io/client-go/testing" +) + +// FakePodProbeMarkers implements PodProbeMarkerInterface +type FakePodProbeMarkers struct { + Fake *FakeAppsV1alpha1 + ns string +} + +var podprobemarkersResource = schema.GroupVersionResource{Group: "apps.kruise.io", Version: "v1alpha1", Resource: "podprobemarkers"} + +var podprobemarkersKind = schema.GroupVersionKind{Group: "apps.kruise.io", Version: "v1alpha1", Kind: "PodProbeMarker"} + +// Get takes name of the podProbeMarker, and returns the corresponding podProbeMarker object, and an error if there is any. +func (c *FakePodProbeMarkers) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.PodProbeMarker, err error) { + obj, err := c.Fake. + Invokes(testing.NewGetAction(podprobemarkersResource, c.ns, name), &v1alpha1.PodProbeMarker{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.PodProbeMarker), err +} + +// List takes label and field selectors, and returns the list of PodProbeMarkers that match those selectors. +func (c *FakePodProbeMarkers) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.PodProbeMarkerList, err error) { + obj, err := c.Fake. + Invokes(testing.NewListAction(podprobemarkersResource, podprobemarkersKind, c.ns, opts), &v1alpha1.PodProbeMarkerList{}) + + if obj == nil { + return nil, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &v1alpha1.PodProbeMarkerList{ListMeta: obj.(*v1alpha1.PodProbeMarkerList).ListMeta} + for _, item := range obj.(*v1alpha1.PodProbeMarkerList).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 podProbeMarkers. +func (c *FakePodProbeMarkers) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewWatchAction(podprobemarkersResource, c.ns, opts)) + +} + +// Create takes the representation of a podProbeMarker and creates it. Returns the server's representation of the podProbeMarker, and an error, if there is any. +func (c *FakePodProbeMarkers) Create(ctx context.Context, podProbeMarker *v1alpha1.PodProbeMarker, opts v1.CreateOptions) (result *v1alpha1.PodProbeMarker, err error) { + obj, err := c.Fake. + Invokes(testing.NewCreateAction(podprobemarkersResource, c.ns, podProbeMarker), &v1alpha1.PodProbeMarker{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.PodProbeMarker), err +} + +// Update takes the representation of a podProbeMarker and updates it. Returns the server's representation of the podProbeMarker, and an error, if there is any. +func (c *FakePodProbeMarkers) Update(ctx context.Context, podProbeMarker *v1alpha1.PodProbeMarker, opts v1.UpdateOptions) (result *v1alpha1.PodProbeMarker, err error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateAction(podprobemarkersResource, c.ns, podProbeMarker), &v1alpha1.PodProbeMarker{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.PodProbeMarker), 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 *FakePodProbeMarkers) UpdateStatus(ctx context.Context, podProbeMarker *v1alpha1.PodProbeMarker, opts v1.UpdateOptions) (*v1alpha1.PodProbeMarker, error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateSubresourceAction(podprobemarkersResource, "status", c.ns, podProbeMarker), &v1alpha1.PodProbeMarker{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.PodProbeMarker), err +} + +// Delete takes name of the podProbeMarker and deletes it. Returns an error if one occurs. +func (c *FakePodProbeMarkers) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewDeleteAction(podprobemarkersResource, c.ns, name), &v1alpha1.PodProbeMarker{}) + + return err +} + +// DeleteCollection deletes a collection of objects. +func (c *FakePodProbeMarkers) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + action := testing.NewDeleteCollectionAction(podprobemarkersResource, c.ns, listOpts) + + _, err := c.Fake.Invokes(action, &v1alpha1.PodProbeMarkerList{}) + return err +} + +// Patch applies the patch and returns the patched podProbeMarker. +func (c *FakePodProbeMarkers) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.PodProbeMarker, err error) { + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceAction(podprobemarkersResource, c.ns, name, pt, data, subresources...), &v1alpha1.PodProbeMarker{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.PodProbeMarker), err +} diff --git a/pkg/client/clientset/versioned/typed/apps/v1alpha1/generated_expansion.go b/pkg/client/clientset/versioned/typed/apps/v1alpha1/generated_expansion.go index b0474a7450..bced157d78 100644 --- a/pkg/client/clientset/versioned/typed/apps/v1alpha1/generated_expansion.go +++ b/pkg/client/clientset/versioned/typed/apps/v1alpha1/generated_expansion.go @@ -33,8 +33,12 @@ type ImagePullJobExpansion interface{} type NodeImageExpansion interface{} +type NodePodProbeExpansion interface{} + type PersistentPodStateExpansion interface{} +type PodProbeMarkerExpansion interface{} + type ResourceDistributionExpansion interface{} type SidecarSetExpansion interface{} diff --git a/pkg/client/clientset/versioned/typed/apps/v1alpha1/nodepodprobe.go b/pkg/client/clientset/versioned/typed/apps/v1alpha1/nodepodprobe.go new file mode 100644 index 0000000000..44bc4e3a46 --- /dev/null +++ b/pkg/client/clientset/versioned/typed/apps/v1alpha1/nodepodprobe.go @@ -0,0 +1,183 @@ +/* +Copyright 2021 The Kruise 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/openkruise/kruise/apis/apps/v1alpha1" + scheme "github.com/openkruise/kruise/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" +) + +// NodePodProbesGetter has a method to return a NodePodProbeInterface. +// A group's client should implement this interface. +type NodePodProbesGetter interface { + NodePodProbes() NodePodProbeInterface +} + +// NodePodProbeInterface has methods to work with NodePodProbe resources. +type NodePodProbeInterface interface { + Create(ctx context.Context, nodePodProbe *v1alpha1.NodePodProbe, opts v1.CreateOptions) (*v1alpha1.NodePodProbe, error) + Update(ctx context.Context, nodePodProbe *v1alpha1.NodePodProbe, opts v1.UpdateOptions) (*v1alpha1.NodePodProbe, error) + UpdateStatus(ctx context.Context, nodePodProbe *v1alpha1.NodePodProbe, opts v1.UpdateOptions) (*v1alpha1.NodePodProbe, 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.NodePodProbe, error) + List(ctx context.Context, opts v1.ListOptions) (*v1alpha1.NodePodProbeList, 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.NodePodProbe, err error) + NodePodProbeExpansion +} + +// nodePodProbes implements NodePodProbeInterface +type nodePodProbes struct { + client rest.Interface +} + +// newNodePodProbes returns a NodePodProbes +func newNodePodProbes(c *AppsV1alpha1Client) *nodePodProbes { + return &nodePodProbes{ + client: c.RESTClient(), + } +} + +// Get takes name of the nodePodProbe, and returns the corresponding nodePodProbe object, and an error if there is any. +func (c *nodePodProbes) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.NodePodProbe, err error) { + result = &v1alpha1.NodePodProbe{} + err = c.client.Get(). + Resource("nodepodprobes"). + Name(name). + VersionedParams(&options, scheme.ParameterCodec). + Do(ctx). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of NodePodProbes that match those selectors. +func (c *nodePodProbes) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.NodePodProbeList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1alpha1.NodePodProbeList{} + err = c.client.Get(). + Resource("nodepodprobes"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Do(ctx). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested nodePodProbes. +func (c *nodePodProbes) 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("nodepodprobes"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Watch(ctx) +} + +// Create takes the representation of a nodePodProbe and creates it. Returns the server's representation of the nodePodProbe, and an error, if there is any. +func (c *nodePodProbes) Create(ctx context.Context, nodePodProbe *v1alpha1.NodePodProbe, opts v1.CreateOptions) (result *v1alpha1.NodePodProbe, err error) { + result = &v1alpha1.NodePodProbe{} + err = c.client.Post(). + Resource("nodepodprobes"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(nodePodProbe). + Do(ctx). + Into(result) + return +} + +// Update takes the representation of a nodePodProbe and updates it. Returns the server's representation of the nodePodProbe, and an error, if there is any. +func (c *nodePodProbes) Update(ctx context.Context, nodePodProbe *v1alpha1.NodePodProbe, opts v1.UpdateOptions) (result *v1alpha1.NodePodProbe, err error) { + result = &v1alpha1.NodePodProbe{} + err = c.client.Put(). + Resource("nodepodprobes"). + Name(nodePodProbe.Name). + VersionedParams(&opts, scheme.ParameterCodec). + Body(nodePodProbe). + 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 *nodePodProbes) UpdateStatus(ctx context.Context, nodePodProbe *v1alpha1.NodePodProbe, opts v1.UpdateOptions) (result *v1alpha1.NodePodProbe, err error) { + result = &v1alpha1.NodePodProbe{} + err = c.client.Put(). + Resource("nodepodprobes"). + Name(nodePodProbe.Name). + SubResource("status"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(nodePodProbe). + Do(ctx). + Into(result) + return +} + +// Delete takes name of the nodePodProbe and deletes it. Returns an error if one occurs. +func (c *nodePodProbes) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + return c.client.Delete(). + Resource("nodepodprobes"). + Name(name). + Body(&opts). + Do(ctx). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *nodePodProbes) 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("nodepodprobes"). + VersionedParams(&listOpts, scheme.ParameterCodec). + Timeout(timeout). + Body(&opts). + Do(ctx). + Error() +} + +// Patch applies the patch and returns the patched nodePodProbe. +func (c *nodePodProbes) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.NodePodProbe, err error) { + result = &v1alpha1.NodePodProbe{} + err = c.client.Patch(pt). + Resource("nodepodprobes"). + Name(name). + SubResource(subresources...). + VersionedParams(&opts, scheme.ParameterCodec). + Body(data). + Do(ctx). + Into(result) + return +} diff --git a/pkg/client/clientset/versioned/typed/apps/v1alpha1/podprobemarker.go b/pkg/client/clientset/versioned/typed/apps/v1alpha1/podprobemarker.go new file mode 100644 index 0000000000..0bb3dd7740 --- /dev/null +++ b/pkg/client/clientset/versioned/typed/apps/v1alpha1/podprobemarker.go @@ -0,0 +1,194 @@ +/* +Copyright 2021 The Kruise 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/openkruise/kruise/apis/apps/v1alpha1" + scheme "github.com/openkruise/kruise/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" +) + +// PodProbeMarkersGetter has a method to return a PodProbeMarkerInterface. +// A group's client should implement this interface. +type PodProbeMarkersGetter interface { + PodProbeMarkers(namespace string) PodProbeMarkerInterface +} + +// PodProbeMarkerInterface has methods to work with PodProbeMarker resources. +type PodProbeMarkerInterface interface { + Create(ctx context.Context, podProbeMarker *v1alpha1.PodProbeMarker, opts v1.CreateOptions) (*v1alpha1.PodProbeMarker, error) + Update(ctx context.Context, podProbeMarker *v1alpha1.PodProbeMarker, opts v1.UpdateOptions) (*v1alpha1.PodProbeMarker, error) + UpdateStatus(ctx context.Context, podProbeMarker *v1alpha1.PodProbeMarker, opts v1.UpdateOptions) (*v1alpha1.PodProbeMarker, 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.PodProbeMarker, error) + List(ctx context.Context, opts v1.ListOptions) (*v1alpha1.PodProbeMarkerList, 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.PodProbeMarker, err error) + PodProbeMarkerExpansion +} + +// podProbeMarkers implements PodProbeMarkerInterface +type podProbeMarkers struct { + client rest.Interface + ns string +} + +// newPodProbeMarkers returns a PodProbeMarkers +func newPodProbeMarkers(c *AppsV1alpha1Client, namespace string) *podProbeMarkers { + return &podProbeMarkers{ + client: c.RESTClient(), + ns: namespace, + } +} + +// Get takes name of the podProbeMarker, and returns the corresponding podProbeMarker object, and an error if there is any. +func (c *podProbeMarkers) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.PodProbeMarker, err error) { + result = &v1alpha1.PodProbeMarker{} + err = c.client.Get(). + Namespace(c.ns). + Resource("podprobemarkers"). + Name(name). + VersionedParams(&options, scheme.ParameterCodec). + Do(ctx). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of PodProbeMarkers that match those selectors. +func (c *podProbeMarkers) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.PodProbeMarkerList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1alpha1.PodProbeMarkerList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("podprobemarkers"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Do(ctx). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested podProbeMarkers. +func (c *podProbeMarkers) 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(). + Namespace(c.ns). + Resource("podprobemarkers"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Watch(ctx) +} + +// Create takes the representation of a podProbeMarker and creates it. Returns the server's representation of the podProbeMarker, and an error, if there is any. +func (c *podProbeMarkers) Create(ctx context.Context, podProbeMarker *v1alpha1.PodProbeMarker, opts v1.CreateOptions) (result *v1alpha1.PodProbeMarker, err error) { + result = &v1alpha1.PodProbeMarker{} + err = c.client.Post(). + Namespace(c.ns). + Resource("podprobemarkers"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(podProbeMarker). + Do(ctx). + Into(result) + return +} + +// Update takes the representation of a podProbeMarker and updates it. Returns the server's representation of the podProbeMarker, and an error, if there is any. +func (c *podProbeMarkers) Update(ctx context.Context, podProbeMarker *v1alpha1.PodProbeMarker, opts v1.UpdateOptions) (result *v1alpha1.PodProbeMarker, err error) { + result = &v1alpha1.PodProbeMarker{} + err = c.client.Put(). + Namespace(c.ns). + Resource("podprobemarkers"). + Name(podProbeMarker.Name). + VersionedParams(&opts, scheme.ParameterCodec). + Body(podProbeMarker). + 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 *podProbeMarkers) UpdateStatus(ctx context.Context, podProbeMarker *v1alpha1.PodProbeMarker, opts v1.UpdateOptions) (result *v1alpha1.PodProbeMarker, err error) { + result = &v1alpha1.PodProbeMarker{} + err = c.client.Put(). + Namespace(c.ns). + Resource("podprobemarkers"). + Name(podProbeMarker.Name). + SubResource("status"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(podProbeMarker). + Do(ctx). + Into(result) + return +} + +// Delete takes name of the podProbeMarker and deletes it. Returns an error if one occurs. +func (c *podProbeMarkers) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + return c.client.Delete(). + Namespace(c.ns). + Resource("podprobemarkers"). + Name(name). + Body(&opts). + Do(ctx). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *podProbeMarkers) 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(). + Namespace(c.ns). + Resource("podprobemarkers"). + VersionedParams(&listOpts, scheme.ParameterCodec). + Timeout(timeout). + Body(&opts). + Do(ctx). + Error() +} + +// Patch applies the patch and returns the patched podProbeMarker. +func (c *podProbeMarkers) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.PodProbeMarker, err error) { + result = &v1alpha1.PodProbeMarker{} + err = c.client.Patch(pt). + Namespace(c.ns). + Resource("podprobemarkers"). + Name(name). + SubResource(subresources...). + VersionedParams(&opts, scheme.ParameterCodec). + Body(data). + Do(ctx). + Into(result) + return +} diff --git a/pkg/client/informers/externalversions/apps/v1alpha1/interface.go b/pkg/client/informers/externalversions/apps/v1alpha1/interface.go index 712dca6647..77eae8b954 100644 --- a/pkg/client/informers/externalversions/apps/v1alpha1/interface.go +++ b/pkg/client/informers/externalversions/apps/v1alpha1/interface.go @@ -39,8 +39,12 @@ type Interface interface { ImagePullJobs() ImagePullJobInformer // NodeImages returns a NodeImageInformer. NodeImages() NodeImageInformer + // NodePodProbes returns a NodePodProbeInformer. + NodePodProbes() NodePodProbeInformer // PersistentPodStates returns a PersistentPodStateInformer. PersistentPodStates() PersistentPodStateInformer + // PodProbeMarkers returns a PodProbeMarkerInformer. + PodProbeMarkers() PodProbeMarkerInformer // ResourceDistributions returns a ResourceDistributionInformer. ResourceDistributions() ResourceDistributionInformer // SidecarSets returns a SidecarSetInformer. @@ -104,11 +108,21 @@ func (v *version) NodeImages() NodeImageInformer { return &nodeImageInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} } +// NodePodProbes returns a NodePodProbeInformer. +func (v *version) NodePodProbes() NodePodProbeInformer { + return &nodePodProbeInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} +} + // PersistentPodStates returns a PersistentPodStateInformer. func (v *version) PersistentPodStates() PersistentPodStateInformer { return &persistentPodStateInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} } +// PodProbeMarkers returns a PodProbeMarkerInformer. +func (v *version) PodProbeMarkers() PodProbeMarkerInformer { + return &podProbeMarkerInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} +} + // ResourceDistributions returns a ResourceDistributionInformer. func (v *version) ResourceDistributions() ResourceDistributionInformer { return &resourceDistributionInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} diff --git a/pkg/client/informers/externalversions/apps/v1alpha1/nodepodprobe.go b/pkg/client/informers/externalversions/apps/v1alpha1/nodepodprobe.go new file mode 100644 index 0000000000..668632ceda --- /dev/null +++ b/pkg/client/informers/externalversions/apps/v1alpha1/nodepodprobe.go @@ -0,0 +1,88 @@ +/* +Copyright 2021 The Kruise 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" + + appsv1alpha1 "github.com/openkruise/kruise/apis/apps/v1alpha1" + versioned "github.com/openkruise/kruise/pkg/client/clientset/versioned" + internalinterfaces "github.com/openkruise/kruise/pkg/client/informers/externalversions/internalinterfaces" + v1alpha1 "github.com/openkruise/kruise/pkg/client/listers/apps/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" +) + +// NodePodProbeInformer provides access to a shared informer and lister for +// NodePodProbes. +type NodePodProbeInformer interface { + Informer() cache.SharedIndexInformer + Lister() v1alpha1.NodePodProbeLister +} + +type nodePodProbeInformer struct { + factory internalinterfaces.SharedInformerFactory + tweakListOptions internalinterfaces.TweakListOptionsFunc +} + +// NewNodePodProbeInformer constructs a new informer for NodePodProbe 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 NewNodePodProbeInformer(client versioned.Interface, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { + return NewFilteredNodePodProbeInformer(client, resyncPeriod, indexers, nil) +} + +// NewFilteredNodePodProbeInformer constructs a new informer for NodePodProbe 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 NewFilteredNodePodProbeInformer(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.AppsV1alpha1().NodePodProbes().List(context.TODO(), options) + }, + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.AppsV1alpha1().NodePodProbes().Watch(context.TODO(), options) + }, + }, + &appsv1alpha1.NodePodProbe{}, + resyncPeriod, + indexers, + ) +} + +func (f *nodePodProbeInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { + return NewFilteredNodePodProbeInformer(client, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) +} + +func (f *nodePodProbeInformer) Informer() cache.SharedIndexInformer { + return f.factory.InformerFor(&appsv1alpha1.NodePodProbe{}, f.defaultInformer) +} + +func (f *nodePodProbeInformer) Lister() v1alpha1.NodePodProbeLister { + return v1alpha1.NewNodePodProbeLister(f.Informer().GetIndexer()) +} diff --git a/pkg/client/informers/externalversions/apps/v1alpha1/podprobemarker.go b/pkg/client/informers/externalversions/apps/v1alpha1/podprobemarker.go new file mode 100644 index 0000000000..77b5fd272b --- /dev/null +++ b/pkg/client/informers/externalversions/apps/v1alpha1/podprobemarker.go @@ -0,0 +1,89 @@ +/* +Copyright 2021 The Kruise 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" + + appsv1alpha1 "github.com/openkruise/kruise/apis/apps/v1alpha1" + versioned "github.com/openkruise/kruise/pkg/client/clientset/versioned" + internalinterfaces "github.com/openkruise/kruise/pkg/client/informers/externalversions/internalinterfaces" + v1alpha1 "github.com/openkruise/kruise/pkg/client/listers/apps/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" +) + +// PodProbeMarkerInformer provides access to a shared informer and lister for +// PodProbeMarkers. +type PodProbeMarkerInformer interface { + Informer() cache.SharedIndexInformer + Lister() v1alpha1.PodProbeMarkerLister +} + +type podProbeMarkerInformer struct { + factory internalinterfaces.SharedInformerFactory + tweakListOptions internalinterfaces.TweakListOptionsFunc + namespace string +} + +// NewPodProbeMarkerInformer constructs a new informer for PodProbeMarker 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 NewPodProbeMarkerInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { + return NewFilteredPodProbeMarkerInformer(client, namespace, resyncPeriod, indexers, nil) +} + +// NewFilteredPodProbeMarkerInformer constructs a new informer for PodProbeMarker 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 NewFilteredPodProbeMarkerInformer(client versioned.Interface, namespace string, 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.AppsV1alpha1().PodProbeMarkers(namespace).List(context.TODO(), options) + }, + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.AppsV1alpha1().PodProbeMarkers(namespace).Watch(context.TODO(), options) + }, + }, + &appsv1alpha1.PodProbeMarker{}, + resyncPeriod, + indexers, + ) +} + +func (f *podProbeMarkerInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { + return NewFilteredPodProbeMarkerInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) +} + +func (f *podProbeMarkerInformer) Informer() cache.SharedIndexInformer { + return f.factory.InformerFor(&appsv1alpha1.PodProbeMarker{}, f.defaultInformer) +} + +func (f *podProbeMarkerInformer) Lister() v1alpha1.PodProbeMarkerLister { + return v1alpha1.NewPodProbeMarkerLister(f.Informer().GetIndexer()) +} diff --git a/pkg/client/informers/externalversions/generic.go b/pkg/client/informers/externalversions/generic.go index a6b88c800d..cd9da8f30d 100644 --- a/pkg/client/informers/externalversions/generic.go +++ b/pkg/client/informers/externalversions/generic.go @@ -70,8 +70,12 @@ func (f *sharedInformerFactory) ForResource(resource schema.GroupVersionResource return &genericInformer{resource: resource.GroupResource(), informer: f.Apps().V1alpha1().ImagePullJobs().Informer()}, nil case v1alpha1.SchemeGroupVersion.WithResource("nodeimages"): return &genericInformer{resource: resource.GroupResource(), informer: f.Apps().V1alpha1().NodeImages().Informer()}, nil + case v1alpha1.SchemeGroupVersion.WithResource("nodepodprobes"): + return &genericInformer{resource: resource.GroupResource(), informer: f.Apps().V1alpha1().NodePodProbes().Informer()}, nil case v1alpha1.SchemeGroupVersion.WithResource("persistentpodstates"): return &genericInformer{resource: resource.GroupResource(), informer: f.Apps().V1alpha1().PersistentPodStates().Informer()}, nil + case v1alpha1.SchemeGroupVersion.WithResource("podprobemarkers"): + return &genericInformer{resource: resource.GroupResource(), informer: f.Apps().V1alpha1().PodProbeMarkers().Informer()}, nil case v1alpha1.SchemeGroupVersion.WithResource("resourcedistributions"): return &genericInformer{resource: resource.GroupResource(), informer: f.Apps().V1alpha1().ResourceDistributions().Informer()}, nil case v1alpha1.SchemeGroupVersion.WithResource("sidecarsets"): diff --git a/pkg/client/listers/apps/v1alpha1/expansion_generated.go b/pkg/client/listers/apps/v1alpha1/expansion_generated.go index 3e028f1228..a23d033752 100644 --- a/pkg/client/listers/apps/v1alpha1/expansion_generated.go +++ b/pkg/client/listers/apps/v1alpha1/expansion_generated.go @@ -77,6 +77,10 @@ type ImagePullJobNamespaceListerExpansion interface{} // NodeImageLister. type NodeImageListerExpansion interface{} +// NodePodProbeListerExpansion allows custom methods to be added to +// NodePodProbeLister. +type NodePodProbeListerExpansion interface{} + // PersistentPodStateListerExpansion allows custom methods to be added to // PersistentPodStateLister. type PersistentPodStateListerExpansion interface{} @@ -85,6 +89,14 @@ type PersistentPodStateListerExpansion interface{} // PersistentPodStateNamespaceLister. type PersistentPodStateNamespaceListerExpansion interface{} +// PodProbeMarkerListerExpansion allows custom methods to be added to +// PodProbeMarkerLister. +type PodProbeMarkerListerExpansion interface{} + +// PodProbeMarkerNamespaceListerExpansion allows custom methods to be added to +// PodProbeMarkerNamespaceLister. +type PodProbeMarkerNamespaceListerExpansion interface{} + // ResourceDistributionListerExpansion allows custom methods to be added to // ResourceDistributionLister. type ResourceDistributionListerExpansion interface{} diff --git a/pkg/client/listers/apps/v1alpha1/nodepodprobe.go b/pkg/client/listers/apps/v1alpha1/nodepodprobe.go new file mode 100644 index 0000000000..8550ec2abb --- /dev/null +++ b/pkg/client/listers/apps/v1alpha1/nodepodprobe.go @@ -0,0 +1,67 @@ +/* +Copyright 2021 The Kruise 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/openkruise/kruise/apis/apps/v1alpha1" + "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/labels" + "k8s.io/client-go/tools/cache" +) + +// NodePodProbeLister helps list NodePodProbes. +// All objects returned here must be treated as read-only. +type NodePodProbeLister interface { + // List lists all NodePodProbes in the indexer. + // Objects returned here must be treated as read-only. + List(selector labels.Selector) (ret []*v1alpha1.NodePodProbe, err error) + // Get retrieves the NodePodProbe from the index for a given name. + // Objects returned here must be treated as read-only. + Get(name string) (*v1alpha1.NodePodProbe, error) + NodePodProbeListerExpansion +} + +// nodePodProbeLister implements the NodePodProbeLister interface. +type nodePodProbeLister struct { + indexer cache.Indexer +} + +// NewNodePodProbeLister returns a new NodePodProbeLister. +func NewNodePodProbeLister(indexer cache.Indexer) NodePodProbeLister { + return &nodePodProbeLister{indexer: indexer} +} + +// List lists all NodePodProbes in the indexer. +func (s *nodePodProbeLister) List(selector labels.Selector) (ret []*v1alpha1.NodePodProbe, err error) { + err = cache.ListAll(s.indexer, selector, func(m interface{}) { + ret = append(ret, m.(*v1alpha1.NodePodProbe)) + }) + return ret, err +} + +// Get retrieves the NodePodProbe from the index for a given name. +func (s *nodePodProbeLister) Get(name string) (*v1alpha1.NodePodProbe, error) { + obj, exists, err := s.indexer.GetByKey(name) + if err != nil { + return nil, err + } + if !exists { + return nil, errors.NewNotFound(v1alpha1.Resource("nodepodprobe"), name) + } + return obj.(*v1alpha1.NodePodProbe), nil +} diff --git a/pkg/client/listers/apps/v1alpha1/podprobemarker.go b/pkg/client/listers/apps/v1alpha1/podprobemarker.go new file mode 100644 index 0000000000..04d5e6316d --- /dev/null +++ b/pkg/client/listers/apps/v1alpha1/podprobemarker.go @@ -0,0 +1,98 @@ +/* +Copyright 2021 The Kruise 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/openkruise/kruise/apis/apps/v1alpha1" + "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/labels" + "k8s.io/client-go/tools/cache" +) + +// PodProbeMarkerLister helps list PodProbeMarkers. +// All objects returned here must be treated as read-only. +type PodProbeMarkerLister interface { + // List lists all PodProbeMarkers in the indexer. + // Objects returned here must be treated as read-only. + List(selector labels.Selector) (ret []*v1alpha1.PodProbeMarker, err error) + // PodProbeMarkers returns an object that can list and get PodProbeMarkers. + PodProbeMarkers(namespace string) PodProbeMarkerNamespaceLister + PodProbeMarkerListerExpansion +} + +// podProbeMarkerLister implements the PodProbeMarkerLister interface. +type podProbeMarkerLister struct { + indexer cache.Indexer +} + +// NewPodProbeMarkerLister returns a new PodProbeMarkerLister. +func NewPodProbeMarkerLister(indexer cache.Indexer) PodProbeMarkerLister { + return &podProbeMarkerLister{indexer: indexer} +} + +// List lists all PodProbeMarkers in the indexer. +func (s *podProbeMarkerLister) List(selector labels.Selector) (ret []*v1alpha1.PodProbeMarker, err error) { + err = cache.ListAll(s.indexer, selector, func(m interface{}) { + ret = append(ret, m.(*v1alpha1.PodProbeMarker)) + }) + return ret, err +} + +// PodProbeMarkers returns an object that can list and get PodProbeMarkers. +func (s *podProbeMarkerLister) PodProbeMarkers(namespace string) PodProbeMarkerNamespaceLister { + return podProbeMarkerNamespaceLister{indexer: s.indexer, namespace: namespace} +} + +// PodProbeMarkerNamespaceLister helps list and get PodProbeMarkers. +// All objects returned here must be treated as read-only. +type PodProbeMarkerNamespaceLister interface { + // List lists all PodProbeMarkers in the indexer for a given namespace. + // Objects returned here must be treated as read-only. + List(selector labels.Selector) (ret []*v1alpha1.PodProbeMarker, err error) + // Get retrieves the PodProbeMarker from the indexer for a given namespace and name. + // Objects returned here must be treated as read-only. + Get(name string) (*v1alpha1.PodProbeMarker, error) + PodProbeMarkerNamespaceListerExpansion +} + +// podProbeMarkerNamespaceLister implements the PodProbeMarkerNamespaceLister +// interface. +type podProbeMarkerNamespaceLister struct { + indexer cache.Indexer + namespace string +} + +// List lists all PodProbeMarkers in the indexer for a given namespace. +func (s podProbeMarkerNamespaceLister) List(selector labels.Selector) (ret []*v1alpha1.PodProbeMarker, err error) { + err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { + ret = append(ret, m.(*v1alpha1.PodProbeMarker)) + }) + return ret, err +} + +// Get retrieves the PodProbeMarker from the indexer for a given namespace and name. +func (s podProbeMarkerNamespaceLister) Get(name string) (*v1alpha1.PodProbeMarker, error) { + obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) + if err != nil { + return nil, err + } + if !exists { + return nil, errors.NewNotFound(v1alpha1.Resource("podprobemarker"), name) + } + return obj.(*v1alpha1.PodProbeMarker), nil +} diff --git a/pkg/controller/statefulset/stateful_set_control.go b/pkg/controller/statefulset/stateful_set_control.go index f94fffd1b5..69ba24865e 100644 --- a/pkg/controller/statefulset/stateful_set_control.go +++ b/pkg/controller/statefulset/stateful_set_control.go @@ -193,8 +193,17 @@ func (ssc *defaultStatefulSetControl) truncateHistory( current *apps.ControllerRevision, update *apps.ControllerRevision) error { history := make([]*apps.ControllerRevision, 0, len(revisions)) + if current == nil || update == nil { + return nil + } // mark all live revisions - live := map[string]bool{current.Name: true, update.Name: true} + live := map[string]bool{} + if current != nil { + live[current.Name] = true + } + if update != nil { + live[update.Name] = true + } for i := range pods { live[getPodRevision(pods[i])] = true }