blob: a1ef1a10badd775cb2bc8d22499891789a39d031 [file] [log] [blame]
Matteo Scandoloa4285862020-12-01 18:10:10 -08001/*
2Copyright 2015 The Kubernetes Authors.
3
4Licensed under the Apache License, Version 2.0 (the "License");
5you may not use this file except in compliance with the License.
6You may obtain a copy of the License at
7
8 http://www.apache.org/licenses/LICENSE-2.0
9
10Unless required by applicable law or agreed to in writing, software
11distributed under the License is distributed on an "AS IS" BASIS,
12WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13See the License for the specific language governing permissions and
14limitations under the License.
15*/
16
17package v1beta1
18
19import (
20 appsv1beta1 "k8s.io/api/apps/v1beta1"
21 v1 "k8s.io/api/core/v1"
22 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
23 "k8s.io/apimachinery/pkg/util/intstr"
24)
25
26// describes the attributes of a scale subresource
27type ScaleSpec struct {
28 // desired number of instances for the scaled object.
29 // +optional
30 Replicas int32 `json:"replicas,omitempty" protobuf:"varint,1,opt,name=replicas"`
31}
32
33// represents the current status of a scale subresource.
34type ScaleStatus struct {
35 // actual number of observed instances of the scaled object.
36 Replicas int32 `json:"replicas" protobuf:"varint,1,opt,name=replicas"`
37
38 // label query over pods that should match the replicas count. More info: http://kubernetes.io/docs/user-guide/labels#label-selectors
39 // +optional
40 Selector map[string]string `json:"selector,omitempty" protobuf:"bytes,2,rep,name=selector"`
41
42 // label selector for pods that should match the replicas count. This is a serializated
43 // version of both map-based and more expressive set-based selectors. This is done to
44 // avoid introspection in the clients. The string will be in the same format as the
45 // query-param syntax. If the target type only supports map-based selectors, both this
46 // field and map-based selector field are populated.
47 // More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/#label-selectors
48 // +optional
49 TargetSelector string `json:"targetSelector,omitempty" protobuf:"bytes,3,opt,name=targetSelector"`
50}
51
52// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
53// +k8s:prerelease-lifecycle-gen:introduced=1.1
54// +k8s:prerelease-lifecycle-gen:deprecated=1.2
55// +k8s:prerelease-lifecycle-gen:removed=1.18
56
57// represents a scaling request for a resource.
58type Scale struct {
59 metav1.TypeMeta `json:",inline"`
60 // Standard object metadata; More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata.
61 // +optional
62 metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
63
64 // defines the behavior of the scale. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status.
65 // +optional
66 Spec ScaleSpec `json:"spec,omitempty" protobuf:"bytes,2,opt,name=spec"`
67
68 // current status of the scale. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status. Read-only.
69 // +optional
70 Status ScaleStatus `json:"status,omitempty" protobuf:"bytes,3,opt,name=status"`
71}
72
73// +genclient
74// +genclient:method=GetScale,verb=get,subresource=scale,result=Scale
75// +genclient:method=UpdateScale,verb=update,subresource=scale,input=Scale,result=Scale
76// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
77// +k8s:prerelease-lifecycle-gen:introduced=1.1
78// +k8s:prerelease-lifecycle-gen:deprecated=1.8
79// +k8s:prerelease-lifecycle-gen:removed=1.18
80// +k8s:prerelease-lifecycle-gen:replacement=apps,v1,Deployment
81
82// DEPRECATED - This group version of Deployment is deprecated by apps/v1beta2/Deployment. See the release notes for
83// more information.
84// Deployment enables declarative updates for Pods and ReplicaSets.
85type Deployment struct {
86 metav1.TypeMeta `json:",inline"`
87 // Standard object metadata.
88 // +optional
89 metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
90
91 // Specification of the desired behavior of the Deployment.
92 // +optional
93 Spec DeploymentSpec `json:"spec,omitempty" protobuf:"bytes,2,opt,name=spec"`
94
95 // Most recently observed status of the Deployment.
96 // +optional
97 Status DeploymentStatus `json:"status,omitempty" protobuf:"bytes,3,opt,name=status"`
98}
99
100// DeploymentSpec is the specification of the desired behavior of the Deployment.
101type DeploymentSpec struct {
102 // Number of desired pods. This is a pointer to distinguish between explicit
103 // zero and not specified. Defaults to 1.
104 // +optional
105 Replicas *int32 `json:"replicas,omitempty" protobuf:"varint,1,opt,name=replicas"`
106
107 // Label selector for pods. Existing ReplicaSets whose pods are
108 // selected by this will be the ones affected by this deployment.
109 // +optional
110 Selector *metav1.LabelSelector `json:"selector,omitempty" protobuf:"bytes,2,opt,name=selector"`
111
112 // Template describes the pods that will be created.
113 Template v1.PodTemplateSpec `json:"template" protobuf:"bytes,3,opt,name=template"`
114
115 // The deployment strategy to use to replace existing pods with new ones.
116 // +optional
117 // +patchStrategy=retainKeys
118 Strategy DeploymentStrategy `json:"strategy,omitempty" patchStrategy:"retainKeys" protobuf:"bytes,4,opt,name=strategy"`
119
120 // Minimum number of seconds for which a newly created pod should be ready
121 // without any of its container crashing, for it to be considered available.
122 // Defaults to 0 (pod will be considered available as soon as it is ready)
123 // +optional
124 MinReadySeconds int32 `json:"minReadySeconds,omitempty" protobuf:"varint,5,opt,name=minReadySeconds"`
125
126 // The number of old ReplicaSets to retain to allow rollback.
127 // This is a pointer to distinguish between explicit zero and not specified.
128 // This is set to the max value of int32 (i.e. 2147483647) by default, which
129 // means "retaining all old ReplicaSets".
130 // +optional
131 RevisionHistoryLimit *int32 `json:"revisionHistoryLimit,omitempty" protobuf:"varint,6,opt,name=revisionHistoryLimit"`
132
133 // Indicates that the deployment is paused and will not be processed by the
134 // deployment controller.
135 // +optional
136 Paused bool `json:"paused,omitempty" protobuf:"varint,7,opt,name=paused"`
137
138 // DEPRECATED.
139 // The config this deployment is rolling back to. Will be cleared after rollback is done.
140 // +optional
141 RollbackTo *RollbackConfig `json:"rollbackTo,omitempty" protobuf:"bytes,8,opt,name=rollbackTo"`
142
143 // The maximum time in seconds for a deployment to make progress before it
144 // is considered to be failed. The deployment controller will continue to
145 // process failed deployments and a condition with a ProgressDeadlineExceeded
146 // reason will be surfaced in the deployment status. Note that progress will
147 // not be estimated during the time a deployment is paused. This is set to
148 // the max value of int32 (i.e. 2147483647) by default, which means "no deadline".
149 // +optional
150 ProgressDeadlineSeconds *int32 `json:"progressDeadlineSeconds,omitempty" protobuf:"varint,9,opt,name=progressDeadlineSeconds"`
151}
152
153// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
154// +k8s:prerelease-lifecycle-gen:introduced=1.2
155// +k8s:prerelease-lifecycle-gen:deprecated=1.8
156// +k8s:prerelease-lifecycle-gen:removed=1.18
157
158// DEPRECATED.
159// DeploymentRollback stores the information required to rollback a deployment.
160type DeploymentRollback struct {
161 metav1.TypeMeta `json:",inline"`
162 // Required: This must match the Name of a deployment.
163 Name string `json:"name" protobuf:"bytes,1,opt,name=name"`
164 // The annotations to be updated to a deployment
165 // +optional
166 UpdatedAnnotations map[string]string `json:"updatedAnnotations,omitempty" protobuf:"bytes,2,rep,name=updatedAnnotations"`
167 // The config of this deployment rollback.
168 RollbackTo RollbackConfig `json:"rollbackTo" protobuf:"bytes,3,opt,name=rollbackTo"`
169}
170
171// DEPRECATED.
172type RollbackConfig struct {
173 // The revision to rollback to. If set to 0, rollback to the last revision.
174 // +optional
175 Revision int64 `json:"revision,omitempty" protobuf:"varint,1,opt,name=revision"`
176}
177
178const (
179 // DefaultDeploymentUniqueLabelKey is the default key of the selector that is added
180 // to existing RCs (and label key that is added to its pods) to prevent the existing RCs
181 // to select new pods (and old pods being select by new RC).
182 DefaultDeploymentUniqueLabelKey string = "pod-template-hash"
183)
184
185// DeploymentStrategy describes how to replace existing pods with new ones.
186type DeploymentStrategy struct {
187 // Type of deployment. Can be "Recreate" or "RollingUpdate". Default is RollingUpdate.
188 // +optional
189 Type DeploymentStrategyType `json:"type,omitempty" protobuf:"bytes,1,opt,name=type,casttype=DeploymentStrategyType"`
190
191 // Rolling update config params. Present only if DeploymentStrategyType =
192 // RollingUpdate.
193 //---
194 // TODO: Update this to follow our convention for oneOf, whatever we decide it
195 // to be.
196 // +optional
197 RollingUpdate *RollingUpdateDeployment `json:"rollingUpdate,omitempty" protobuf:"bytes,2,opt,name=rollingUpdate"`
198}
199
200type DeploymentStrategyType string
201
202const (
203 // Kill all existing pods before creating new ones.
204 RecreateDeploymentStrategyType DeploymentStrategyType = "Recreate"
205
206 // Replace the old RCs by new one using rolling update i.e gradually scale down the old RCs and scale up the new one.
207 RollingUpdateDeploymentStrategyType DeploymentStrategyType = "RollingUpdate"
208)
209
210// Spec to control the desired behavior of rolling update.
211type RollingUpdateDeployment struct {
212 // The maximum number of pods that can be unavailable during the update.
213 // Value can be an absolute number (ex: 5) or a percentage of desired pods (ex: 10%).
214 // Absolute number is calculated from percentage by rounding down.
215 // This can not be 0 if MaxSurge is 0.
216 // By default, a fixed value of 1 is used.
217 // Example: when this is set to 30%, the old RC can be scaled down to 70% of desired pods
218 // immediately when the rolling update starts. Once new pods are ready, old RC
219 // can be scaled down further, followed by scaling up the new RC, ensuring
220 // that the total number of pods available at all times during the update is at
221 // least 70% of desired pods.
222 // +optional
223 MaxUnavailable *intstr.IntOrString `json:"maxUnavailable,omitempty" protobuf:"bytes,1,opt,name=maxUnavailable"`
224
225 // The maximum number of pods that can be scheduled above the desired number of
226 // pods.
227 // Value can be an absolute number (ex: 5) or a percentage of desired pods (ex: 10%).
228 // This can not be 0 if MaxUnavailable is 0.
229 // Absolute number is calculated from percentage by rounding up.
230 // By default, a value of 1 is used.
231 // Example: when this is set to 30%, the new RC can be scaled up immediately when
232 // the rolling update starts, such that the total number of old and new pods do not exceed
233 // 130% of desired pods. Once old pods have been killed,
234 // new RC can be scaled up further, ensuring that total number of pods running
235 // at any time during the update is at most 130% of desired pods.
236 // +optional
237 MaxSurge *intstr.IntOrString `json:"maxSurge,omitempty" protobuf:"bytes,2,opt,name=maxSurge"`
238}
239
240// DeploymentStatus is the most recently observed status of the Deployment.
241type DeploymentStatus struct {
242 // The generation observed by the deployment controller.
243 // +optional
244 ObservedGeneration int64 `json:"observedGeneration,omitempty" protobuf:"varint,1,opt,name=observedGeneration"`
245
246 // Total number of non-terminated pods targeted by this deployment (their labels match the selector).
247 // +optional
248 Replicas int32 `json:"replicas,omitempty" protobuf:"varint,2,opt,name=replicas"`
249
250 // Total number of non-terminated pods targeted by this deployment that have the desired template spec.
251 // +optional
252 UpdatedReplicas int32 `json:"updatedReplicas,omitempty" protobuf:"varint,3,opt,name=updatedReplicas"`
253
254 // Total number of ready pods targeted by this deployment.
255 // +optional
256 ReadyReplicas int32 `json:"readyReplicas,omitempty" protobuf:"varint,7,opt,name=readyReplicas"`
257
258 // Total number of available pods (ready for at least minReadySeconds) targeted by this deployment.
259 // +optional
260 AvailableReplicas int32 `json:"availableReplicas,omitempty" protobuf:"varint,4,opt,name=availableReplicas"`
261
262 // Total number of unavailable pods targeted by this deployment. This is the total number of
263 // pods that are still required for the deployment to have 100% available capacity. They may
264 // either be pods that are running but not yet available or pods that still have not been created.
265 // +optional
266 UnavailableReplicas int32 `json:"unavailableReplicas,omitempty" protobuf:"varint,5,opt,name=unavailableReplicas"`
267
268 // Represents the latest available observations of a deployment's current state.
269 // +patchMergeKey=type
270 // +patchStrategy=merge
271 Conditions []DeploymentCondition `json:"conditions,omitempty" patchStrategy:"merge" patchMergeKey:"type" protobuf:"bytes,6,rep,name=conditions"`
272
273 // Count of hash collisions for the Deployment. The Deployment controller uses this
274 // field as a collision avoidance mechanism when it needs to create the name for the
275 // newest ReplicaSet.
276 // +optional
277 CollisionCount *int32 `json:"collisionCount,omitempty" protobuf:"varint,8,opt,name=collisionCount"`
278}
279
280type DeploymentConditionType string
281
282// These are valid conditions of a deployment.
283const (
284 // Available means the deployment is available, ie. at least the minimum available
285 // replicas required are up and running for at least minReadySeconds.
286 DeploymentAvailable DeploymentConditionType = "Available"
287 // Progressing means the deployment is progressing. Progress for a deployment is
288 // considered when a new replica set is created or adopted, and when new pods scale
289 // up or old pods scale down. Progress is not estimated for paused deployments or
290 // when progressDeadlineSeconds is not specified.
291 DeploymentProgressing DeploymentConditionType = "Progressing"
292 // ReplicaFailure is added in a deployment when one of its pods fails to be created
293 // or deleted.
294 DeploymentReplicaFailure DeploymentConditionType = "ReplicaFailure"
295)
296
297// DeploymentCondition describes the state of a deployment at a certain point.
298type DeploymentCondition struct {
299 // Type of deployment condition.
300 Type DeploymentConditionType `json:"type" protobuf:"bytes,1,opt,name=type,casttype=DeploymentConditionType"`
301 // Status of the condition, one of True, False, Unknown.
302 Status v1.ConditionStatus `json:"status" protobuf:"bytes,2,opt,name=status,casttype=k8s.io/api/core/v1.ConditionStatus"`
303 // The last time this condition was updated.
304 LastUpdateTime metav1.Time `json:"lastUpdateTime,omitempty" protobuf:"bytes,6,opt,name=lastUpdateTime"`
305 // Last time the condition transitioned from one status to another.
306 LastTransitionTime metav1.Time `json:"lastTransitionTime,omitempty" protobuf:"bytes,7,opt,name=lastTransitionTime"`
307 // The reason for the condition's last transition.
308 Reason string `json:"reason,omitempty" protobuf:"bytes,4,opt,name=reason"`
309 // A human readable message indicating details about the transition.
310 Message string `json:"message,omitempty" protobuf:"bytes,5,opt,name=message"`
311}
312
313// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
314// +k8s:prerelease-lifecycle-gen:introduced=1.1
315// +k8s:prerelease-lifecycle-gen:deprecated=1.8
316// +k8s:prerelease-lifecycle-gen:removed=1.18
317// +k8s:prerelease-lifecycle-gen:replacement=apps,v1,DeploymentList
318
319// DeploymentList is a list of Deployments.
320type DeploymentList struct {
321 metav1.TypeMeta `json:",inline"`
322 // Standard list metadata.
323 // +optional
324 metav1.ListMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
325
326 // Items is the list of Deployments.
327 Items []Deployment `json:"items" protobuf:"bytes,2,rep,name=items"`
328}
329
330type DaemonSetUpdateStrategy struct {
331 // Type of daemon set update. Can be "RollingUpdate" or "OnDelete".
332 // Default is OnDelete.
333 // +optional
334 Type DaemonSetUpdateStrategyType `json:"type,omitempty" protobuf:"bytes,1,opt,name=type"`
335
336 // Rolling update config params. Present only if type = "RollingUpdate".
337 //---
338 // TODO: Update this to follow our convention for oneOf, whatever we decide it
339 // to be. Same as Deployment `strategy.rollingUpdate`.
340 // See https://github.com/kubernetes/kubernetes/issues/35345
341 // +optional
342 RollingUpdate *RollingUpdateDaemonSet `json:"rollingUpdate,omitempty" protobuf:"bytes,2,opt,name=rollingUpdate"`
343}
344
345type DaemonSetUpdateStrategyType string
346
347const (
348 // Replace the old daemons by new ones using rolling update i.e replace them on each node one after the other.
349 RollingUpdateDaemonSetStrategyType DaemonSetUpdateStrategyType = "RollingUpdate"
350
351 // Replace the old daemons only when it's killed
352 OnDeleteDaemonSetStrategyType DaemonSetUpdateStrategyType = "OnDelete"
353)
354
355// Spec to control the desired behavior of daemon set rolling update.
356type RollingUpdateDaemonSet struct {
357 // The maximum number of DaemonSet pods that can be unavailable during the
358 // update. Value can be an absolute number (ex: 5) or a percentage of total
359 // number of DaemonSet pods at the start of the update (ex: 10%). Absolute
360 // number is calculated from percentage by rounding up.
361 // This cannot be 0.
362 // Default value is 1.
363 // Example: when this is set to 30%, at most 30% of the total number of nodes
364 // that should be running the daemon pod (i.e. status.desiredNumberScheduled)
365 // can have their pods stopped for an update at any given
366 // time. The update starts by stopping at most 30% of those DaemonSet pods
367 // and then brings up new DaemonSet pods in their place. Once the new pods
368 // are available, it then proceeds onto other DaemonSet pods, thus ensuring
369 // that at least 70% of original number of DaemonSet pods are available at
370 // all times during the update.
371 // +optional
372 MaxUnavailable *intstr.IntOrString `json:"maxUnavailable,omitempty" protobuf:"bytes,1,opt,name=maxUnavailable"`
373}
374
375// DaemonSetSpec is the specification of a daemon set.
376type DaemonSetSpec struct {
377 // A label query over pods that are managed by the daemon set.
378 // Must match in order to be controlled.
379 // If empty, defaulted to labels on Pod template.
380 // More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/#label-selectors
381 // +optional
382 Selector *metav1.LabelSelector `json:"selector,omitempty" protobuf:"bytes,1,opt,name=selector"`
383
384 // An object that describes the pod that will be created.
385 // The DaemonSet will create exactly one copy of this pod on every node
386 // that matches the template's node selector (or on every node if no node
387 // selector is specified).
388 // More info: https://kubernetes.io/docs/concepts/workloads/controllers/replicationcontroller#pod-template
389 Template v1.PodTemplateSpec `json:"template" protobuf:"bytes,2,opt,name=template"`
390
391 // An update strategy to replace existing DaemonSet pods with new pods.
392 // +optional
393 UpdateStrategy DaemonSetUpdateStrategy `json:"updateStrategy,omitempty" protobuf:"bytes,3,opt,name=updateStrategy"`
394
395 // The minimum number of seconds for which a newly created DaemonSet pod should
396 // be ready without any of its container crashing, for it to be considered
397 // available. Defaults to 0 (pod will be considered available as soon as it
398 // is ready).
399 // +optional
400 MinReadySeconds int32 `json:"minReadySeconds,omitempty" protobuf:"varint,4,opt,name=minReadySeconds"`
401
402 // DEPRECATED.
403 // A sequence number representing a specific generation of the template.
404 // Populated by the system. It can be set only during the creation.
405 // +optional
406 TemplateGeneration int64 `json:"templateGeneration,omitempty" protobuf:"varint,5,opt,name=templateGeneration"`
407
408 // The number of old history to retain to allow rollback.
409 // This is a pointer to distinguish between explicit zero and not specified.
410 // Defaults to 10.
411 // +optional
412 RevisionHistoryLimit *int32 `json:"revisionHistoryLimit,omitempty" protobuf:"varint,6,opt,name=revisionHistoryLimit"`
413}
414
415// DaemonSetStatus represents the current status of a daemon set.
416type DaemonSetStatus struct {
417 // The number of nodes that are running at least 1
418 // daemon pod and are supposed to run the daemon pod.
419 // More info: https://kubernetes.io/docs/concepts/workloads/controllers/daemonset/
420 CurrentNumberScheduled int32 `json:"currentNumberScheduled" protobuf:"varint,1,opt,name=currentNumberScheduled"`
421
422 // The number of nodes that are running the daemon pod, but are
423 // not supposed to run the daemon pod.
424 // More info: https://kubernetes.io/docs/concepts/workloads/controllers/daemonset/
425 NumberMisscheduled int32 `json:"numberMisscheduled" protobuf:"varint,2,opt,name=numberMisscheduled"`
426
427 // The total number of nodes that should be running the daemon
428 // pod (including nodes correctly running the daemon pod).
429 // More info: https://kubernetes.io/docs/concepts/workloads/controllers/daemonset/
430 DesiredNumberScheduled int32 `json:"desiredNumberScheduled" protobuf:"varint,3,opt,name=desiredNumberScheduled"`
431
432 // The number of nodes that should be running the daemon pod and have one
433 // or more of the daemon pod running and ready.
434 NumberReady int32 `json:"numberReady" protobuf:"varint,4,opt,name=numberReady"`
435
436 // The most recent generation observed by the daemon set controller.
437 // +optional
438 ObservedGeneration int64 `json:"observedGeneration,omitempty" protobuf:"varint,5,opt,name=observedGeneration"`
439
440 // The total number of nodes that are running updated daemon pod
441 // +optional
442 UpdatedNumberScheduled int32 `json:"updatedNumberScheduled,omitempty" protobuf:"varint,6,opt,name=updatedNumberScheduled"`
443
444 // The number of nodes that should be running the
445 // daemon pod and have one or more of the daemon pod running and
446 // available (ready for at least spec.minReadySeconds)
447 // +optional
448 NumberAvailable int32 `json:"numberAvailable,omitempty" protobuf:"varint,7,opt,name=numberAvailable"`
449
450 // The number of nodes that should be running the
451 // daemon pod and have none of the daemon pod running and available
452 // (ready for at least spec.minReadySeconds)
453 // +optional
454 NumberUnavailable int32 `json:"numberUnavailable,omitempty" protobuf:"varint,8,opt,name=numberUnavailable"`
455
456 // Count of hash collisions for the DaemonSet. The DaemonSet controller
457 // uses this field as a collision avoidance mechanism when it needs to
458 // create the name for the newest ControllerRevision.
459 // +optional
460 CollisionCount *int32 `json:"collisionCount,omitempty" protobuf:"varint,9,opt,name=collisionCount"`
461
462 // Represents the latest available observations of a DaemonSet's current state.
463 // +optional
464 // +patchMergeKey=type
465 // +patchStrategy=merge
466 Conditions []DaemonSetCondition `json:"conditions,omitempty" patchStrategy:"merge" patchMergeKey:"type" protobuf:"bytes,10,rep,name=conditions"`
467}
468
469type DaemonSetConditionType string
470
471// TODO: Add valid condition types of a DaemonSet.
472
473// DaemonSetCondition describes the state of a DaemonSet at a certain point.
474type DaemonSetCondition struct {
475 // Type of DaemonSet condition.
476 Type DaemonSetConditionType `json:"type" protobuf:"bytes,1,opt,name=type,casttype=DaemonSetConditionType"`
477 // Status of the condition, one of True, False, Unknown.
478 Status v1.ConditionStatus `json:"status" protobuf:"bytes,2,opt,name=status,casttype=k8s.io/api/core/v1.ConditionStatus"`
479 // Last time the condition transitioned from one status to another.
480 // +optional
481 LastTransitionTime metav1.Time `json:"lastTransitionTime,omitempty" protobuf:"bytes,3,opt,name=lastTransitionTime"`
482 // The reason for the condition's last transition.
483 // +optional
484 Reason string `json:"reason,omitempty" protobuf:"bytes,4,opt,name=reason"`
485 // A human readable message indicating details about the transition.
486 // +optional
487 Message string `json:"message,omitempty" protobuf:"bytes,5,opt,name=message"`
488}
489
490// +genclient
491// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
492// +k8s:prerelease-lifecycle-gen:introduced=1.1
493// +k8s:prerelease-lifecycle-gen:deprecated=1.8
494// +k8s:prerelease-lifecycle-gen:removed=1.18
495// +k8s:prerelease-lifecycle-gen:replacement=apps,v1,DaemonSet
496
497// DEPRECATED - This group version of DaemonSet is deprecated by apps/v1beta2/DaemonSet. See the release notes for
498// more information.
499// DaemonSet represents the configuration of a daemon set.
500type DaemonSet struct {
501 metav1.TypeMeta `json:",inline"`
502 // Standard object's metadata.
503 // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata
504 // +optional
505 metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
506
507 // The desired behavior of this daemon set.
508 // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status
509 // +optional
510 Spec DaemonSetSpec `json:"spec,omitempty" protobuf:"bytes,2,opt,name=spec"`
511
512 // The current status of this daemon set. This data may be
513 // out of date by some window of time.
514 // Populated by the system.
515 // Read-only.
516 // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status
517 // +optional
518 Status DaemonSetStatus `json:"status,omitempty" protobuf:"bytes,3,opt,name=status"`
519}
520
521const (
522 // DEPRECATED: DefaultDaemonSetUniqueLabelKey is used instead.
523 // DaemonSetTemplateGenerationKey is the key of the labels that is added
524 // to daemon set pods to distinguish between old and new pod templates
525 // during DaemonSet template update.
526 DaemonSetTemplateGenerationKey string = "pod-template-generation"
527
528 // DefaultDaemonSetUniqueLabelKey is the default label key that is added
529 // to existing DaemonSet pods to distinguish between old and new
530 // DaemonSet pods during DaemonSet template updates.
531 DefaultDaemonSetUniqueLabelKey = appsv1beta1.ControllerRevisionHashLabelKey
532)
533
534// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
535// +k8s:prerelease-lifecycle-gen:introduced=1.1
536// +k8s:prerelease-lifecycle-gen:deprecated=1.8
537// +k8s:prerelease-lifecycle-gen:removed=1.18
538// +k8s:prerelease-lifecycle-gen:replacement=apps,v1,DaemonSetList
539
540// DaemonSetList is a collection of daemon sets.
541type DaemonSetList struct {
542 metav1.TypeMeta `json:",inline"`
543 // Standard list metadata.
544 // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata
545 // +optional
546 metav1.ListMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
547
548 // A list of daemon sets.
549 Items []DaemonSet `json:"items" protobuf:"bytes,2,rep,name=items"`
550}
551
552// +genclient
553// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
554// +k8s:prerelease-lifecycle-gen:introduced=1.1
555// +k8s:prerelease-lifecycle-gen:deprecated=1.14
556// +k8s:prerelease-lifecycle-gen:removed=1.22
557// +k8s:prerelease-lifecycle-gen:replacement=networking.k8s.io,v1,Ingress
558
559// Ingress is a collection of rules that allow inbound connections to reach the
560// endpoints defined by a backend. An Ingress can be configured to give services
561// externally-reachable urls, load balance traffic, terminate SSL, offer name
562// based virtual hosting etc.
563// DEPRECATED - This group version of Ingress is deprecated by networking.k8s.io/v1beta1 Ingress. See the release notes for more information.
564type Ingress struct {
565 metav1.TypeMeta `json:",inline"`
566 // Standard object's metadata.
567 // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata
568 // +optional
569 metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
570
571 // Spec is the desired state of the Ingress.
572 // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status
573 // +optional
574 Spec IngressSpec `json:"spec,omitempty" protobuf:"bytes,2,opt,name=spec"`
575
576 // Status is the current state of the Ingress.
577 // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status
578 // +optional
579 Status IngressStatus `json:"status,omitempty" protobuf:"bytes,3,opt,name=status"`
580}
581
582// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
583// +k8s:prerelease-lifecycle-gen:introduced=1.1
584// +k8s:prerelease-lifecycle-gen:deprecated=1.14
585// +k8s:prerelease-lifecycle-gen:removed=1.22
586// +k8s:prerelease-lifecycle-gen:replacement=networking.k8s.io,v1,IngressList
587
588// IngressList is a collection of Ingress.
589type IngressList struct {
590 metav1.TypeMeta `json:",inline"`
591 // Standard object's metadata.
592 // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata
593 // +optional
594 metav1.ListMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
595
596 // Items is the list of Ingress.
597 Items []Ingress `json:"items" protobuf:"bytes,2,rep,name=items"`
598}
599
600// IngressSpec describes the Ingress the user wishes to exist.
601type IngressSpec struct {
602 // IngressClassName is the name of the IngressClass cluster resource. The
603 // associated IngressClass defines which controller will implement the
604 // resource. This replaces the deprecated `kubernetes.io/ingress.class`
605 // annotation. For backwards compatibility, when that annotation is set, it
606 // must be given precedence over this field. The controller may emit a
607 // warning if the field and annotation have different values.
608 // Implementations of this API should ignore Ingresses without a class
609 // specified. An IngressClass resource may be marked as default, which can
610 // be used to set a default value for this field. For more information,
611 // refer to the IngressClass documentation.
612 // +optional
613 IngressClassName *string `json:"ingressClassName,omitempty" protobuf:"bytes,4,opt,name=ingressClassName"`
614
615 // A default backend capable of servicing requests that don't match any
616 // rule. At least one of 'backend' or 'rules' must be specified. This field
617 // is optional to allow the loadbalancer controller or defaulting logic to
618 // specify a global default.
619 // +optional
620 Backend *IngressBackend `json:"backend,omitempty" protobuf:"bytes,1,opt,name=backend"`
621
622 // TLS configuration. Currently the Ingress only supports a single TLS
623 // port, 443. If multiple members of this list specify different hosts, they
624 // will be multiplexed on the same port according to the hostname specified
625 // through the SNI TLS extension, if the ingress controller fulfilling the
626 // ingress supports SNI.
627 // +optional
628 TLS []IngressTLS `json:"tls,omitempty" protobuf:"bytes,2,rep,name=tls"`
629
630 // A list of host rules used to configure the Ingress. If unspecified, or
631 // no rule matches, all traffic is sent to the default backend.
632 // +optional
633 Rules []IngressRule `json:"rules,omitempty" protobuf:"bytes,3,rep,name=rules"`
634 // TODO: Add the ability to specify load-balancer IP through claims
635}
636
637// IngressTLS describes the transport layer security associated with an Ingress.
638type IngressTLS struct {
639 // Hosts are a list of hosts included in the TLS certificate. The values in
640 // this list must match the name/s used in the tlsSecret. Defaults to the
641 // wildcard host setting for the loadbalancer controller fulfilling this
642 // Ingress, if left unspecified.
643 // +optional
644 Hosts []string `json:"hosts,omitempty" protobuf:"bytes,1,rep,name=hosts"`
645 // SecretName is the name of the secret used to terminate SSL traffic on 443.
646 // Field is left optional to allow SSL routing based on SNI hostname alone.
647 // If the SNI host in a listener conflicts with the "Host" header field used
648 // by an IngressRule, the SNI host is used for termination and value of the
649 // Host header is used for routing.
650 // +optional
651 SecretName string `json:"secretName,omitempty" protobuf:"bytes,2,opt,name=secretName"`
652 // TODO: Consider specifying different modes of termination, protocols etc.
653}
654
655// IngressStatus describe the current state of the Ingress.
656type IngressStatus struct {
657 // LoadBalancer contains the current status of the load-balancer.
658 // +optional
659 LoadBalancer v1.LoadBalancerStatus `json:"loadBalancer,omitempty" protobuf:"bytes,1,opt,name=loadBalancer"`
660}
661
662// IngressRule represents the rules mapping the paths under a specified host to
663// the related backend services. Incoming requests are first evaluated for a host
664// match, then routed to the backend associated with the matching IngressRuleValue.
665type IngressRule struct {
666 // Host is the fully qualified domain name of a network host, as defined by RFC 3986.
667 // Note the following deviations from the "host" part of the
668 // URI as defined in RFC 3986:
669 // 1. IPs are not allowed. Currently an IngressRuleValue can only apply to
670 // the IP in the Spec of the parent Ingress.
671 // 2. The `:` delimiter is not respected because ports are not allowed.
672 // Currently the port of an Ingress is implicitly :80 for http and
673 // :443 for https.
674 // Both these may change in the future.
675 // Incoming requests are matched against the host before the
676 // IngressRuleValue. If the host is unspecified, the Ingress routes all
677 // traffic based on the specified IngressRuleValue.
678 //
679 // Host can be "precise" which is a domain name without the terminating dot of
680 // a network host (e.g. "foo.bar.com") or "wildcard", which is a domain name
681 // prefixed with a single wildcard label (e.g. "*.foo.com").
682 // The wildcard character '*' must appear by itself as the first DNS label and
683 // matches only a single label. You cannot have a wildcard label by itself (e.g. Host == "*").
684 // Requests will be matched against the Host field in the following way:
685 // 1. If Host is precise, the request matches this rule if the http host header is equal to Host.
686 // 2. If Host is a wildcard, then the request matches this rule if the http host header
687 // is to equal to the suffix (removing the first label) of the wildcard rule.
688 // +optional
689 Host string `json:"host,omitempty" protobuf:"bytes,1,opt,name=host"`
690 // IngressRuleValue represents a rule to route requests for this IngressRule.
691 // If unspecified, the rule defaults to a http catch-all. Whether that sends
692 // just traffic matching the host to the default backend or all traffic to the
693 // default backend, is left to the controller fulfilling the Ingress. Http is
694 // currently the only supported IngressRuleValue.
695 // +optional
696 IngressRuleValue `json:",inline,omitempty" protobuf:"bytes,2,opt,name=ingressRuleValue"`
697}
698
699// IngressRuleValue represents a rule to apply against incoming requests. If the
700// rule is satisfied, the request is routed to the specified backend. Currently
701// mixing different types of rules in a single Ingress is disallowed, so exactly
702// one of the following must be set.
703type IngressRuleValue struct {
704 //TODO:
705 // 1. Consider renaming this resource and the associated rules so they
706 // aren't tied to Ingress. They can be used to route intra-cluster traffic.
707 // 2. Consider adding fields for ingress-type specific global options
708 // usable by a loadbalancer, like http keep-alive.
709
710 // +optional
711 HTTP *HTTPIngressRuleValue `json:"http,omitempty" protobuf:"bytes,1,opt,name=http"`
712}
713
714// HTTPIngressRuleValue is a list of http selectors pointing to backends.
715// In the example: http://<host>/<path>?<searchpart> -> backend where
716// where parts of the url correspond to RFC 3986, this resource will be used
717// to match against everything after the last '/' and before the first '?'
718// or '#'.
719type HTTPIngressRuleValue struct {
720 // A collection of paths that map requests to backends.
721 Paths []HTTPIngressPath `json:"paths" protobuf:"bytes,1,rep,name=paths"`
722 // TODO: Consider adding fields for ingress-type specific global
723 // options usable by a loadbalancer, like http keep-alive.
724}
725
726// PathType represents the type of path referred to by a HTTPIngressPath.
727type PathType string
728
729const (
730 // PathTypeExact matches the URL path exactly and with case sensitivity.
731 PathTypeExact = PathType("Exact")
732
733 // PathTypePrefix matches based on a URL path prefix split by '/'. Matching
734 // is case sensitive and done on a path element by element basis. A path
735 // element refers to the list of labels in the path split by the '/'
736 // separator. A request is a match for path p if every p is an element-wise
737 // prefix of p of the request path. Note that if the last element of the
738 // path is a substring of the last element in request path, it is not a
739 // match (e.g. /foo/bar matches /foo/bar/baz, but does not match
740 // /foo/barbaz). If multiple matching paths exist in an Ingress spec, the
741 // longest matching path is given priority.
742 // Examples:
743 // - /foo/bar does not match requests to /foo/barbaz
744 // - /foo/bar matches request to /foo/bar and /foo/bar/baz
745 // - /foo and /foo/ both match requests to /foo and /foo/. If both paths are
746 // present in an Ingress spec, the longest matching path (/foo/) is given
747 // priority.
748 PathTypePrefix = PathType("Prefix")
749
750 // PathTypeImplementationSpecific matching is up to the IngressClass.
751 // Implementations can treat this as a separate PathType or treat it
752 // identically to Prefix or Exact path types.
753 PathTypeImplementationSpecific = PathType("ImplementationSpecific")
754)
755
756// HTTPIngressPath associates a path with a backend. Incoming urls matching the
757// path are forwarded to the backend.
758type HTTPIngressPath struct {
759 // Path is matched against the path of an incoming request. Currently it can
760 // contain characters disallowed from the conventional "path" part of a URL
761 // as defined by RFC 3986. Paths must begin with a '/'. When unspecified,
762 // all paths from incoming requests are matched.
763 // +optional
764 Path string `json:"path,omitempty" protobuf:"bytes,1,opt,name=path"`
765
766 // PathType determines the interpretation of the Path matching. PathType can
767 // be one of the following values:
768 // * Exact: Matches the URL path exactly.
769 // * Prefix: Matches based on a URL path prefix split by '/'. Matching is
770 // done on a path element by element basis. A path element refers is the
771 // list of labels in the path split by the '/' separator. A request is a
772 // match for path p if every p is an element-wise prefix of p of the
773 // request path. Note that if the last element of the path is a substring
774 // of the last element in request path, it is not a match (e.g. /foo/bar
775 // matches /foo/bar/baz, but does not match /foo/barbaz).
776 // * ImplementationSpecific: Interpretation of the Path matching is up to
777 // the IngressClass. Implementations can treat this as a separate PathType
778 // or treat it identically to Prefix or Exact path types.
779 // Implementations are required to support all path types.
780 // Defaults to ImplementationSpecific.
781 PathType *PathType `json:"pathType,omitempty" protobuf:"bytes,3,opt,name=pathType"`
782
783 // Backend defines the referenced service endpoint to which the traffic
784 // will be forwarded to.
785 Backend IngressBackend `json:"backend" protobuf:"bytes,2,opt,name=backend"`
786}
787
788// IngressBackend describes all endpoints for a given service and port.
789type IngressBackend struct {
790 // Specifies the name of the referenced service.
791 // +optional
792 ServiceName string `json:"serviceName,omitempty" protobuf:"bytes,1,opt,name=serviceName"`
793
794 // Specifies the port of the referenced service.
795 // +optional
796 ServicePort intstr.IntOrString `json:"servicePort,omitempty" protobuf:"bytes,2,opt,name=servicePort"`
797
798 // Resource is an ObjectRef to another Kubernetes resource in the namespace
799 // of the Ingress object. If resource is specified, serviceName and servicePort
800 // must not be specified.
801 // +optional
802 Resource *v1.TypedLocalObjectReference `json:"resource,omitempty" protobuf:"bytes,3,opt,name=resource"`
803}
804
805// +genclient
806// +genclient:method=GetScale,verb=get,subresource=scale,result=Scale
807// +genclient:method=UpdateScale,verb=update,subresource=scale,input=Scale,result=Scale
808// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
809// +k8s:prerelease-lifecycle-gen:introduced=1.2
810// +k8s:prerelease-lifecycle-gen:deprecated=1.8
811// +k8s:prerelease-lifecycle-gen:removed=1.18
812// +k8s:prerelease-lifecycle-gen:replacement=apps,v1,ReplicaSet
813
814// DEPRECATED - This group version of ReplicaSet is deprecated by apps/v1beta2/ReplicaSet. See the release notes for
815// more information.
816// ReplicaSet ensures that a specified number of pod replicas are running at any given time.
817type ReplicaSet struct {
818 metav1.TypeMeta `json:",inline"`
819
820 // If the Labels of a ReplicaSet are empty, they are defaulted to
821 // be the same as the Pod(s) that the ReplicaSet manages.
822 // Standard object's metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata
823 // +optional
824 metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
825
826 // Spec defines the specification of the desired behavior of the ReplicaSet.
827 // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status
828 // +optional
829 Spec ReplicaSetSpec `json:"spec,omitempty" protobuf:"bytes,2,opt,name=spec"`
830
831 // Status is the most recently observed status of the ReplicaSet.
832 // This data may be out of date by some window of time.
833 // Populated by the system.
834 // Read-only.
835 // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status
836 // +optional
837 Status ReplicaSetStatus `json:"status,omitempty" protobuf:"bytes,3,opt,name=status"`
838}
839
840// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
841// +k8s:prerelease-lifecycle-gen:introduced=1.2
842// +k8s:prerelease-lifecycle-gen:deprecated=1.8
843// +k8s:prerelease-lifecycle-gen:removed=1.18
844// +k8s:prerelease-lifecycle-gen:replacement=apps,v1,ReplicaSetList
845
846// ReplicaSetList is a collection of ReplicaSets.
847type ReplicaSetList struct {
848 metav1.TypeMeta `json:",inline"`
849 // Standard list metadata.
850 // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
851 // +optional
852 metav1.ListMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
853
854 // List of ReplicaSets.
855 // More info: https://kubernetes.io/docs/concepts/workloads/controllers/replicationcontroller
856 Items []ReplicaSet `json:"items" protobuf:"bytes,2,rep,name=items"`
857}
858
859// ReplicaSetSpec is the specification of a ReplicaSet.
860type ReplicaSetSpec struct {
861 // Replicas is the number of desired replicas.
862 // This is a pointer to distinguish between explicit zero and unspecified.
863 // Defaults to 1.
864 // More info: https://kubernetes.io/docs/concepts/workloads/controllers/replicationcontroller/#what-is-a-replicationcontroller
865 // +optional
866 Replicas *int32 `json:"replicas,omitempty" protobuf:"varint,1,opt,name=replicas"`
867
868 // Minimum number of seconds for which a newly created pod should be ready
869 // without any of its container crashing, for it to be considered available.
870 // Defaults to 0 (pod will be considered available as soon as it is ready)
871 // +optional
872 MinReadySeconds int32 `json:"minReadySeconds,omitempty" protobuf:"varint,4,opt,name=minReadySeconds"`
873
874 // Selector is a label query over pods that should match the replica count.
875 // If the selector is empty, it is defaulted to the labels present on the pod template.
876 // Label keys and values that must match in order to be controlled by this replica set.
877 // More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/#label-selectors
878 // +optional
879 Selector *metav1.LabelSelector `json:"selector,omitempty" protobuf:"bytes,2,opt,name=selector"`
880
881 // Template is the object that describes the pod that will be created if
882 // insufficient replicas are detected.
883 // More info: https://kubernetes.io/docs/concepts/workloads/controllers/replicationcontroller#pod-template
884 // +optional
885 Template v1.PodTemplateSpec `json:"template,omitempty" protobuf:"bytes,3,opt,name=template"`
886}
887
888// ReplicaSetStatus represents the current status of a ReplicaSet.
889type ReplicaSetStatus struct {
890 // Replicas is the most recently oberved number of replicas.
891 // More info: https://kubernetes.io/docs/concepts/workloads/controllers/replicationcontroller/#what-is-a-replicationcontroller
892 Replicas int32 `json:"replicas" protobuf:"varint,1,opt,name=replicas"`
893
894 // The number of pods that have labels matching the labels of the pod template of the replicaset.
895 // +optional
896 FullyLabeledReplicas int32 `json:"fullyLabeledReplicas,omitempty" protobuf:"varint,2,opt,name=fullyLabeledReplicas"`
897
898 // The number of ready replicas for this replica set.
899 // +optional
900 ReadyReplicas int32 `json:"readyReplicas,omitempty" protobuf:"varint,4,opt,name=readyReplicas"`
901
902 // The number of available replicas (ready for at least minReadySeconds) for this replica set.
903 // +optional
904 AvailableReplicas int32 `json:"availableReplicas,omitempty" protobuf:"varint,5,opt,name=availableReplicas"`
905
906 // ObservedGeneration reflects the generation of the most recently observed ReplicaSet.
907 // +optional
908 ObservedGeneration int64 `json:"observedGeneration,omitempty" protobuf:"varint,3,opt,name=observedGeneration"`
909
910 // Represents the latest available observations of a replica set's current state.
911 // +optional
912 // +patchMergeKey=type
913 // +patchStrategy=merge
914 Conditions []ReplicaSetCondition `json:"conditions,omitempty" patchStrategy:"merge" patchMergeKey:"type" protobuf:"bytes,6,rep,name=conditions"`
915}
916
917type ReplicaSetConditionType string
918
919// These are valid conditions of a replica set.
920const (
921 // ReplicaSetReplicaFailure is added in a replica set when one of its pods fails to be created
922 // due to insufficient quota, limit ranges, pod security policy, node selectors, etc. or deleted
923 // due to kubelet being down or finalizers are failing.
924 ReplicaSetReplicaFailure ReplicaSetConditionType = "ReplicaFailure"
925)
926
927// ReplicaSetCondition describes the state of a replica set at a certain point.
928type ReplicaSetCondition struct {
929 // Type of replica set condition.
930 Type ReplicaSetConditionType `json:"type" protobuf:"bytes,1,opt,name=type,casttype=ReplicaSetConditionType"`
931 // Status of the condition, one of True, False, Unknown.
932 Status v1.ConditionStatus `json:"status" protobuf:"bytes,2,opt,name=status,casttype=k8s.io/api/core/v1.ConditionStatus"`
933 // The last time the condition transitioned from one status to another.
934 // +optional
935 LastTransitionTime metav1.Time `json:"lastTransitionTime,omitempty" protobuf:"bytes,3,opt,name=lastTransitionTime"`
936 // The reason for the condition's last transition.
937 // +optional
938 Reason string `json:"reason,omitempty" protobuf:"bytes,4,opt,name=reason"`
939 // A human readable message indicating details about the transition.
940 // +optional
941 Message string `json:"message,omitempty" protobuf:"bytes,5,opt,name=message"`
942}
943
944// +genclient
945// +genclient:nonNamespaced
946// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
947// +k8s:prerelease-lifecycle-gen:introduced=1.2
948// +k8s:prerelease-lifecycle-gen:deprecated=1.11
949// +k8s:prerelease-lifecycle-gen:removed=1.18
950// +k8s:prerelease-lifecycle-gen:replacement=policy,v1beta1,PodSecurityPolicy
951
952// PodSecurityPolicy governs the ability to make requests that affect the Security Context
953// that will be applied to a pod and container.
954// Deprecated: use PodSecurityPolicy from policy API Group instead.
955type PodSecurityPolicy struct {
956 metav1.TypeMeta `json:",inline"`
957 // Standard object's metadata.
958 // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata
959 // +optional
960 metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
961
962 // spec defines the policy enforced.
963 // +optional
964 Spec PodSecurityPolicySpec `json:"spec,omitempty" protobuf:"bytes,2,opt,name=spec"`
965}
966
967// PodSecurityPolicySpec defines the policy enforced.
968// Deprecated: use PodSecurityPolicySpec from policy API Group instead.
969type PodSecurityPolicySpec struct {
970 // privileged determines if a pod can request to be run as privileged.
971 // +optional
972 Privileged bool `json:"privileged,omitempty" protobuf:"varint,1,opt,name=privileged"`
973 // defaultAddCapabilities is the default set of capabilities that will be added to the container
974 // unless the pod spec specifically drops the capability. You may not list a capability in both
975 // defaultAddCapabilities and requiredDropCapabilities. Capabilities added here are implicitly
976 // allowed, and need not be included in the allowedCapabilities list.
977 // +optional
978 DefaultAddCapabilities []v1.Capability `json:"defaultAddCapabilities,omitempty" protobuf:"bytes,2,rep,name=defaultAddCapabilities,casttype=k8s.io/api/core/v1.Capability"`
979 // requiredDropCapabilities are the capabilities that will be dropped from the container. These
980 // are required to be dropped and cannot be added.
981 // +optional
982 RequiredDropCapabilities []v1.Capability `json:"requiredDropCapabilities,omitempty" protobuf:"bytes,3,rep,name=requiredDropCapabilities,casttype=k8s.io/api/core/v1.Capability"`
983 // allowedCapabilities is a list of capabilities that can be requested to add to the container.
984 // Capabilities in this field may be added at the pod author's discretion.
985 // You must not list a capability in both allowedCapabilities and requiredDropCapabilities.
986 // +optional
987 AllowedCapabilities []v1.Capability `json:"allowedCapabilities,omitempty" protobuf:"bytes,4,rep,name=allowedCapabilities,casttype=k8s.io/api/core/v1.Capability"`
988 // volumes is an allowlist of volume plugins. Empty indicates that
989 // no volumes may be used. To allow all volumes you may use '*'.
990 // +optional
991 Volumes []FSType `json:"volumes,omitempty" protobuf:"bytes,5,rep,name=volumes,casttype=FSType"`
992 // hostNetwork determines if the policy allows the use of HostNetwork in the pod spec.
993 // +optional
994 HostNetwork bool `json:"hostNetwork,omitempty" protobuf:"varint,6,opt,name=hostNetwork"`
995 // hostPorts determines which host port ranges are allowed to be exposed.
996 // +optional
997 HostPorts []HostPortRange `json:"hostPorts,omitempty" protobuf:"bytes,7,rep,name=hostPorts"`
998 // hostPID determines if the policy allows the use of HostPID in the pod spec.
999 // +optional
1000 HostPID bool `json:"hostPID,omitempty" protobuf:"varint,8,opt,name=hostPID"`
1001 // hostIPC determines if the policy allows the use of HostIPC in the pod spec.
1002 // +optional
1003 HostIPC bool `json:"hostIPC,omitempty" protobuf:"varint,9,opt,name=hostIPC"`
1004 // seLinux is the strategy that will dictate the allowable labels that may be set.
1005 SELinux SELinuxStrategyOptions `json:"seLinux" protobuf:"bytes,10,opt,name=seLinux"`
1006 // runAsUser is the strategy that will dictate the allowable RunAsUser values that may be set.
1007 RunAsUser RunAsUserStrategyOptions `json:"runAsUser" protobuf:"bytes,11,opt,name=runAsUser"`
1008 // RunAsGroup is the strategy that will dictate the allowable RunAsGroup values that may be set.
1009 // If this field is omitted, the pod's RunAsGroup can take any value. This field requires the
1010 // RunAsGroup feature gate to be enabled.
1011 // +optional
1012 RunAsGroup *RunAsGroupStrategyOptions `json:"runAsGroup,omitempty" protobuf:"bytes,22,opt,name=runAsGroup"`
1013 // supplementalGroups is the strategy that will dictate what supplemental groups are used by the SecurityContext.
1014 SupplementalGroups SupplementalGroupsStrategyOptions `json:"supplementalGroups" protobuf:"bytes,12,opt,name=supplementalGroups"`
1015 // fsGroup is the strategy that will dictate what fs group is used by the SecurityContext.
1016 FSGroup FSGroupStrategyOptions `json:"fsGroup" protobuf:"bytes,13,opt,name=fsGroup"`
1017 // readOnlyRootFilesystem when set to true will force containers to run with a read only root file
1018 // system. If the container specifically requests to run with a non-read only root file system
1019 // the PSP should deny the pod.
1020 // If set to false the container may run with a read only root file system if it wishes but it
1021 // will not be forced to.
1022 // +optional
1023 ReadOnlyRootFilesystem bool `json:"readOnlyRootFilesystem,omitempty" protobuf:"varint,14,opt,name=readOnlyRootFilesystem"`
1024 // defaultAllowPrivilegeEscalation controls the default setting for whether a
1025 // process can gain more privileges than its parent process.
1026 // +optional
1027 DefaultAllowPrivilegeEscalation *bool `json:"defaultAllowPrivilegeEscalation,omitempty" protobuf:"varint,15,opt,name=defaultAllowPrivilegeEscalation"`
1028 // allowPrivilegeEscalation determines if a pod can request to allow
1029 // privilege escalation. If unspecified, defaults to true.
1030 // +optional
1031 AllowPrivilegeEscalation *bool `json:"allowPrivilegeEscalation,omitempty" protobuf:"varint,16,opt,name=allowPrivilegeEscalation"`
1032 // allowedHostPaths is an allowlist of host paths. Empty indicates
1033 // that all host paths may be used.
1034 // +optional
1035 AllowedHostPaths []AllowedHostPath `json:"allowedHostPaths,omitempty" protobuf:"bytes,17,rep,name=allowedHostPaths"`
1036 // allowedFlexVolumes is an allowlist of Flexvolumes. Empty or nil indicates that all
1037 // Flexvolumes may be used. This parameter is effective only when the usage of the Flexvolumes
1038 // is allowed in the "volumes" field.
1039 // +optional
1040 AllowedFlexVolumes []AllowedFlexVolume `json:"allowedFlexVolumes,omitempty" protobuf:"bytes,18,rep,name=allowedFlexVolumes"`
1041 // AllowedCSIDrivers is an allowlist of inline CSI drivers that must be explicitly set to be embedded within a pod spec.
1042 // An empty value indicates that any CSI driver can be used for inline ephemeral volumes.
1043 // +optional
1044 AllowedCSIDrivers []AllowedCSIDriver `json:"allowedCSIDrivers,omitempty" protobuf:"bytes,23,rep,name=allowedCSIDrivers"`
1045 // allowedUnsafeSysctls is a list of explicitly allowed unsafe sysctls, defaults to none.
1046 // Each entry is either a plain sysctl name or ends in "*" in which case it is considered
1047 // as a prefix of allowed sysctls. Single * means all unsafe sysctls are allowed.
1048 // Kubelet has to allowlist all unsafe sysctls explicitly to avoid rejection.
1049 //
1050 // Examples:
1051 // e.g. "foo/*" allows "foo/bar", "foo/baz", etc.
1052 // e.g. "foo.*" allows "foo.bar", "foo.baz", etc.
1053 // +optional
1054 AllowedUnsafeSysctls []string `json:"allowedUnsafeSysctls,omitempty" protobuf:"bytes,19,rep,name=allowedUnsafeSysctls"`
1055 // forbiddenSysctls is a list of explicitly forbidden sysctls, defaults to none.
1056 // Each entry is either a plain sysctl name or ends in "*" in which case it is considered
1057 // as a prefix of forbidden sysctls. Single * means all sysctls are forbidden.
1058 //
1059 // Examples:
1060 // e.g. "foo/*" forbids "foo/bar", "foo/baz", etc.
1061 // e.g. "foo.*" forbids "foo.bar", "foo.baz", etc.
1062 // +optional
1063 ForbiddenSysctls []string `json:"forbiddenSysctls,omitempty" protobuf:"bytes,20,rep,name=forbiddenSysctls"`
1064 // AllowedProcMountTypes is an allowlist of allowed ProcMountTypes.
1065 // Empty or nil indicates that only the DefaultProcMountType may be used.
1066 // This requires the ProcMountType feature flag to be enabled.
1067 // +optional
1068 AllowedProcMountTypes []v1.ProcMountType `json:"allowedProcMountTypes,omitempty" protobuf:"bytes,21,opt,name=allowedProcMountTypes"`
1069 // runtimeClass is the strategy that will dictate the allowable RuntimeClasses for a pod.
1070 // If this field is omitted, the pod's runtimeClassName field is unrestricted.
1071 // Enforcement of this field depends on the RuntimeClass feature gate being enabled.
1072 // +optional
1073 RuntimeClass *RuntimeClassStrategyOptions `json:"runtimeClass,omitempty" protobuf:"bytes,24,opt,name=runtimeClass"`
1074}
1075
1076// AllowedHostPath defines the host volume conditions that will be enabled by a policy
1077// for pods to use. It requires the path prefix to be defined.
1078// Deprecated: use AllowedHostPath from policy API Group instead.
1079type AllowedHostPath struct {
1080 // pathPrefix is the path prefix that the host volume must match.
1081 // It does not support `*`.
1082 // Trailing slashes are trimmed when validating the path prefix with a host path.
1083 //
1084 // Examples:
1085 // `/foo` would allow `/foo`, `/foo/` and `/foo/bar`
1086 // `/foo` would not allow `/food` or `/etc/foo`
1087 PathPrefix string `json:"pathPrefix,omitempty" protobuf:"bytes,1,rep,name=pathPrefix"`
1088
1089 // when set to true, will allow host volumes matching the pathPrefix only if all volume mounts are readOnly.
1090 // +optional
1091 ReadOnly bool `json:"readOnly,omitempty" protobuf:"varint,2,opt,name=readOnly"`
1092}
1093
1094// FSType gives strong typing to different file systems that are used by volumes.
1095// Deprecated: use FSType from policy API Group instead.
1096type FSType string
1097
1098const (
1099 AzureFile FSType = "azureFile"
1100 Flocker FSType = "flocker"
1101 FlexVolume FSType = "flexVolume"
1102 HostPath FSType = "hostPath"
1103 EmptyDir FSType = "emptyDir"
1104 GCEPersistentDisk FSType = "gcePersistentDisk"
1105 AWSElasticBlockStore FSType = "awsElasticBlockStore"
1106 GitRepo FSType = "gitRepo"
1107 Secret FSType = "secret"
1108 NFS FSType = "nfs"
1109 ISCSI FSType = "iscsi"
1110 Glusterfs FSType = "glusterfs"
1111 PersistentVolumeClaim FSType = "persistentVolumeClaim"
1112 RBD FSType = "rbd"
1113 Cinder FSType = "cinder"
1114 CephFS FSType = "cephFS"
1115 DownwardAPI FSType = "downwardAPI"
1116 FC FSType = "fc"
1117 ConfigMap FSType = "configMap"
1118 Quobyte FSType = "quobyte"
1119 AzureDisk FSType = "azureDisk"
1120 CSI FSType = "csi"
1121 All FSType = "*"
1122)
1123
1124// AllowedFlexVolume represents a single Flexvolume that is allowed to be used.
1125// Deprecated: use AllowedFlexVolume from policy API Group instead.
1126type AllowedFlexVolume struct {
1127 // driver is the name of the Flexvolume driver.
1128 Driver string `json:"driver" protobuf:"bytes,1,opt,name=driver"`
1129}
1130
1131// AllowedCSIDriver represents a single inline CSI Driver that is allowed to be used.
1132type AllowedCSIDriver struct {
1133 // Name is the registered name of the CSI driver
1134 Name string `json:"name" protobuf:"bytes,1,opt,name=name"`
1135}
1136
1137// HostPortRange defines a range of host ports that will be enabled by a policy
1138// for pods to use. It requires both the start and end to be defined.
1139// Deprecated: use HostPortRange from policy API Group instead.
1140type HostPortRange struct {
1141 // min is the start of the range, inclusive.
1142 Min int32 `json:"min" protobuf:"varint,1,opt,name=min"`
1143 // max is the end of the range, inclusive.
1144 Max int32 `json:"max" protobuf:"varint,2,opt,name=max"`
1145}
1146
1147// SELinuxStrategyOptions defines the strategy type and any options used to create the strategy.
1148// Deprecated: use SELinuxStrategyOptions from policy API Group instead.
1149type SELinuxStrategyOptions struct {
1150 // rule is the strategy that will dictate the allowable labels that may be set.
1151 Rule SELinuxStrategy `json:"rule" protobuf:"bytes,1,opt,name=rule,casttype=SELinuxStrategy"`
1152 // seLinuxOptions required to run as; required for MustRunAs
1153 // More info: https://kubernetes.io/docs/tasks/configure-pod-container/security-context/
1154 // +optional
1155 SELinuxOptions *v1.SELinuxOptions `json:"seLinuxOptions,omitempty" protobuf:"bytes,2,opt,name=seLinuxOptions"`
1156}
1157
1158// SELinuxStrategy denotes strategy types for generating SELinux options for a
1159// Security Context.
1160// Deprecated: use SELinuxStrategy from policy API Group instead.
1161type SELinuxStrategy string
1162
1163const (
1164 // SELinuxStrategyMustRunAs means that container must have SELinux labels of X applied.
1165 // Deprecated: use SELinuxStrategyMustRunAs from policy API Group instead.
1166 SELinuxStrategyMustRunAs SELinuxStrategy = "MustRunAs"
1167 // SELinuxStrategyRunAsAny means that container may make requests for any SELinux context labels.
1168 // Deprecated: use SELinuxStrategyRunAsAny from policy API Group instead.
1169 SELinuxStrategyRunAsAny SELinuxStrategy = "RunAsAny"
1170)
1171
1172// RunAsUserStrategyOptions defines the strategy type and any options used to create the strategy.
1173// Deprecated: use RunAsUserStrategyOptions from policy API Group instead.
1174type RunAsUserStrategyOptions struct {
1175 // rule is the strategy that will dictate the allowable RunAsUser values that may be set.
1176 Rule RunAsUserStrategy `json:"rule" protobuf:"bytes,1,opt,name=rule,casttype=RunAsUserStrategy"`
1177 // ranges are the allowed ranges of uids that may be used. If you would like to force a single uid
1178 // then supply a single range with the same start and end. Required for MustRunAs.
1179 // +optional
1180 Ranges []IDRange `json:"ranges,omitempty" protobuf:"bytes,2,rep,name=ranges"`
1181}
1182
1183// RunAsGroupStrategyOptions defines the strategy type and any options used to create the strategy.
1184// Deprecated: use RunAsGroupStrategyOptions from policy API Group instead.
1185type RunAsGroupStrategyOptions struct {
1186 // rule is the strategy that will dictate the allowable RunAsGroup values that may be set.
1187 Rule RunAsGroupStrategy `json:"rule" protobuf:"bytes,1,opt,name=rule,casttype=RunAsGroupStrategy"`
1188 // ranges are the allowed ranges of gids that may be used. If you would like to force a single gid
1189 // then supply a single range with the same start and end. Required for MustRunAs.
1190 // +optional
1191 Ranges []IDRange `json:"ranges,omitempty" protobuf:"bytes,2,rep,name=ranges"`
1192}
1193
1194// IDRange provides a min/max of an allowed range of IDs.
1195// Deprecated: use IDRange from policy API Group instead.
1196type IDRange struct {
1197 // min is the start of the range, inclusive.
1198 Min int64 `json:"min" protobuf:"varint,1,opt,name=min"`
1199 // max is the end of the range, inclusive.
1200 Max int64 `json:"max" protobuf:"varint,2,opt,name=max"`
1201}
1202
1203// RunAsUserStrategy denotes strategy types for generating RunAsUser values for a
1204// Security Context.
1205// Deprecated: use RunAsUserStrategy from policy API Group instead.
1206type RunAsUserStrategy string
1207
1208const (
1209 // RunAsUserStrategyMustRunAs means that container must run as a particular uid.
1210 // Deprecated: use RunAsUserStrategyMustRunAs from policy API Group instead.
1211 RunAsUserStrategyMustRunAs RunAsUserStrategy = "MustRunAs"
1212 // RunAsUserStrategyMustRunAsNonRoot means that container must run as a non-root uid.
1213 // Deprecated: use RunAsUserStrategyMustRunAsNonRoot from policy API Group instead.
1214 RunAsUserStrategyMustRunAsNonRoot RunAsUserStrategy = "MustRunAsNonRoot"
1215 // RunAsUserStrategyRunAsAny means that container may make requests for any uid.
1216 // Deprecated: use RunAsUserStrategyRunAsAny from policy API Group instead.
1217 RunAsUserStrategyRunAsAny RunAsUserStrategy = "RunAsAny"
1218)
1219
1220// RunAsGroupStrategy denotes strategy types for generating RunAsGroup values for a
1221// Security Context.
1222// Deprecated: use RunAsGroupStrategy from policy API Group instead.
1223type RunAsGroupStrategy string
1224
1225const (
1226 // RunAsGroupStrategyMayRunAs means that container does not need to run with a particular gid.
1227 // However, when RunAsGroup are specified, they have to fall in the defined range.
1228 RunAsGroupStrategyMayRunAs RunAsGroupStrategy = "MayRunAs"
1229 // RunAsGroupStrategyMustRunAs means that container must run as a particular gid.
1230 // Deprecated: use RunAsGroupStrategyMustRunAs from policy API Group instead.
1231 RunAsGroupStrategyMustRunAs RunAsGroupStrategy = "MustRunAs"
1232 // RunAsGroupStrategyRunAsAny means that container may make requests for any gid.
1233 // Deprecated: use RunAsGroupStrategyRunAsAny from policy API Group instead.
1234 RunAsGroupStrategyRunAsAny RunAsGroupStrategy = "RunAsAny"
1235)
1236
1237// FSGroupStrategyOptions defines the strategy type and options used to create the strategy.
1238// Deprecated: use FSGroupStrategyOptions from policy API Group instead.
1239type FSGroupStrategyOptions struct {
1240 // rule is the strategy that will dictate what FSGroup is used in the SecurityContext.
1241 // +optional
1242 Rule FSGroupStrategyType `json:"rule,omitempty" protobuf:"bytes,1,opt,name=rule,casttype=FSGroupStrategyType"`
1243 // ranges are the allowed ranges of fs groups. If you would like to force a single
1244 // fs group then supply a single range with the same start and end. Required for MustRunAs.
1245 // +optional
1246 Ranges []IDRange `json:"ranges,omitempty" protobuf:"bytes,2,rep,name=ranges"`
1247}
1248
1249// FSGroupStrategyType denotes strategy types for generating FSGroup values for a
1250// SecurityContext
1251// Deprecated: use FSGroupStrategyType from policy API Group instead.
1252type FSGroupStrategyType string
1253
1254const (
1255 // FSGroupStrategyMustRunAs meant that container must have FSGroup of X applied.
1256 // Deprecated: use FSGroupStrategyMustRunAs from policy API Group instead.
1257 FSGroupStrategyMustRunAs FSGroupStrategyType = "MustRunAs"
1258 // FSGroupStrategyRunAsAny means that container may make requests for any FSGroup labels.
1259 // Deprecated: use FSGroupStrategyRunAsAny from policy API Group instead.
1260 FSGroupStrategyRunAsAny FSGroupStrategyType = "RunAsAny"
1261)
1262
1263// SupplementalGroupsStrategyOptions defines the strategy type and options used to create the strategy.
1264// Deprecated: use SupplementalGroupsStrategyOptions from policy API Group instead.
1265type SupplementalGroupsStrategyOptions struct {
1266 // rule is the strategy that will dictate what supplemental groups is used in the SecurityContext.
1267 // +optional
1268 Rule SupplementalGroupsStrategyType `json:"rule,omitempty" protobuf:"bytes,1,opt,name=rule,casttype=SupplementalGroupsStrategyType"`
1269 // ranges are the allowed ranges of supplemental groups. If you would like to force a single
1270 // supplemental group then supply a single range with the same start and end. Required for MustRunAs.
1271 // +optional
1272 Ranges []IDRange `json:"ranges,omitempty" protobuf:"bytes,2,rep,name=ranges"`
1273}
1274
1275// SupplementalGroupsStrategyType denotes strategy types for determining valid supplemental
1276// groups for a SecurityContext.
1277// Deprecated: use SupplementalGroupsStrategyType from policy API Group instead.
1278type SupplementalGroupsStrategyType string
1279
1280const (
1281 // SupplementalGroupsStrategyMustRunAs means that container must run as a particular gid.
1282 // Deprecated: use SupplementalGroupsStrategyMustRunAs from policy API Group instead.
1283 SupplementalGroupsStrategyMustRunAs SupplementalGroupsStrategyType = "MustRunAs"
1284 // SupplementalGroupsStrategyRunAsAny means that container may make requests for any gid.
1285 // Deprecated: use SupplementalGroupsStrategyRunAsAny from policy API Group instead.
1286 SupplementalGroupsStrategyRunAsAny SupplementalGroupsStrategyType = "RunAsAny"
1287)
1288
1289// RuntimeClassStrategyOptions define the strategy that will dictate the allowable RuntimeClasses
1290// for a pod.
1291type RuntimeClassStrategyOptions struct {
1292 // allowedRuntimeClassNames is an allowlist of RuntimeClass names that may be specified on a pod.
1293 // A value of "*" means that any RuntimeClass name is allowed, and must be the only item in the
1294 // list. An empty list requires the RuntimeClassName field to be unset.
1295 AllowedRuntimeClassNames []string `json:"allowedRuntimeClassNames" protobuf:"bytes,1,rep,name=allowedRuntimeClassNames"`
1296 // defaultRuntimeClassName is the default RuntimeClassName to set on the pod.
1297 // The default MUST be allowed by the allowedRuntimeClassNames list.
1298 // A value of nil does not mutate the Pod.
1299 // +optional
1300 DefaultRuntimeClassName *string `json:"defaultRuntimeClassName,omitempty" protobuf:"bytes,2,opt,name=defaultRuntimeClassName"`
1301}
1302
1303// AllowAllRuntimeClassNames can be used as a value for the
1304// RuntimeClassStrategyOptions.AllowedRuntimeClassNames field and means that any RuntimeClassName is
1305// allowed.
1306const AllowAllRuntimeClassNames = "*"
1307
1308// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
1309// +k8s:prerelease-lifecycle-gen:introduced=1.2
1310// +k8s:prerelease-lifecycle-gen:deprecated=1.11
1311// +k8s:prerelease-lifecycle-gen:removed=1.18
1312// +k8s:prerelease-lifecycle-gen:replacement=policy,v1beta1,PodSecurityPolicyList
1313
1314// PodSecurityPolicyList is a list of PodSecurityPolicy objects.
1315// Deprecated: use PodSecurityPolicyList from policy API Group instead.
1316type PodSecurityPolicyList struct {
1317 metav1.TypeMeta `json:",inline"`
1318 // Standard list metadata.
1319 // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata
1320 // +optional
1321 metav1.ListMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
1322
1323 // items is a list of schema objects.
1324 Items []PodSecurityPolicy `json:"items" protobuf:"bytes,2,rep,name=items"`
1325}
1326
1327// +genclient
1328// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
1329// +k8s:prerelease-lifecycle-gen:introduced=1.3
1330// +k8s:prerelease-lifecycle-gen:deprecated=1.9
1331// +k8s:prerelease-lifecycle-gen:removed=1.18
1332// +k8s:prerelease-lifecycle-gen:replacement=networking.k8s.io,v1,NetworkPolicy
1333
1334// DEPRECATED 1.9 - This group version of NetworkPolicy is deprecated by networking/v1/NetworkPolicy.
1335// NetworkPolicy describes what network traffic is allowed for a set of Pods
1336type NetworkPolicy struct {
1337 metav1.TypeMeta `json:",inline"`
1338 // Standard object's metadata.
1339 // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata
1340 // +optional
1341 metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
1342
1343 // Specification of the desired behavior for this NetworkPolicy.
1344 // +optional
1345 Spec NetworkPolicySpec `json:"spec,omitempty" protobuf:"bytes,2,opt,name=spec"`
1346}
1347
1348// DEPRECATED 1.9 - This group version of PolicyType is deprecated by networking/v1/PolicyType.
1349// Policy Type string describes the NetworkPolicy type
1350// This type is beta-level in 1.8
1351type PolicyType string
1352
1353const (
1354 // PolicyTypeIngress is a NetworkPolicy that affects ingress traffic on selected pods
1355 PolicyTypeIngress PolicyType = "Ingress"
1356 // PolicyTypeEgress is a NetworkPolicy that affects egress traffic on selected pods
1357 PolicyTypeEgress PolicyType = "Egress"
1358)
1359
1360// DEPRECATED 1.9 - This group version of NetworkPolicySpec is deprecated by networking/v1/NetworkPolicySpec.
1361type NetworkPolicySpec struct {
1362 // Selects the pods to which this NetworkPolicy object applies. The array of ingress rules
1363 // is applied to any pods selected by this field. Multiple network policies can select the
1364 // same set of pods. In this case, the ingress rules for each are combined additively.
1365 // This field is NOT optional and follows standard label selector semantics.
1366 // An empty podSelector matches all pods in this namespace.
1367 PodSelector metav1.LabelSelector `json:"podSelector" protobuf:"bytes,1,opt,name=podSelector"`
1368
1369 // List of ingress rules to be applied to the selected pods.
1370 // Traffic is allowed to a pod if there are no NetworkPolicies selecting the pod
1371 // OR if the traffic source is the pod's local node,
1372 // OR if the traffic matches at least one ingress rule across all of the NetworkPolicy
1373 // objects whose podSelector matches the pod.
1374 // If this field is empty then this NetworkPolicy does not allow any traffic
1375 // (and serves solely to ensure that the pods it selects are isolated by default).
1376 // +optional
1377 Ingress []NetworkPolicyIngressRule `json:"ingress,omitempty" protobuf:"bytes,2,rep,name=ingress"`
1378
1379 // List of egress rules to be applied to the selected pods. Outgoing traffic is
1380 // allowed if there are no NetworkPolicies selecting the pod (and cluster policy
1381 // otherwise allows the traffic), OR if the traffic matches at least one egress rule
1382 // across all of the NetworkPolicy objects whose podSelector matches the pod. If
1383 // this field is empty then this NetworkPolicy limits all outgoing traffic (and serves
1384 // solely to ensure that the pods it selects are isolated by default).
1385 // This field is beta-level in 1.8
1386 // +optional
1387 Egress []NetworkPolicyEgressRule `json:"egress,omitempty" protobuf:"bytes,3,rep,name=egress"`
1388
1389 // List of rule types that the NetworkPolicy relates to.
1390 // Valid options are "Ingress", "Egress", or "Ingress,Egress".
1391 // If this field is not specified, it will default based on the existence of Ingress or Egress rules;
1392 // policies that contain an Egress section are assumed to affect Egress, and all policies
1393 // (whether or not they contain an Ingress section) are assumed to affect Ingress.
1394 // If you want to write an egress-only policy, you must explicitly specify policyTypes [ "Egress" ].
1395 // Likewise, if you want to write a policy that specifies that no egress is allowed,
1396 // you must specify a policyTypes value that include "Egress" (since such a policy would not include
1397 // an Egress section and would otherwise default to just [ "Ingress" ]).
1398 // This field is beta-level in 1.8
1399 // +optional
1400 PolicyTypes []PolicyType `json:"policyTypes,omitempty" protobuf:"bytes,4,rep,name=policyTypes,casttype=PolicyType"`
1401}
1402
1403// DEPRECATED 1.9 - This group version of NetworkPolicyIngressRule is deprecated by networking/v1/NetworkPolicyIngressRule.
1404// This NetworkPolicyIngressRule matches traffic if and only if the traffic matches both ports AND from.
1405type NetworkPolicyIngressRule struct {
1406 // List of ports which should be made accessible on the pods selected for this rule.
1407 // Each item in this list is combined using a logical OR.
1408 // If this field is empty or missing, this rule matches all ports (traffic not restricted by port).
1409 // If this field is present and contains at least one item, then this rule allows traffic
1410 // only if the traffic matches at least one port in the list.
1411 // +optional
1412 Ports []NetworkPolicyPort `json:"ports,omitempty" protobuf:"bytes,1,rep,name=ports"`
1413
1414 // List of sources which should be able to access the pods selected for this rule.
1415 // Items in this list are combined using a logical OR operation.
1416 // If this field is empty or missing, this rule matches all sources (traffic not restricted by source).
1417 // If this field is present and contains at least one item, this rule allows traffic only if the
1418 // traffic matches at least one item in the from list.
1419 // +optional
1420 From []NetworkPolicyPeer `json:"from,omitempty" protobuf:"bytes,2,rep,name=from"`
1421}
1422
1423// DEPRECATED 1.9 - This group version of NetworkPolicyEgressRule is deprecated by networking/v1/NetworkPolicyEgressRule.
1424// NetworkPolicyEgressRule describes a particular set of traffic that is allowed out of pods
1425// matched by a NetworkPolicySpec's podSelector. The traffic must match both ports and to.
1426// This type is beta-level in 1.8
1427type NetworkPolicyEgressRule struct {
1428 // List of destination ports for outgoing traffic.
1429 // Each item in this list is combined using a logical OR. If this field is
1430 // empty or missing, this rule matches all ports (traffic not restricted by port).
1431 // If this field is present and contains at least one item, then this rule allows
1432 // traffic only if the traffic matches at least one port in the list.
1433 // +optional
1434 Ports []NetworkPolicyPort `json:"ports,omitempty" protobuf:"bytes,1,rep,name=ports"`
1435
1436 // List of destinations for outgoing traffic of pods selected for this rule.
1437 // Items in this list are combined using a logical OR operation. If this field is
1438 // empty or missing, this rule matches all destinations (traffic not restricted by
1439 // destination). If this field is present and contains at least one item, this rule
1440 // allows traffic only if the traffic matches at least one item in the to list.
1441 // +optional
1442 To []NetworkPolicyPeer `json:"to,omitempty" protobuf:"bytes,2,rep,name=to"`
1443}
1444
1445// DEPRECATED 1.9 - This group version of NetworkPolicyPort is deprecated by networking/v1/NetworkPolicyPort.
1446type NetworkPolicyPort struct {
1447 // Optional. The protocol (TCP, UDP, or SCTP) which traffic must match.
1448 // If not specified, this field defaults to TCP.
1449 // +optional
1450 Protocol *v1.Protocol `json:"protocol,omitempty" protobuf:"bytes,1,opt,name=protocol,casttype=k8s.io/api/core/v1.Protocol"`
1451
1452 // If specified, the port on the given protocol. This can
1453 // either be a numerical or named port on a pod. If this field is not provided,
1454 // this matches all port names and numbers.
1455 // If present, only traffic on the specified protocol AND port
1456 // will be matched.
1457 // +optional
1458 Port *intstr.IntOrString `json:"port,omitempty" protobuf:"bytes,2,opt,name=port"`
1459}
1460
1461// DEPRECATED 1.9 - This group version of IPBlock is deprecated by networking/v1/IPBlock.
1462// IPBlock describes a particular CIDR (Ex. "192.168.1.1/24","2001:db9::/64") that is allowed
1463// to the pods matched by a NetworkPolicySpec's podSelector. The except entry describes CIDRs
1464// that should not be included within this rule.
1465type IPBlock struct {
1466 // CIDR is a string representing the IP Block
1467 // Valid examples are "192.168.1.1/24" or "2001:db9::/64"
1468 CIDR string `json:"cidr" protobuf:"bytes,1,name=cidr"`
1469 // Except is a slice of CIDRs that should not be included within an IP Block
1470 // Valid examples are "192.168.1.1/24" or "2001:db9::/64"
1471 // Except values will be rejected if they are outside the CIDR range
1472 // +optional
1473 Except []string `json:"except,omitempty" protobuf:"bytes,2,rep,name=except"`
1474}
1475
1476// DEPRECATED 1.9 - This group version of NetworkPolicyPeer is deprecated by networking/v1/NetworkPolicyPeer.
1477type NetworkPolicyPeer struct {
1478 // This is a label selector which selects Pods. This field follows standard label
1479 // selector semantics; if present but empty, it selects all pods.
1480 //
1481 // If NamespaceSelector is also set, then the NetworkPolicyPeer as a whole selects
1482 // the Pods matching PodSelector in the Namespaces selected by NamespaceSelector.
1483 // Otherwise it selects the Pods matching PodSelector in the policy's own Namespace.
1484 // +optional
1485 PodSelector *metav1.LabelSelector `json:"podSelector,omitempty" protobuf:"bytes,1,opt,name=podSelector"`
1486
1487 // Selects Namespaces using cluster-scoped labels. This field follows standard label
1488 // selector semantics; if present but empty, it selects all namespaces.
1489 //
1490 // If PodSelector is also set, then the NetworkPolicyPeer as a whole selects
1491 // the Pods matching PodSelector in the Namespaces selected by NamespaceSelector.
1492 // Otherwise it selects all Pods in the Namespaces selected by NamespaceSelector.
1493 // +optional
1494 NamespaceSelector *metav1.LabelSelector `json:"namespaceSelector,omitempty" protobuf:"bytes,2,opt,name=namespaceSelector"`
1495
1496 // IPBlock defines policy on a particular IPBlock. If this field is set then
1497 // neither of the other fields can be.
1498 // +optional
1499 IPBlock *IPBlock `json:"ipBlock,omitempty" protobuf:"bytes,3,rep,name=ipBlock"`
1500}
1501
1502// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
1503// +k8s:prerelease-lifecycle-gen:introduced=1.3
1504// +k8s:prerelease-lifecycle-gen:deprecated=1.9
1505// +k8s:prerelease-lifecycle-gen:removed=1.18
1506// +k8s:prerelease-lifecycle-gen:replacement=networking.k8s.io,v1,NetworkPolicyList
1507
1508// DEPRECATED 1.9 - This group version of NetworkPolicyList is deprecated by networking/v1/NetworkPolicyList.
1509// Network Policy List is a list of NetworkPolicy objects.
1510type NetworkPolicyList struct {
1511 metav1.TypeMeta `json:",inline"`
1512 // Standard list metadata.
1513 // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata
1514 // +optional
1515 metav1.ListMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
1516
1517 // Items is a list of schema objects.
1518 Items []NetworkPolicy `json:"items" protobuf:"bytes,2,rep,name=items"`
1519}