|
| 1 | +package v1beta1 |
| 2 | + |
| 3 | +import ( |
| 4 | + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" |
| 5 | +) |
| 6 | + |
| 7 | +// NodeForceDrainSpec defines the desired state of NodeForceDrain |
| 8 | +type NodeForceDrainSpec struct { |
| 9 | + // NodeSelector is a selector to select which nodes to drain |
| 10 | + // A nil selector matches no nodes, while an empty selector matches all nodes. |
| 11 | + NodeSelector *metav1.LabelSelector `json:"nodeSelector"` |
| 12 | + // NodeDrainGracePeriod is the duration until the controller starts to delete pods on the node. |
| 13 | + // The duration is calculated from the OpenShist node drain annotation. |
| 14 | + // This circumvents the eviction API and means that PDBs are ignored. |
| 15 | + // This is not a force delete, but it will delete pods that are not managed by a controller. |
| 16 | + // A zero value disables the force drain. |
| 17 | + NodeDrainGracePeriod metav1.Duration `json:"nodeDrainGracePeriod"` |
| 18 | + // PodForceDeleteGracePeriod is the duration until the controller starts to force delete pods on the node. |
| 19 | + // The duration is calculated from the pods deletion timestamp. |
| 20 | + // Only pods on nodes that have reached the nodeDrainGracePeriod are force deleted. |
| 21 | + // The maximum time until pod force deletion is nodeDrainGracePeriod+podForceDeleteGracePeriod. |
| 22 | + // This is equivalent to the `--force --grace-period=0` flag of `kubectl delete pod`. |
| 23 | + // A zero value disables the force delete. |
| 24 | + PodForceDeleteGracePeriod metav1.Duration `json:"podForceDeleteGracePeriod"` |
| 25 | +} |
| 26 | + |
| 27 | +// NodeForceDrainStatus defines the observed state of NodeForceDrain |
| 28 | +type NodeForceDrainStatus struct { |
| 29 | + // LastObservedNodeDrain is the last time the controller observed a node drain. |
| 30 | + LastObservedNodeDrain []ObservedNodeDrain `json:"lastObservedNodeDrain,omitempty"` |
| 31 | +} |
| 32 | + |
| 33 | +type ObservedNodeDrain struct { |
| 34 | + // NodeName is the name of the node that was drained. |
| 35 | + NodeName string `json:"nodeName"` |
| 36 | + // LastAppliedDrain is a unique identifier for the drain. |
| 37 | + // Taken from the machineconfiguration.openshift.io/lastAppliedDrain annotation. |
| 38 | + LastAppliedDrain string `json:"drainID"` |
| 39 | + ObservedTime metav1.Time `json:"observedTime"` |
| 40 | +} |
| 41 | + |
| 42 | +//+kubebuilder:object:root=true |
| 43 | +//+kubebuilder:subresource:status |
| 44 | + |
| 45 | +// NodeForceDrain is the Schema for the NodeForceDrains API |
| 46 | +type NodeForceDrain struct { |
| 47 | + metav1.TypeMeta `json:",inline"` |
| 48 | + metav1.ObjectMeta `json:"metadata,omitempty"` |
| 49 | + |
| 50 | + Spec NodeForceDrainSpec `json:"spec,omitempty"` |
| 51 | + Status NodeForceDrainStatus `json:"status,omitempty"` |
| 52 | +} |
| 53 | + |
| 54 | +//+kubebuilder:object:root=true |
| 55 | + |
| 56 | +// NodeForceDrainList contains a list of NodeForceDrain |
| 57 | +type NodeForceDrainList struct { |
| 58 | + metav1.TypeMeta `json:",inline"` |
| 59 | + metav1.ListMeta `json:"metadata,omitempty"` |
| 60 | + Items []NodeForceDrain `json:"items"` |
| 61 | +} |
| 62 | + |
| 63 | +func init() { |
| 64 | + SchemeBuilder.Register(&NodeForceDrain{}, &NodeForceDrainList{}) |
| 65 | +} |
0 commit comments