1package v1
2
3import (
4 "cue.dev/x/k8s.io/apimachinery/pkg/apis/meta/v1"
5 "cue.dev/x/k8s.io/apimachinery/pkg/util/intstr"
6)
7
8// Eviction evicts a pod from its node subject to certain policies and safety
9// constraints. This is a subresource of Pod. A request to cause such an
10// eviction is created by POSTing to .../pods/<pod name>/evictions.
11#Eviction: {
12 // APIVersion defines the versioned schema of this representation of an object.
13 // Servers should convert recognized schemas to the latest internal value, and
14 // may reject unrecognized values. More info:
15 // https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources
16 "apiVersion": "policy/v1"
17
18 // DeleteOptions may be provided
19 "deleteOptions"?: v1.#DeleteOptions
20
21 // Kind is a string value representing the REST resource this object represents.
22 // Servers may infer this from the endpoint the client submits requests to.
23 // Cannot be updated. In CamelCase. More info:
24 // https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
25 "kind": "Eviction"
26
27 // ObjectMeta describes the pod that is being evicted.
28 "metadata"?: v1.#ObjectMeta
29}
30
31// PodDisruptionBudget is an object to define the max disruption that can be
32// caused to a collection of pods
33#PodDisruptionBudget: {
34 // APIVersion defines the versioned schema of this representation of an object.
35 // Servers should convert recognized schemas to the latest internal value, and
36 // may reject unrecognized values. More info:
37 // https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources
38 "apiVersion": "policy/v1"
39
40 // Kind is a string value representing the REST resource this object represents.
41 // Servers may infer this from the endpoint the client submits requests to.
42 // Cannot be updated. In CamelCase. More info:
43 // https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
44 "kind": "PodDisruptionBudget"
45
46 // Standard object's metadata. More info:
47 // https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata
48 "metadata"?: v1.#ObjectMeta
49
50 // Specification of the desired behavior of the PodDisruptionBudget.
51 "spec"?: #PodDisruptionBudgetSpec
52
53 // Most recently observed status of the PodDisruptionBudget.
54 "status"?: #PodDisruptionBudgetStatus
55}
56
57// PodDisruptionBudgetList is a collection of PodDisruptionBudgets.
58#PodDisruptionBudgetList: {
59 // APIVersion defines the versioned schema of this representation of an object.
60 // Servers should convert recognized schemas to the latest internal value, and
61 // may reject unrecognized values. More info:
62 // https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources
63 "apiVersion": "policy/v1"
64
65 // Items is a list of PodDisruptionBudgets
66 "items"!: [...#PodDisruptionBudget]
67
68 // Kind is a string value representing the REST resource this object represents.
69 // Servers may infer this from the endpoint the client submits requests to.
70 // Cannot be updated. In CamelCase. More info:
71 // https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
72 "kind": "PodDisruptionBudgetList"
73
74 // Standard object's metadata. More info:
75 // https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata
76 "metadata"?: v1.#ListMeta
77}
78
79// PodDisruptionBudgetSpec is a description of a PodDisruptionBudget.
80#PodDisruptionBudgetSpec: {
81 // An eviction is allowed if at most "maxUnavailable" pods selected by
82 // "selector" are unavailable after the eviction, i.e. even in absence of the
83 // evicted pod. For example, one can prevent all voluntary evictions by
84 // specifying 0. This is a mutually exclusive setting with "minAvailable".
85 "maxUnavailable"?: intstr.#IntOrString
86
87 // An eviction is allowed if at least "minAvailable" pods selected by "selector"
88 // will still be available after the eviction, i.e. even in the absence of the
89 // evicted pod. So for example you can prevent all voluntary evictions by
90 // specifying "100%".
91 "minAvailable"?: intstr.#IntOrString
92
93 // Label query over pods whose evictions are managed by the disruption budget. A
94 // null selector will match no pods, while an empty ({}) selector will select
95 // all pods within the namespace.
96 "selector"?: v1.#LabelSelector
97
98 // UnhealthyPodEvictionPolicy defines the criteria for when unhealthy pods
99 // should be considered for eviction. Current implementation considers healthy
100 // pods, as pods that have status.conditions item with
101 // type="Ready",status="True".
102 //
103 // Valid policies are IfHealthyBudget and AlwaysAllow. If no policy is
104 // specified, the default behavior will be used, which corresponds to the
105 // IfHealthyBudget policy.
106 //
107 // IfHealthyBudget policy means that running pods (status.phase="Running"), but
108 // not yet healthy can be evicted only if the guarded application is not
109 // disrupted (status.currentHealthy is at least equal to
110 // status.desiredHealthy). Healthy pods will be subject to the PDB for
111 // eviction.
112 //
113 // AlwaysAllow policy means that all running pods (status.phase="Running"), but
114 // not yet healthy are considered disrupted and can be evicted regardless of
115 // whether the criteria in a PDB is met. This means perspective running pods of
116 // a disrupted application might not get a chance to become healthy. Healthy
117 // pods will be subject to the PDB for eviction.
118 //
119 // Additional policies may be added in the future. Clients making eviction
120 // decisions should disallow eviction of unhealthy pods if they encounter an
121 // unrecognized policy in this field.
122 "unhealthyPodEvictionPolicy"?: string
123}
124
125// PodDisruptionBudgetStatus represents information about the status of a
126// PodDisruptionBudget. Status may trail the actual state of a system.
127#PodDisruptionBudgetStatus: {
128 // Conditions contain conditions for PDB. The disruption controller sets the
129 // DisruptionAllowed condition. The following are known values for the reason
130 // field (additional reasons could be added in the future): - SyncFailed: The
131 // controller encountered an error and wasn't able to compute
132 // the number of allowed disruptions. Therefore no disruptions are
133 // allowed and the status of the condition will be False.
134 // - InsufficientPods: The number of pods are either at or below the number
135 // required by the PodDisruptionBudget. No disruptions are
136 // allowed and the status of the condition will be False.
137 // - SufficientPods: There are more pods than required by the PodDisruptionBudget.
138 // The condition will be True, and the number of allowed
139 // disruptions are provided by the disruptionsAllowed property.
140 "conditions"?: [...v1.#Condition]
141
142 // current number of healthy pods
143 "currentHealthy"?: int32 & int
144
145 // minimum desired number of healthy pods
146 "desiredHealthy"?: int32 & int
147
148 // DisruptedPods contains information about pods whose eviction was processed by
149 // the API server eviction subresource handler but has not yet been observed by
150 // the PodDisruptionBudget controller. A pod will be in this map from the time
151 // when the API server processed the eviction request to the time when the pod
152 // is seen by PDB controller as having been marked for deletion (or after a
153 // timeout). The key in the map is the name of the pod and the value is the
154 // time when the API server processed the eviction request. If the deletion
155 // didn't occur and a pod is still there it will be removed from the list
156 // automatically by PodDisruptionBudget controller after some time. If
157 // everything goes smooth this map should be empty for the most of the time.
158 // Large number of entries in the map may indicate problems with pod deletions.
159 "disruptedPods"?: [string]: v1.#Time
160
161 // Number of pod disruptions that are currently allowed.
162 "disruptionsAllowed"?: int32 & int
163
164 // total number of pods counted by this disruption budget
165 "expectedPods"?: int32 & int
166
167 // Most recent generation observed when updating this PDB status.
168 // DisruptionsAllowed and other status information is valid only if
169 // observedGeneration equals to PDB's object generation.
170 "observedGeneration"?: int64 & int
171}