-
Notifications
You must be signed in to change notification settings - Fork 773
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* pod probe marker apis Signed-off-by: liheng.zms <[email protected]> * fix statefulset truncateHistory panic Signed-off-by: liheng.zms <[email protected]> Signed-off-by: liheng.zms <[email protected]>
- Loading branch information
Showing
20 changed files
with
2,187 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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{}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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{}) | ||
} |
Oops, something went wrong.