blob: 711afc80c7380366eeafb5f5a2dcb2e19584b806 [file] [log] [blame]
Matteo Scandoloa4285862020-12-01 18:10:10 -08001/*
2Copyright 2016 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 v1 "k8s.io/api/core/v1"
21 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
22 "k8s.io/apimachinery/pkg/util/intstr"
23)
24
25// PodDisruptionBudgetSpec is a description of a PodDisruptionBudget.
26type PodDisruptionBudgetSpec struct {
27 // An eviction is allowed if at least "minAvailable" pods selected by
28 // "selector" will still be available after the eviction, i.e. even in the
29 // absence of the evicted pod. So for example you can prevent all voluntary
30 // evictions by specifying "100%".
31 // +optional
32 MinAvailable *intstr.IntOrString `json:"minAvailable,omitempty" protobuf:"bytes,1,opt,name=minAvailable"`
33
34 // Label query over pods whose evictions are managed by the disruption
35 // budget.
36 // +optional
37 Selector *metav1.LabelSelector `json:"selector,omitempty" protobuf:"bytes,2,opt,name=selector"`
38
39 // An eviction is allowed if at most "maxUnavailable" pods selected by
40 // "selector" are unavailable after the eviction, i.e. even in absence of
41 // the evicted pod. For example, one can prevent all voluntary evictions
42 // by specifying 0. This is a mutually exclusive setting with "minAvailable".
43 // +optional
44 MaxUnavailable *intstr.IntOrString `json:"maxUnavailable,omitempty" protobuf:"bytes,3,opt,name=maxUnavailable"`
45}
46
47// PodDisruptionBudgetStatus represents information about the status of a
48// PodDisruptionBudget. Status may trail the actual state of a system.
49type PodDisruptionBudgetStatus struct {
50 // Most recent generation observed when updating this PDB status. DisruptionsAllowed and other
51 // status information is valid only if observedGeneration equals to PDB's object generation.
52 // +optional
53 ObservedGeneration int64 `json:"observedGeneration,omitempty" protobuf:"varint,1,opt,name=observedGeneration"`
54
55 // DisruptedPods contains information about pods whose eviction was
56 // processed by the API server eviction subresource handler but has not
57 // yet been observed by the PodDisruptionBudget controller.
58 // A pod will be in this map from the time when the API server processed the
59 // eviction request to the time when the pod is seen by PDB controller
60 // as having been marked for deletion (or after a timeout). The key in the map is the name of the pod
61 // and the value is the time when the API server processed the eviction request. If
62 // the deletion didn't occur and a pod is still there it will be removed from
63 // the list automatically by PodDisruptionBudget controller after some time.
64 // If everything goes smooth this map should be empty for the most of the time.
65 // Large number of entries in the map may indicate problems with pod deletions.
66 // +optional
67 DisruptedPods map[string]metav1.Time `json:"disruptedPods,omitempty" protobuf:"bytes,2,rep,name=disruptedPods"`
68
69 // Number of pod disruptions that are currently allowed.
70 DisruptionsAllowed int32 `json:"disruptionsAllowed" protobuf:"varint,3,opt,name=disruptionsAllowed"`
71
72 // current number of healthy pods
73 CurrentHealthy int32 `json:"currentHealthy" protobuf:"varint,4,opt,name=currentHealthy"`
74
75 // minimum desired number of healthy pods
76 DesiredHealthy int32 `json:"desiredHealthy" protobuf:"varint,5,opt,name=desiredHealthy"`
77
78 // total number of pods counted by this disruption budget
79 ExpectedPods int32 `json:"expectedPods" protobuf:"varint,6,opt,name=expectedPods"`
80}
81
82// +genclient
83// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
84// +k8s:prerelease-lifecycle-gen:introduced=1.5
85// +k8s:prerelease-lifecycle-gen:deprecated=1.22
86
87// PodDisruptionBudget is an object to define the max disruption that can be caused to a collection of pods
88type PodDisruptionBudget struct {
89 metav1.TypeMeta `json:",inline"`
90 // +optional
91 metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
92
93 // Specification of the desired behavior of the PodDisruptionBudget.
94 // +optional
95 Spec PodDisruptionBudgetSpec `json:"spec,omitempty" protobuf:"bytes,2,opt,name=spec"`
96 // Most recently observed status of the PodDisruptionBudget.
97 // +optional
98 Status PodDisruptionBudgetStatus `json:"status,omitempty" protobuf:"bytes,3,opt,name=status"`
99}
100
101// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
102// +k8s:prerelease-lifecycle-gen:introduced=1.5
103// +k8s:prerelease-lifecycle-gen:deprecated=1.22
104
105// PodDisruptionBudgetList is a collection of PodDisruptionBudgets.
106type PodDisruptionBudgetList struct {
107 metav1.TypeMeta `json:",inline"`
108 // +optional
109 metav1.ListMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
110 Items []PodDisruptionBudget `json:"items" protobuf:"bytes,2,rep,name=items"`
111}
112
113// +genclient
114// +genclient:noVerbs
115// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
116// +k8s:prerelease-lifecycle-gen:introduced=1.5
117// +k8s:prerelease-lifecycle-gen:deprecated=1.22
118
119// Eviction evicts a pod from its node subject to certain policies and safety constraints.
120// This is a subresource of Pod. A request to cause such an eviction is
121// created by POSTing to .../pods/<pod name>/evictions.
122type Eviction struct {
123 metav1.TypeMeta `json:",inline"`
124
125 // ObjectMeta describes the pod that is being evicted.
126 // +optional
127 metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
128
129 // DeleteOptions may be provided
130 // +optional
131 DeleteOptions *metav1.DeleteOptions `json:"deleteOptions,omitempty" protobuf:"bytes,2,opt,name=deleteOptions"`
132}
133
134// +genclient
135// +genclient:nonNamespaced
136// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
137// +k8s:prerelease-lifecycle-gen:introduced=1.10
138// +k8s:prerelease-lifecycle-gen:deprecated=1.22
139
140// PodSecurityPolicy governs the ability to make requests that affect the Security Context
141// that will be applied to a pod and container.
142type PodSecurityPolicy struct {
143 metav1.TypeMeta `json:",inline"`
144 // Standard object's metadata.
145 // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata
146 // +optional
147 metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
148
149 // spec defines the policy enforced.
150 // +optional
151 Spec PodSecurityPolicySpec `json:"spec,omitempty" protobuf:"bytes,2,opt,name=spec"`
152}
153
154// PodSecurityPolicySpec defines the policy enforced.
155type PodSecurityPolicySpec struct {
156 // privileged determines if a pod can request to be run as privileged.
157 // +optional
158 Privileged bool `json:"privileged,omitempty" protobuf:"varint,1,opt,name=privileged"`
159 // defaultAddCapabilities is the default set of capabilities that will be added to the container
160 // unless the pod spec specifically drops the capability. You may not list a capability in both
161 // defaultAddCapabilities and requiredDropCapabilities. Capabilities added here are implicitly
162 // allowed, and need not be included in the allowedCapabilities list.
163 // +optional
164 DefaultAddCapabilities []v1.Capability `json:"defaultAddCapabilities,omitempty" protobuf:"bytes,2,rep,name=defaultAddCapabilities,casttype=k8s.io/api/core/v1.Capability"`
165 // requiredDropCapabilities are the capabilities that will be dropped from the container. These
166 // are required to be dropped and cannot be added.
167 // +optional
168 RequiredDropCapabilities []v1.Capability `json:"requiredDropCapabilities,omitempty" protobuf:"bytes,3,rep,name=requiredDropCapabilities,casttype=k8s.io/api/core/v1.Capability"`
169 // allowedCapabilities is a list of capabilities that can be requested to add to the container.
170 // Capabilities in this field may be added at the pod author's discretion.
171 // You must not list a capability in both allowedCapabilities and requiredDropCapabilities.
172 // +optional
173 AllowedCapabilities []v1.Capability `json:"allowedCapabilities,omitempty" protobuf:"bytes,4,rep,name=allowedCapabilities,casttype=k8s.io/api/core/v1.Capability"`
174 // volumes is an allowlist of volume plugins. Empty indicates that
175 // no volumes may be used. To allow all volumes you may use '*'.
176 // +optional
177 Volumes []FSType `json:"volumes,omitempty" protobuf:"bytes,5,rep,name=volumes,casttype=FSType"`
178 // hostNetwork determines if the policy allows the use of HostNetwork in the pod spec.
179 // +optional
180 HostNetwork bool `json:"hostNetwork,omitempty" protobuf:"varint,6,opt,name=hostNetwork"`
181 // hostPorts determines which host port ranges are allowed to be exposed.
182 // +optional
183 HostPorts []HostPortRange `json:"hostPorts,omitempty" protobuf:"bytes,7,rep,name=hostPorts"`
184 // hostPID determines if the policy allows the use of HostPID in the pod spec.
185 // +optional
186 HostPID bool `json:"hostPID,omitempty" protobuf:"varint,8,opt,name=hostPID"`
187 // hostIPC determines if the policy allows the use of HostIPC in the pod spec.
188 // +optional
189 HostIPC bool `json:"hostIPC,omitempty" protobuf:"varint,9,opt,name=hostIPC"`
190 // seLinux is the strategy that will dictate the allowable labels that may be set.
191 SELinux SELinuxStrategyOptions `json:"seLinux" protobuf:"bytes,10,opt,name=seLinux"`
192 // runAsUser is the strategy that will dictate the allowable RunAsUser values that may be set.
193 RunAsUser RunAsUserStrategyOptions `json:"runAsUser" protobuf:"bytes,11,opt,name=runAsUser"`
194 // RunAsGroup is the strategy that will dictate the allowable RunAsGroup values that may be set.
195 // If this field is omitted, the pod's RunAsGroup can take any value. This field requires the
196 // RunAsGroup feature gate to be enabled.
197 // +optional
198 RunAsGroup *RunAsGroupStrategyOptions `json:"runAsGroup,omitempty" protobuf:"bytes,22,opt,name=runAsGroup"`
199 // supplementalGroups is the strategy that will dictate what supplemental groups are used by the SecurityContext.
200 SupplementalGroups SupplementalGroupsStrategyOptions `json:"supplementalGroups" protobuf:"bytes,12,opt,name=supplementalGroups"`
201 // fsGroup is the strategy that will dictate what fs group is used by the SecurityContext.
202 FSGroup FSGroupStrategyOptions `json:"fsGroup" protobuf:"bytes,13,opt,name=fsGroup"`
203 // readOnlyRootFilesystem when set to true will force containers to run with a read only root file
204 // system. If the container specifically requests to run with a non-read only root file system
205 // the PSP should deny the pod.
206 // If set to false the container may run with a read only root file system if it wishes but it
207 // will not be forced to.
208 // +optional
209 ReadOnlyRootFilesystem bool `json:"readOnlyRootFilesystem,omitempty" protobuf:"varint,14,opt,name=readOnlyRootFilesystem"`
210 // defaultAllowPrivilegeEscalation controls the default setting for whether a
211 // process can gain more privileges than its parent process.
212 // +optional
213 DefaultAllowPrivilegeEscalation *bool `json:"defaultAllowPrivilegeEscalation,omitempty" protobuf:"varint,15,opt,name=defaultAllowPrivilegeEscalation"`
214 // allowPrivilegeEscalation determines if a pod can request to allow
215 // privilege escalation. If unspecified, defaults to true.
216 // +optional
217 AllowPrivilegeEscalation *bool `json:"allowPrivilegeEscalation,omitempty" protobuf:"varint,16,opt,name=allowPrivilegeEscalation"`
218 // allowedHostPaths is an allowlist of host paths. Empty indicates
219 // that all host paths may be used.
220 // +optional
221 AllowedHostPaths []AllowedHostPath `json:"allowedHostPaths,omitempty" protobuf:"bytes,17,rep,name=allowedHostPaths"`
222 // allowedFlexVolumes is an allowlist of Flexvolumes. Empty or nil indicates that all
223 // Flexvolumes may be used. This parameter is effective only when the usage of the Flexvolumes
224 // is allowed in the "volumes" field.
225 // +optional
226 AllowedFlexVolumes []AllowedFlexVolume `json:"allowedFlexVolumes,omitempty" protobuf:"bytes,18,rep,name=allowedFlexVolumes"`
227 // AllowedCSIDrivers is an allowlist of inline CSI drivers that must be explicitly set to be embedded within a pod spec.
228 // An empty value indicates that any CSI driver can be used for inline ephemeral volumes.
229 // This is a beta field, and is only honored if the API server enables the CSIInlineVolume feature gate.
230 // +optional
231 AllowedCSIDrivers []AllowedCSIDriver `json:"allowedCSIDrivers,omitempty" protobuf:"bytes,23,rep,name=allowedCSIDrivers"`
232 // allowedUnsafeSysctls is a list of explicitly allowed unsafe sysctls, defaults to none.
233 // Each entry is either a plain sysctl name or ends in "*" in which case it is considered
234 // as a prefix of allowed sysctls. Single * means all unsafe sysctls are allowed.
235 // Kubelet has to allowlist all allowed unsafe sysctls explicitly to avoid rejection.
236 //
237 // Examples:
238 // e.g. "foo/*" allows "foo/bar", "foo/baz", etc.
239 // e.g. "foo.*" allows "foo.bar", "foo.baz", etc.
240 // +optional
241 AllowedUnsafeSysctls []string `json:"allowedUnsafeSysctls,omitempty" protobuf:"bytes,19,rep,name=allowedUnsafeSysctls"`
242 // forbiddenSysctls is a list of explicitly forbidden sysctls, defaults to none.
243 // Each entry is either a plain sysctl name or ends in "*" in which case it is considered
244 // as a prefix of forbidden sysctls. Single * means all sysctls are forbidden.
245 //
246 // Examples:
247 // e.g. "foo/*" forbids "foo/bar", "foo/baz", etc.
248 // e.g. "foo.*" forbids "foo.bar", "foo.baz", etc.
249 // +optional
250 ForbiddenSysctls []string `json:"forbiddenSysctls,omitempty" protobuf:"bytes,20,rep,name=forbiddenSysctls"`
251 // AllowedProcMountTypes is an allowlist of allowed ProcMountTypes.
252 // Empty or nil indicates that only the DefaultProcMountType may be used.
253 // This requires the ProcMountType feature flag to be enabled.
254 // +optional
255 AllowedProcMountTypes []v1.ProcMountType `json:"allowedProcMountTypes,omitempty" protobuf:"bytes,21,opt,name=allowedProcMountTypes"`
256 // runtimeClass is the strategy that will dictate the allowable RuntimeClasses for a pod.
257 // If this field is omitted, the pod's runtimeClassName field is unrestricted.
258 // Enforcement of this field depends on the RuntimeClass feature gate being enabled.
259 // +optional
260 RuntimeClass *RuntimeClassStrategyOptions `json:"runtimeClass,omitempty" protobuf:"bytes,24,opt,name=runtimeClass"`
261}
262
263// AllowedHostPath defines the host volume conditions that will be enabled by a policy
264// for pods to use. It requires the path prefix to be defined.
265type AllowedHostPath struct {
266 // pathPrefix is the path prefix that the host volume must match.
267 // It does not support `*`.
268 // Trailing slashes are trimmed when validating the path prefix with a host path.
269 //
270 // Examples:
271 // `/foo` would allow `/foo`, `/foo/` and `/foo/bar`
272 // `/foo` would not allow `/food` or `/etc/foo`
273 PathPrefix string `json:"pathPrefix,omitempty" protobuf:"bytes,1,rep,name=pathPrefix"`
274
275 // when set to true, will allow host volumes matching the pathPrefix only if all volume mounts are readOnly.
276 // +optional
277 ReadOnly bool `json:"readOnly,omitempty" protobuf:"varint,2,opt,name=readOnly"`
278}
279
280// AllowAllCapabilities can be used as a value for the PodSecurityPolicy.AllowAllCapabilities
281// field and means that any capabilities are allowed to be requested.
282var AllowAllCapabilities v1.Capability = "*"
283
284// FSType gives strong typing to different file systems that are used by volumes.
285type FSType string
286
287const (
288 AzureFile FSType = "azureFile"
289 Flocker FSType = "flocker"
290 FlexVolume FSType = "flexVolume"
291 HostPath FSType = "hostPath"
292 EmptyDir FSType = "emptyDir"
293 GCEPersistentDisk FSType = "gcePersistentDisk"
294 AWSElasticBlockStore FSType = "awsElasticBlockStore"
295 GitRepo FSType = "gitRepo"
296 Secret FSType = "secret"
297 NFS FSType = "nfs"
298 ISCSI FSType = "iscsi"
299 Glusterfs FSType = "glusterfs"
300 PersistentVolumeClaim FSType = "persistentVolumeClaim"
301 RBD FSType = "rbd"
302 Cinder FSType = "cinder"
303 CephFS FSType = "cephFS"
304 DownwardAPI FSType = "downwardAPI"
305 FC FSType = "fc"
306 ConfigMap FSType = "configMap"
307 VsphereVolume FSType = "vsphereVolume"
308 Quobyte FSType = "quobyte"
309 AzureDisk FSType = "azureDisk"
310 PhotonPersistentDisk FSType = "photonPersistentDisk"
311 StorageOS FSType = "storageos"
312 Projected FSType = "projected"
313 PortworxVolume FSType = "portworxVolume"
314 ScaleIO FSType = "scaleIO"
315 CSI FSType = "csi"
316 Ephemeral FSType = "ephemeral"
317 All FSType = "*"
318)
319
320// AllowedFlexVolume represents a single Flexvolume that is allowed to be used.
321type AllowedFlexVolume struct {
322 // driver is the name of the Flexvolume driver.
323 Driver string `json:"driver" protobuf:"bytes,1,opt,name=driver"`
324}
325
326// AllowedCSIDriver represents a single inline CSI Driver that is allowed to be used.
327type AllowedCSIDriver struct {
328 // Name is the registered name of the CSI driver
329 Name string `json:"name" protobuf:"bytes,1,opt,name=name"`
330}
331
332// HostPortRange defines a range of host ports that will be enabled by a policy
333// for pods to use. It requires both the start and end to be defined.
334type HostPortRange struct {
335 // min is the start of the range, inclusive.
336 Min int32 `json:"min" protobuf:"varint,1,opt,name=min"`
337 // max is the end of the range, inclusive.
338 Max int32 `json:"max" protobuf:"varint,2,opt,name=max"`
339}
340
341// SELinuxStrategyOptions defines the strategy type and any options used to create the strategy.
342type SELinuxStrategyOptions struct {
343 // rule is the strategy that will dictate the allowable labels that may be set.
344 Rule SELinuxStrategy `json:"rule" protobuf:"bytes,1,opt,name=rule,casttype=SELinuxStrategy"`
345 // seLinuxOptions required to run as; required for MustRunAs
346 // More info: https://kubernetes.io/docs/tasks/configure-pod-container/security-context/
347 // +optional
348 SELinuxOptions *v1.SELinuxOptions `json:"seLinuxOptions,omitempty" protobuf:"bytes,2,opt,name=seLinuxOptions"`
349}
350
351// SELinuxStrategy denotes strategy types for generating SELinux options for a
352// Security Context.
353type SELinuxStrategy string
354
355const (
356 // SELinuxStrategyMustRunAs means that container must have SELinux labels of X applied.
357 SELinuxStrategyMustRunAs SELinuxStrategy = "MustRunAs"
358 // SELinuxStrategyRunAsAny means that container may make requests for any SELinux context labels.
359 SELinuxStrategyRunAsAny SELinuxStrategy = "RunAsAny"
360)
361
362// RunAsUserStrategyOptions defines the strategy type and any options used to create the strategy.
363type RunAsUserStrategyOptions struct {
364 // rule is the strategy that will dictate the allowable RunAsUser values that may be set.
365 Rule RunAsUserStrategy `json:"rule" protobuf:"bytes,1,opt,name=rule,casttype=RunAsUserStrategy"`
366 // ranges are the allowed ranges of uids that may be used. If you would like to force a single uid
367 // then supply a single range with the same start and end. Required for MustRunAs.
368 // +optional
369 Ranges []IDRange `json:"ranges,omitempty" protobuf:"bytes,2,rep,name=ranges"`
370}
371
372// RunAsGroupStrategyOptions defines the strategy type and any options used to create the strategy.
373type RunAsGroupStrategyOptions struct {
374 // rule is the strategy that will dictate the allowable RunAsGroup values that may be set.
375 Rule RunAsGroupStrategy `json:"rule" protobuf:"bytes,1,opt,name=rule,casttype=RunAsGroupStrategy"`
376 // ranges are the allowed ranges of gids that may be used. If you would like to force a single gid
377 // then supply a single range with the same start and end. Required for MustRunAs.
378 // +optional
379 Ranges []IDRange `json:"ranges,omitempty" protobuf:"bytes,2,rep,name=ranges"`
380}
381
382// IDRange provides a min/max of an allowed range of IDs.
383type IDRange struct {
384 // min is the start of the range, inclusive.
385 Min int64 `json:"min" protobuf:"varint,1,opt,name=min"`
386 // max is the end of the range, inclusive.
387 Max int64 `json:"max" protobuf:"varint,2,opt,name=max"`
388}
389
390// RunAsUserStrategy denotes strategy types for generating RunAsUser values for a
391// Security Context.
392type RunAsUserStrategy string
393
394const (
395 // RunAsUserStrategyMustRunAs means that container must run as a particular uid.
396 RunAsUserStrategyMustRunAs RunAsUserStrategy = "MustRunAs"
397 // RunAsUserStrategyMustRunAsNonRoot means that container must run as a non-root uid.
398 RunAsUserStrategyMustRunAsNonRoot RunAsUserStrategy = "MustRunAsNonRoot"
399 // RunAsUserStrategyRunAsAny means that container may make requests for any uid.
400 RunAsUserStrategyRunAsAny RunAsUserStrategy = "RunAsAny"
401)
402
403// RunAsGroupStrategy denotes strategy types for generating RunAsGroup values for a
404// Security Context.
405type RunAsGroupStrategy string
406
407const (
408 // RunAsGroupStrategyMayRunAs means that container does not need to run with a particular gid.
409 // However, when RunAsGroup are specified, they have to fall in the defined range.
410 RunAsGroupStrategyMayRunAs RunAsGroupStrategy = "MayRunAs"
411 // RunAsGroupStrategyMustRunAs means that container must run as a particular gid.
412 RunAsGroupStrategyMustRunAs RunAsGroupStrategy = "MustRunAs"
413 // RunAsUserStrategyRunAsAny means that container may make requests for any gid.
414 RunAsGroupStrategyRunAsAny RunAsGroupStrategy = "RunAsAny"
415)
416
417// FSGroupStrategyOptions defines the strategy type and options used to create the strategy.
418type FSGroupStrategyOptions struct {
419 // rule is the strategy that will dictate what FSGroup is used in the SecurityContext.
420 // +optional
421 Rule FSGroupStrategyType `json:"rule,omitempty" protobuf:"bytes,1,opt,name=rule,casttype=FSGroupStrategyType"`
422 // ranges are the allowed ranges of fs groups. If you would like to force a single
423 // fs group then supply a single range with the same start and end. Required for MustRunAs.
424 // +optional
425 Ranges []IDRange `json:"ranges,omitempty" protobuf:"bytes,2,rep,name=ranges"`
426}
427
428// FSGroupStrategyType denotes strategy types for generating FSGroup values for a
429// SecurityContext
430type FSGroupStrategyType string
431
432const (
433 // FSGroupStrategyMayRunAs means that container does not need to have FSGroup of X applied.
434 // However, when FSGroups are specified, they have to fall in the defined range.
435 FSGroupStrategyMayRunAs FSGroupStrategyType = "MayRunAs"
436 // FSGroupStrategyMustRunAs meant that container must have FSGroup of X applied.
437 FSGroupStrategyMustRunAs FSGroupStrategyType = "MustRunAs"
438 // FSGroupStrategyRunAsAny means that container may make requests for any FSGroup labels.
439 FSGroupStrategyRunAsAny FSGroupStrategyType = "RunAsAny"
440)
441
442// SupplementalGroupsStrategyOptions defines the strategy type and options used to create the strategy.
443type SupplementalGroupsStrategyOptions struct {
444 // rule is the strategy that will dictate what supplemental groups is used in the SecurityContext.
445 // +optional
446 Rule SupplementalGroupsStrategyType `json:"rule,omitempty" protobuf:"bytes,1,opt,name=rule,casttype=SupplementalGroupsStrategyType"`
447 // ranges are the allowed ranges of supplemental groups. If you would like to force a single
448 // supplemental group then supply a single range with the same start and end. Required for MustRunAs.
449 // +optional
450 Ranges []IDRange `json:"ranges,omitempty" protobuf:"bytes,2,rep,name=ranges"`
451}
452
453// SupplementalGroupsStrategyType denotes strategy types for determining valid supplemental
454// groups for a SecurityContext.
455type SupplementalGroupsStrategyType string
456
457const (
458 // SupplementalGroupsStrategyMayRunAs means that container does not need to run with a particular gid.
459 // However, when gids are specified, they have to fall in the defined range.
460 SupplementalGroupsStrategyMayRunAs SupplementalGroupsStrategyType = "MayRunAs"
461 // SupplementalGroupsStrategyMustRunAs means that container must run as a particular gid.
462 SupplementalGroupsStrategyMustRunAs SupplementalGroupsStrategyType = "MustRunAs"
463 // SupplementalGroupsStrategyRunAsAny means that container may make requests for any gid.
464 SupplementalGroupsStrategyRunAsAny SupplementalGroupsStrategyType = "RunAsAny"
465)
466
467// RuntimeClassStrategyOptions define the strategy that will dictate the allowable RuntimeClasses
468// for a pod.
469type RuntimeClassStrategyOptions struct {
470 // allowedRuntimeClassNames is an allowlist of RuntimeClass names that may be specified on a pod.
471 // A value of "*" means that any RuntimeClass name is allowed, and must be the only item in the
472 // list. An empty list requires the RuntimeClassName field to be unset.
473 AllowedRuntimeClassNames []string `json:"allowedRuntimeClassNames" protobuf:"bytes,1,rep,name=allowedRuntimeClassNames"`
474 // defaultRuntimeClassName is the default RuntimeClassName to set on the pod.
475 // The default MUST be allowed by the allowedRuntimeClassNames list.
476 // A value of nil does not mutate the Pod.
477 // +optional
478 DefaultRuntimeClassName *string `json:"defaultRuntimeClassName,omitempty" protobuf:"bytes,2,opt,name=defaultRuntimeClassName"`
479}
480
481// AllowAllRuntimeClassNames can be used as a value for the
482// RuntimeClassStrategyOptions.AllowedRuntimeClassNames field and means that any RuntimeClassName is
483// allowed.
484const AllowAllRuntimeClassNames = "*"
485
486// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
487// +k8s:prerelease-lifecycle-gen:introduced=1.10
488// +k8s:prerelease-lifecycle-gen:deprecated=1.22
489
490// PodSecurityPolicyList is a list of PodSecurityPolicy objects.
491type PodSecurityPolicyList struct {
492 metav1.TypeMeta `json:",inline"`
493 // Standard list metadata.
494 // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata
495 // +optional
496 metav1.ListMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
497
498 // items is a list of schema objects.
499 Items []PodSecurityPolicy `json:"items" protobuf:"bytes,2,rep,name=items"`
500}