-
Notifications
You must be signed in to change notification settings - Fork 780
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
pod probe marker apis #1073
Merged
Merged
pod probe marker apis #1073
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not just use
v1.Probe
?