1/*
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
17/*
18This file (together with pkg/apis/extensions/v1beta1/types.go) contain the experimental
19types in kubernetes. These API objects are experimental, meaning that the
20APIs may be broken at any time by the kubernetes team.
21
22DISCLAIMER: The implementation of the experimental API group itself is
23a temporary one meant as a stopgap solution until kubernetes has proper
24support for multiple API groups. The transition may require changes
25beyond registration differences. In other words, experimental API group
26support is experimental.
27*/
28
29package extensions
30
31import (
32	"k8s.io/apimachinery/pkg/api/resource"
33	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
34	"k8s.io/apimachinery/pkg/util/intstr"
35	"k8s.io/client-go/pkg/api"
36)
37
38const (
39	// SysctlsPodSecurityPolicyAnnotationKey represents the key of a whitelist of
40	// allowed safe and unsafe sysctls in a pod spec. It's a comma-separated list of plain sysctl
41	// names or sysctl patterns (which end in *). The string "*" matches all sysctls.
42	SysctlsPodSecurityPolicyAnnotationKey string = "security.alpha.kubernetes.io/sysctls"
43)
44
45// describes the attributes of a scale subresource
46type ScaleSpec struct {
47	// desired number of instances for the scaled object.
48	// +optional
49	Replicas int32
50}
51
52// represents the current status of a scale subresource.
53type ScaleStatus struct {
54	// actual number of observed instances of the scaled object.
55	Replicas int32
56
57	// label query over pods that should match the replicas count.
58	// More info: http://kubernetes.io/docs/user-guide/labels#label-selectors
59	// +optional
60	Selector *metav1.LabelSelector
61}
62
63// +genclient=true
64// +noMethods=true
65
66// represents a scaling request for a resource.
67type Scale struct {
68	metav1.TypeMeta
69	// Standard object metadata; More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata.
70	// +optional
71	metav1.ObjectMeta
72
73	// defines the behavior of the scale. More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#spec-and-status.
74	// +optional
75	Spec ScaleSpec
76
77	// current status of the scale. More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#spec-and-status. Read-only.
78	// +optional
79	Status ScaleStatus
80}
81
82// Dummy definition
83type ReplicationControllerDummy struct {
84	metav1.TypeMeta
85}
86
87// Alpha-level support for Custom Metrics in HPA (as annotations).
88type CustomMetricTarget struct {
89	// Custom Metric name.
90	Name string
91	// Custom Metric value (average).
92	TargetValue resource.Quantity
93}
94
95type CustomMetricTargetList struct {
96	Items []CustomMetricTarget
97}
98
99type CustomMetricCurrentStatus struct {
100	// Custom Metric name.
101	Name string
102	// Custom Metric value (average).
103	CurrentValue resource.Quantity
104}
105
106type CustomMetricCurrentStatusList struct {
107	Items []CustomMetricCurrentStatus
108}
109
110// +genclient=true
111// +nonNamespaced=true
112
113// A ThirdPartyResource is a generic representation of a resource, it is used by add-ons and plugins to add new resource
114// types to the API.  It consists of one or more Versions of the api.
115type ThirdPartyResource struct {
116	metav1.TypeMeta
117
118	// Standard object metadata
119	// +optional
120	metav1.ObjectMeta
121
122	// Description is the description of this object.
123	// +optional
124	Description string
125
126	// Versions are versions for this third party object
127	Versions []APIVersion
128}
129
130type ThirdPartyResourceList struct {
131	metav1.TypeMeta
132
133	// Standard list metadata.
134	// +optional
135	metav1.ListMeta
136
137	// Items is the list of horizontal pod autoscalers.
138	Items []ThirdPartyResource
139}
140
141// An APIVersion represents a single concrete version of an object model.
142// TODO: we should consider merge this struct with GroupVersion in metav1.go
143type APIVersion struct {
144	// Name of this version (e.g. 'v1').
145	Name string
146}
147
148// An internal object, used for versioned storage in etcd.  Not exposed to the end user.
149type ThirdPartyResourceData struct {
150	metav1.TypeMeta
151	// Standard object metadata.
152	// +optional
153	metav1.ObjectMeta
154
155	// Data is the raw JSON data for this data.
156	// +optional
157	Data []byte
158}
159
160// +genclient=true
161
162type Deployment struct {
163	metav1.TypeMeta
164	// +optional
165	metav1.ObjectMeta
166
167	// Specification of the desired behavior of the Deployment.
168	// +optional
169	Spec DeploymentSpec
170
171	// Most recently observed status of the Deployment.
172	// +optional
173	Status DeploymentStatus
174}
175
176type DeploymentSpec struct {
177	// Number of desired pods. This is a pointer to distinguish between explicit
178	// zero and not specified. Defaults to 1.
179	// +optional
180	Replicas int32
181
182	// Label selector for pods. Existing ReplicaSets whose pods are
183	// selected by this will be the ones affected by this deployment.
184	// +optional
185	Selector *metav1.LabelSelector
186
187	// Template describes the pods that will be created.
188	Template api.PodTemplateSpec
189
190	// The deployment strategy to use to replace existing pods with new ones.
191	// +optional
192	Strategy DeploymentStrategy
193
194	// Minimum number of seconds for which a newly created pod should be ready
195	// without any of its container crashing, for it to be considered available.
196	// Defaults to 0 (pod will be considered available as soon as it is ready)
197	// +optional
198	MinReadySeconds int32
199
200	// The number of old ReplicaSets to retain to allow rollback.
201	// This is a pointer to distinguish between explicit zero and not specified.
202	// +optional
203	RevisionHistoryLimit *int32
204
205	// Indicates that the deployment is paused and will not be processed by the
206	// deployment controller.
207	// +optional
208	Paused bool
209
210	// The config this deployment is rolling back to. Will be cleared after rollback is done.
211	// +optional
212	RollbackTo *RollbackConfig
213
214	// The maximum time in seconds for a deployment to make progress before it
215	// is considered to be failed. The deployment controller will continue to
216	// process failed deployments and a condition with a ProgressDeadlineExceeded
217	// reason will be surfaced in the deployment status. Once autoRollback is
218	// implemented, the deployment controller will automatically rollback failed
219	// deployments. Note that progress will not be estimated during the time a
220	// deployment is paused. This is not set by default.
221	ProgressDeadlineSeconds *int32
222}
223
224// DeploymentRollback stores the information required to rollback a deployment.
225type DeploymentRollback struct {
226	metav1.TypeMeta
227	// Required: This must match the Name of a deployment.
228	Name string
229	// The annotations to be updated to a deployment
230	// +optional
231	UpdatedAnnotations map[string]string
232	// The config of this deployment rollback.
233	RollbackTo RollbackConfig
234}
235
236type RollbackConfig struct {
237	// The revision to rollback to. If set to 0, rollbck to the last revision.
238	// +optional
239	Revision int64
240}
241
242const (
243	// DefaultDeploymentUniqueLabelKey is the default key of the selector that is added
244	// to existing RCs (and label key that is added to its pods) to prevent the existing RCs
245	// to select new pods (and old pods being select by new RC).
246	DefaultDeploymentUniqueLabelKey string = "pod-template-hash"
247)
248
249type DeploymentStrategy struct {
250	// Type of deployment. Can be "Recreate" or "RollingUpdate". Default is RollingUpdate.
251	// +optional
252	Type DeploymentStrategyType
253
254	// Rolling update config params. Present only if DeploymentStrategyType =
255	// RollingUpdate.
256	//---
257	// TODO: Update this to follow our convention for oneOf, whatever we decide it
258	// to be.
259	// +optional
260	RollingUpdate *RollingUpdateDeployment
261}
262
263type DeploymentStrategyType string
264
265const (
266	// Kill all existing pods before creating new ones.
267	RecreateDeploymentStrategyType DeploymentStrategyType = "Recreate"
268
269	// Replace the old RCs by new one using rolling update i.e gradually scale down the old RCs and scale up the new one.
270	RollingUpdateDeploymentStrategyType DeploymentStrategyType = "RollingUpdate"
271)
272
273// Spec to control the desired behavior of rolling update.
274type RollingUpdateDeployment struct {
275	// The maximum number of pods that can be unavailable during the update.
276	// Value can be an absolute number (ex: 5) or a percentage of total pods at the start of update (ex: 10%).
277	// Absolute number is calculated from percentage by rounding down.
278	// This can not be 0 if MaxSurge is 0.
279	// By default, a fixed value of 1 is used.
280	// Example: when this is set to 30%, the old RC can be scaled down by 30%
281	// immediately when the rolling update starts. Once new pods are ready, old RC
282	// can be scaled down further, followed by scaling up the new RC, ensuring
283	// that at least 70% of original number of pods are available at all times
284	// during the update.
285	// +optional
286	MaxUnavailable intstr.IntOrString
287
288	// The maximum number of pods that can be scheduled above the original number of
289	// pods.
290	// Value can be an absolute number (ex: 5) or a percentage of total pods at
291	// the start of the update (ex: 10%). This can not be 0 if MaxUnavailable is 0.
292	// Absolute number is calculated from percentage by rounding up.
293	// By default, a value of 1 is used.
294	// Example: when this is set to 30%, the new RC can be scaled up by 30%
295	// immediately when the rolling update starts. Once old pods have been killed,
296	// new RC can be scaled up further, ensuring that total number of pods running
297	// at any time during the update is atmost 130% of original pods.
298	// +optional
299	MaxSurge intstr.IntOrString
300}
301
302type DeploymentStatus struct {
303	// The generation observed by the deployment controller.
304	// +optional
305	ObservedGeneration int64
306
307	// Total number of non-terminated pods targeted by this deployment (their labels match the selector).
308	// +optional
309	Replicas int32
310
311	// Total number of non-terminated pods targeted by this deployment that have the desired template spec.
312	// +optional
313	UpdatedReplicas int32
314
315	// Total number of ready pods targeted by this deployment.
316	// +optional
317	ReadyReplicas int32
318
319	// Total number of available pods (ready for at least minReadySeconds) targeted by this deployment.
320	// +optional
321	AvailableReplicas int32
322
323	// Total number of unavailable pods targeted by this deployment.
324	// +optional
325	UnavailableReplicas int32
326
327	// Represents the latest available observations of a deployment's current state.
328	Conditions []DeploymentCondition
329}
330
331type DeploymentConditionType string
332
333// These are valid conditions of a deployment.
334const (
335	// Available means the deployment is available, ie. at least the minimum available
336	// replicas required are up and running for at least minReadySeconds.
337	DeploymentAvailable DeploymentConditionType = "Available"
338	// Progressing means the deployment is progressing. Progress for a deployment is
339	// considered when a new replica set is created or adopted, and when new pods scale
340	// up or old pods scale down. Progress is not estimated for paused deployments or
341	// when progressDeadlineSeconds is not specified.
342	DeploymentProgressing DeploymentConditionType = "Progressing"
343	// ReplicaFailure is added in a deployment when one of its pods fails to be created
344	// or deleted.
345	DeploymentReplicaFailure DeploymentConditionType = "ReplicaFailure"
346)
347
348// DeploymentCondition describes the state of a deployment at a certain point.
349type DeploymentCondition struct {
350	// Type of deployment condition.
351	Type DeploymentConditionType
352	// Status of the condition, one of True, False, Unknown.
353	Status api.ConditionStatus
354	// The last time this condition was updated.
355	LastUpdateTime metav1.Time
356	// Last time the condition transitioned from one status to another.
357	LastTransitionTime metav1.Time
358	// The reason for the condition's last transition.
359	Reason string
360	// A human readable message indicating details about the transition.
361	Message string
362}
363
364type DeploymentList struct {
365	metav1.TypeMeta
366	// +optional
367	metav1.ListMeta
368
369	// Items is the list of deployments.
370	Items []Deployment
371}
372
373type DaemonSetUpdateStrategy struct {
374	// Type of daemon set update. Can be "RollingUpdate" or "OnDelete".
375	// Default is OnDelete.
376	// +optional
377	Type DaemonSetUpdateStrategyType
378
379	// Rolling update config params. Present only if type = "RollingUpdate".
380	//---
381	// TODO: Update this to follow our convention for oneOf, whatever we decide it
382	// to be. Same as DeploymentStrategy.RollingUpdate.
383	// See https://github.com/kubernetes/kubernetes/issues/35345
384	// +optional
385	RollingUpdate *RollingUpdateDaemonSet
386}
387
388type DaemonSetUpdateStrategyType string
389
390const (
391	// Replace the old daemons by new ones using rolling update i.e replace them on each node one after the other.
392	RollingUpdateDaemonSetStrategyType DaemonSetUpdateStrategyType = "RollingUpdate"
393
394	// Replace the old daemons only when it's killed
395	OnDeleteDaemonSetStrategyType DaemonSetUpdateStrategyType = "OnDelete"
396)
397
398// Spec to control the desired behavior of daemon set rolling update.
399type RollingUpdateDaemonSet struct {
400	// The maximum number of DaemonSet pods that can be unavailable during the
401	// update. Value can be an absolute number (ex: 5) or a percentage of total
402	// number of DaemonSet pods at the start of the update (ex: 10%). Absolute
403	// number is calculated from percentage by rounding up.
404	// This cannot be 0.
405	// Default value is 1.
406	// Example: when this is set to 30%, at most 30% of the total number of nodes
407	// that should be running the daemon pod (i.e. status.desiredNumberScheduled)
408	// can have their pods stopped for an update at any given
409	// time. The update starts by stopping at most 30% of those DaemonSet pods
410	// and then brings up new DaemonSet pods in their place. Once the new pods
411	// are available, it then proceeds onto other DaemonSet pods, thus ensuring
412	// that at least 70% of original number of DaemonSet pods are available at
413	// all times during the update.
414	// +optional
415	MaxUnavailable intstr.IntOrString
416}
417
418// DaemonSetSpec is the specification of a daemon set.
419type DaemonSetSpec struct {
420	// A label query over pods that are managed by the daemon set.
421	// Must match in order to be controlled.
422	// If empty, defaulted to labels on Pod template.
423	// More info: http://kubernetes.io/docs/user-guide/labels#label-selectors
424	// +optional
425	Selector *metav1.LabelSelector
426
427	// An object that describes the pod that will be created.
428	// The DaemonSet will create exactly one copy of this pod on every node
429	// that matches the template's node selector (or on every node if no node
430	// selector is specified).
431	// More info: http://kubernetes.io/docs/user-guide/replication-controller#pod-template
432	Template api.PodTemplateSpec
433
434	// An update strategy to replace existing DaemonSet pods with new pods.
435	// +optional
436	UpdateStrategy DaemonSetUpdateStrategy
437
438	// The minimum number of seconds for which a newly created DaemonSet pod should
439	// be ready without any of its container crashing, for it to be considered
440	// available. Defaults to 0 (pod will be considered available as soon as it
441	// is ready).
442	// +optional
443	MinReadySeconds int32
444
445	// A sequence number representing a specific generation of the template.
446	// Populated by the system. It can be set only during the creation.
447	// +optional
448	TemplateGeneration int64
449}
450
451// DaemonSetStatus represents the current status of a daemon set.
452type DaemonSetStatus struct {
453	// The number of nodes that are running at least 1
454	// daemon pod and are supposed to run the daemon pod.
455	CurrentNumberScheduled int32
456
457	// The number of nodes that are running the daemon pod, but are
458	// not supposed to run the daemon pod.
459	NumberMisscheduled int32
460
461	// The total number of nodes that should be running the daemon
462	// pod (including nodes correctly running the daemon pod).
463	DesiredNumberScheduled int32
464
465	// The number of nodes that should be running the daemon pod and have one
466	// or more of the daemon pod running and ready.
467	NumberReady int32
468
469	// The most recent generation observed by the daemon set controller.
470	// +optional
471	ObservedGeneration int64
472
473	// The total number of nodes that are running updated daemon pod
474	// +optional
475	UpdatedNumberScheduled int32
476
477	// The number of nodes that should be running the
478	// daemon pod and have one or more of the daemon pod running and
479	// available (ready for at least spec.minReadySeconds)
480	// +optional
481	NumberAvailable int32
482
483	// The number of nodes that should be running the
484	// daemon pod and have none of the daemon pod running and available
485	// (ready for at least spec.minReadySeconds)
486	// +optional
487	NumberUnavailable int32
488}
489
490// +genclient=true
491
492// DaemonSet represents the configuration of a daemon set.
493type DaemonSet struct {
494	metav1.TypeMeta
495	// Standard object's metadata.
496	// More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata
497	// +optional
498	metav1.ObjectMeta
499
500	// The desired behavior of this daemon set.
501	// More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#spec-and-status
502	// +optional
503	Spec DaemonSetSpec
504
505	// The current status of this daemon set. This data may be
506	// out of date by some window of time.
507	// Populated by the system.
508	// Read-only.
509	// More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#spec-and-status
510	// +optional
511	Status DaemonSetStatus
512}
513
514const (
515	// DaemonSetTemplateGenerationKey is the key of the labels that is added
516	// to daemon set pods to distinguish between old and new pod templates
517	// during DaemonSet template update.
518	DaemonSetTemplateGenerationKey string = "pod-template-generation"
519)
520
521// DaemonSetList is a collection of daemon sets.
522type DaemonSetList struct {
523	metav1.TypeMeta
524	// Standard list metadata.
525	// More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata
526	// +optional
527	metav1.ListMeta
528
529	// A list of daemon sets.
530	Items []DaemonSet
531}
532
533type ThirdPartyResourceDataList struct {
534	metav1.TypeMeta
535	// Standard list metadata
536	// More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata
537	// +optional
538	metav1.ListMeta
539	// Items is a list of third party objects
540	Items []ThirdPartyResourceData
541}
542
543// +genclient=true
544
545// Ingress is a collection of rules that allow inbound connections to reach the
546// endpoints defined by a backend. An Ingress can be configured to give services
547// externally-reachable urls, load balance traffic, terminate SSL, offer name
548// based virtual hosting etc.
549type Ingress struct {
550	metav1.TypeMeta
551	// Standard object's metadata.
552	// More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata
553	// +optional
554	metav1.ObjectMeta
555
556	// Spec is the desired state of the Ingress.
557	// More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#spec-and-status
558	// +optional
559	Spec IngressSpec
560
561	// Status is the current state of the Ingress.
562	// More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#spec-and-status
563	// +optional
564	Status IngressStatus
565}
566
567// IngressList is a collection of Ingress.
568type IngressList struct {
569	metav1.TypeMeta
570	// Standard object's metadata.
571	// More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata
572	// +optional
573	metav1.ListMeta
574
575	// Items is the list of Ingress.
576	Items []Ingress
577}
578
579// IngressSpec describes the Ingress the user wishes to exist.
580type IngressSpec struct {
581	// A default backend capable of servicing requests that don't match any
582	// rule. At least one of 'backend' or 'rules' must be specified. This field
583	// is optional to allow the loadbalancer controller or defaulting logic to
584	// specify a global default.
585	// +optional
586	Backend *IngressBackend
587
588	// TLS configuration. Currently the Ingress only supports a single TLS
589	// port, 443. If multiple members of this list specify different hosts, they
590	// will be multiplexed on the same port according to the hostname specified
591	// through the SNI TLS extension, if the ingress controller fulfilling the
592	// ingress supports SNI.
593	// +optional
594	TLS []IngressTLS
595
596	// A list of host rules used to configure the Ingress. If unspecified, or
597	// no rule matches, all traffic is sent to the default backend.
598	// +optional
599	Rules []IngressRule
600	// TODO: Add the ability to specify load-balancer IP through claims
601}
602
603// IngressTLS describes the transport layer security associated with an Ingress.
604type IngressTLS struct {
605	// Hosts are a list of hosts included in the TLS certificate. The values in
606	// this list must match the name/s used in the tlsSecret. Defaults to the
607	// wildcard host setting for the loadbalancer controller fulfilling this
608	// Ingress, if left unspecified.
609	// +optional
610	Hosts []string
611	// SecretName is the name of the secret used to terminate SSL traffic on 443.
612	// Field is left optional to allow SSL routing based on SNI hostname alone.
613	// If the SNI host in a listener conflicts with the "Host" header field used
614	// by an IngressRule, the SNI host is used for termination and value of the
615	// Host header is used for routing.
616	// +optional
617	SecretName string
618	// TODO: Consider specifying different modes of termination, protocols etc.
619}
620
621// IngressStatus describe the current state of the Ingress.
622type IngressStatus struct {
623	// LoadBalancer contains the current status of the load-balancer.
624	// +optional
625	LoadBalancer api.LoadBalancerStatus
626}
627
628// IngressRule represents the rules mapping the paths under a specified host to
629// the related backend services. Incoming requests are first evaluated for a host
630// match, then routed to the backend associated with the matching IngressRuleValue.
631type IngressRule struct {
632	// Host is the fully qualified domain name of a network host, as defined
633	// by RFC 3986. Note the following deviations from the "host" part of the
634	// URI as defined in the RFC:
635	// 1. IPs are not allowed. Currently an IngressRuleValue can only apply to the
636	//	  IP in the Spec of the parent Ingress.
637	// 2. The `:` delimiter is not respected because ports are not allowed.
638	//	  Currently the port of an Ingress is implicitly :80 for http and
639	//	  :443 for https.
640	// Both these may change in the future.
641	// Incoming requests are matched against the host before the IngressRuleValue.
642	// If the host is unspecified, the Ingress routes all traffic based on the
643	// specified IngressRuleValue.
644	// +optional
645	Host string
646	// IngressRuleValue represents a rule to route requests for this IngressRule.
647	// If unspecified, the rule defaults to a http catch-all. Whether that sends
648	// just traffic matching the host to the default backend or all traffic to the
649	// default backend, is left to the controller fulfilling the Ingress. Http is
650	// currently the only supported IngressRuleValue.
651	// +optional
652	IngressRuleValue
653}
654
655// IngressRuleValue represents a rule to apply against incoming requests. If the
656// rule is satisfied, the request is routed to the specified backend. Currently
657// mixing different types of rules in a single Ingress is disallowed, so exactly
658// one of the following must be set.
659type IngressRuleValue struct {
660	//TODO:
661	// 1. Consider renaming this resource and the associated rules so they
662	// aren't tied to Ingress. They can be used to route intra-cluster traffic.
663	// 2. Consider adding fields for ingress-type specific global options
664	// usable by a loadbalancer, like http keep-alive.
665
666	// +optional
667	HTTP *HTTPIngressRuleValue
668}
669
670// HTTPIngressRuleValue is a list of http selectors pointing to backends.
671// In the example: http://<host>/<path>?<searchpart> -> backend where
672// where parts of the url correspond to RFC 3986, this resource will be used
673// to match against everything after the last '/' and before the first '?'
674// or '#'.
675type HTTPIngressRuleValue struct {
676	// A collection of paths that map requests to backends.
677	Paths []HTTPIngressPath
678	// TODO: Consider adding fields for ingress-type specific global
679	// options usable by a loadbalancer, like http keep-alive.
680}
681
682// HTTPIngressPath associates a path regex with a backend. Incoming urls matching
683// the path are forwarded to the backend.
684type HTTPIngressPath struct {
685	// Path is an extended POSIX regex as defined by IEEE Std 1003.1,
686	// (i.e this follows the egrep/unix syntax, not the perl syntax)
687	// matched against the path of an incoming request. Currently it can
688	// contain characters disallowed from the conventional "path"
689	// part of a URL as defined by RFC 3986. Paths must begin with
690	// a '/'. If unspecified, the path defaults to a catch all sending
691	// traffic to the backend.
692	// +optional
693	Path string
694
695	// Backend defines the referenced service endpoint to which the traffic
696	// will be forwarded to.
697	Backend IngressBackend
698}
699
700// IngressBackend describes all endpoints for a given service and port.
701type IngressBackend struct {
702	// Specifies the name of the referenced service.
703	ServiceName string
704
705	// Specifies the port of the referenced service.
706	ServicePort intstr.IntOrString
707}
708
709// +genclient=true
710
711// ReplicaSet represents the configuration of a replica set.
712type ReplicaSet struct {
713	metav1.TypeMeta
714	// +optional
715	metav1.ObjectMeta
716
717	// Spec defines the desired behavior of this ReplicaSet.
718	// +optional
719	Spec ReplicaSetSpec
720
721	// Status is the current status of this ReplicaSet. This data may be
722	// out of date by some window of time.
723	// +optional
724	Status ReplicaSetStatus
725}
726
727// ReplicaSetList is a collection of ReplicaSets.
728type ReplicaSetList struct {
729	metav1.TypeMeta
730	// +optional
731	metav1.ListMeta
732
733	Items []ReplicaSet
734}
735
736// ReplicaSetSpec is the specification of a ReplicaSet.
737// As the internal representation of a ReplicaSet, it must have
738// a Template set.
739type ReplicaSetSpec struct {
740	// Replicas is the number of desired replicas.
741	Replicas int32
742
743	// Minimum number of seconds for which a newly created pod should be ready
744	// without any of its container crashing, for it to be considered available.
745	// Defaults to 0 (pod will be considered available as soon as it is ready)
746	// +optional
747	MinReadySeconds int32
748
749	// Selector is a label query over pods that should match the replica count.
750	// Must match in order to be controlled.
751	// If empty, defaulted to labels on pod template.
752	// More info: http://kubernetes.io/docs/user-guide/labels#label-selectors
753	// +optional
754	Selector *metav1.LabelSelector
755
756	// Template is the object that describes the pod that will be created if
757	// insufficient replicas are detected.
758	// +optional
759	Template api.PodTemplateSpec
760}
761
762// ReplicaSetStatus represents the current status of a ReplicaSet.
763type ReplicaSetStatus struct {
764	// Replicas is the number of actual replicas.
765	Replicas int32
766
767	// The number of pods that have labels matching the labels of the pod template of the replicaset.
768	// +optional
769	FullyLabeledReplicas int32
770
771	// The number of ready replicas for this replica set.
772	// +optional
773	ReadyReplicas int32
774
775	// The number of available replicas (ready for at least minReadySeconds) for this replica set.
776	// +optional
777	AvailableReplicas int32
778
779	// ObservedGeneration is the most recent generation observed by the controller.
780	// +optional
781	ObservedGeneration int64
782
783	// Represents the latest available observations of a replica set's current state.
784	// +optional
785	Conditions []ReplicaSetCondition
786}
787
788type ReplicaSetConditionType string
789
790// These are valid conditions of a replica set.
791const (
792	// ReplicaSetReplicaFailure is added in a replica set when one of its pods fails to be created
793	// due to insufficient quota, limit ranges, pod security policy, node selectors, etc. or deleted
794	// due to kubelet being down or finalizers are failing.
795	ReplicaSetReplicaFailure ReplicaSetConditionType = "ReplicaFailure"
796)
797
798// ReplicaSetCondition describes the state of a replica set at a certain point.
799type ReplicaSetCondition struct {
800	// Type of replica set condition.
801	Type ReplicaSetConditionType
802	// Status of the condition, one of True, False, Unknown.
803	Status api.ConditionStatus
804	// The last time the condition transitioned from one status to another.
805	// +optional
806	LastTransitionTime metav1.Time
807	// The reason for the condition's last transition.
808	// +optional
809	Reason string
810	// A human readable message indicating details about the transition.
811	// +optional
812	Message string
813}
814
815// +genclient=true
816// +nonNamespaced=true
817
818// PodSecurityPolicy governs the ability to make requests that affect the SecurityContext
819// that will be applied to a pod and container.
820type PodSecurityPolicy struct {
821	metav1.TypeMeta
822	// +optional
823	metav1.ObjectMeta
824
825	// Spec defines the policy enforced.
826	// +optional
827	Spec PodSecurityPolicySpec
828}
829
830// PodSecurityPolicySpec defines the policy enforced.
831type PodSecurityPolicySpec struct {
832	// Privileged determines if a pod can request to be run as privileged.
833	// +optional
834	Privileged bool
835	// DefaultAddCapabilities is the default set of capabilities that will be added to the container
836	// unless the pod spec specifically drops the capability.  You may not list a capability in both
837	// DefaultAddCapabilities and RequiredDropCapabilities.
838	// +optional
839	DefaultAddCapabilities []api.Capability
840	// RequiredDropCapabilities are the capabilities that will be dropped from the container.  These
841	// are required to be dropped and cannot be added.
842	// +optional
843	RequiredDropCapabilities []api.Capability
844	// AllowedCapabilities is a list of capabilities that can be requested to add to the container.
845	// Capabilities in this field may be added at the pod author's discretion.
846	// You must not list a capability in both AllowedCapabilities and RequiredDropCapabilities.
847	// +optional
848	AllowedCapabilities []api.Capability
849	// Volumes is a white list of allowed volume plugins.  Empty indicates that all plugins
850	// may be used.
851	// +optional
852	Volumes []FSType
853	// HostNetwork determines if the policy allows the use of HostNetwork in the pod spec.
854	// +optional
855	HostNetwork bool
856	// HostPorts determines which host port ranges are allowed to be exposed.
857	// +optional
858	HostPorts []HostPortRange
859	// HostPID determines if the policy allows the use of HostPID in the pod spec.
860	// +optional
861	HostPID bool
862	// HostIPC determines if the policy allows the use of HostIPC in the pod spec.
863	// +optional
864	HostIPC bool
865	// SELinux is the strategy that will dictate the allowable labels that may be set.
866	SELinux SELinuxStrategyOptions
867	// RunAsUser is the strategy that will dictate the allowable RunAsUser values that may be set.
868	RunAsUser RunAsUserStrategyOptions
869	// SupplementalGroups is the strategy that will dictate what supplemental groups are used by the SecurityContext.
870	SupplementalGroups SupplementalGroupsStrategyOptions
871	// FSGroup is the strategy that will dictate what fs group is used by the SecurityContext.
872	FSGroup FSGroupStrategyOptions
873	// ReadOnlyRootFilesystem when set to true will force containers to run with a read only root file
874	// system.  If the container specifically requests to run with a non-read only root file system
875	// the PSP should deny the pod.
876	// If set to false the container may run with a read only root file system if it wishes but it
877	// will not be forced to.
878	// +optional
879	ReadOnlyRootFilesystem bool
880}
881
882// HostPortRange defines a range of host ports that will be enabled by a policy
883// for pods to use.  It requires both the start and end to be defined.
884type HostPortRange struct {
885	// Min is the start of the range, inclusive.
886	Min int
887	// Max is the end of the range, inclusive.
888	Max int
889}
890
891// FSType gives strong typing to different file systems that are used by volumes.
892type FSType string
893
894var (
895	AzureFile             FSType = "azureFile"
896	Flocker               FSType = "flocker"
897	FlexVolume            FSType = "flexVolume"
898	HostPath              FSType = "hostPath"
899	EmptyDir              FSType = "emptyDir"
900	GCEPersistentDisk     FSType = "gcePersistentDisk"
901	AWSElasticBlockStore  FSType = "awsElasticBlockStore"
902	GitRepo               FSType = "gitRepo"
903	Secret                FSType = "secret"
904	NFS                   FSType = "nfs"
905	ISCSI                 FSType = "iscsi"
906	Glusterfs             FSType = "glusterfs"
907	PersistentVolumeClaim FSType = "persistentVolumeClaim"
908	RBD                   FSType = "rbd"
909	Cinder                FSType = "cinder"
910	CephFS                FSType = "cephFS"
911	DownwardAPI           FSType = "downwardAPI"
912	FC                    FSType = "fc"
913	ConfigMap             FSType = "configMap"
914	VsphereVolume         FSType = "vsphereVolume"
915	Quobyte               FSType = "quobyte"
916	AzureDisk             FSType = "azureDisk"
917	PhotonPersistentDisk  FSType = "photonPersistentDisk"
918	Projected             FSType = "projected"
919	PortworxVolume        FSType = "portworxVolume"
920	ScaleIO               FSType = "scaleIO"
921	All                   FSType = "*"
922)
923
924// SELinuxStrategyOptions defines the strategy type and any options used to create the strategy.
925type SELinuxStrategyOptions struct {
926	// Rule is the strategy that will dictate the allowable labels that may be set.
927	Rule SELinuxStrategy
928	// seLinuxOptions required to run as; required for MustRunAs
929	// More info: http://releases.k8s.io/HEAD/docs/design/security_context.md#security-context
930	// +optional
931	SELinuxOptions *api.SELinuxOptions
932}
933
934// SELinuxStrategy denotes strategy types for generating SELinux options for a
935// Security.
936type SELinuxStrategy string
937
938const (
939	// container must have SELinux labels of X applied.
940	SELinuxStrategyMustRunAs SELinuxStrategy = "MustRunAs"
941	// container may make requests for any SELinux context labels.
942	SELinuxStrategyRunAsAny SELinuxStrategy = "RunAsAny"
943)
944
945// RunAsUserStrategyOptions defines the strategy type and any options used to create the strategy.
946type RunAsUserStrategyOptions struct {
947	// Rule is the strategy that will dictate the allowable RunAsUser values that may be set.
948	Rule RunAsUserStrategy
949	// Ranges are the allowed ranges of uids that may be used.
950	// +optional
951	Ranges []IDRange
952}
953
954// IDRange provides a min/max of an allowed range of IDs.
955type IDRange struct {
956	// Min is the start of the range, inclusive.
957	Min int64
958	// Max is the end of the range, inclusive.
959	Max int64
960}
961
962// RunAsUserStrategy denotes strategy types for generating RunAsUser values for a
963// SecurityContext.
964type RunAsUserStrategy string
965
966const (
967	// container must run as a particular uid.
968	RunAsUserStrategyMustRunAs RunAsUserStrategy = "MustRunAs"
969	// container must run as a non-root uid
970	RunAsUserStrategyMustRunAsNonRoot RunAsUserStrategy = "MustRunAsNonRoot"
971	// container may make requests for any uid.
972	RunAsUserStrategyRunAsAny RunAsUserStrategy = "RunAsAny"
973)
974
975// FSGroupStrategyOptions defines the strategy type and options used to create the strategy.
976type FSGroupStrategyOptions struct {
977	// Rule is the strategy that will dictate what FSGroup is used in the SecurityContext.
978	// +optional
979	Rule FSGroupStrategyType
980	// Ranges are the allowed ranges of fs groups.  If you would like to force a single
981	// fs group then supply a single range with the same start and end.
982	// +optional
983	Ranges []IDRange
984}
985
986// FSGroupStrategyType denotes strategy types for generating FSGroup values for a
987// SecurityContext
988type FSGroupStrategyType string
989
990const (
991	// container must have FSGroup of X applied.
992	FSGroupStrategyMustRunAs FSGroupStrategyType = "MustRunAs"
993	// container may make requests for any FSGroup labels.
994	FSGroupStrategyRunAsAny FSGroupStrategyType = "RunAsAny"
995)
996
997// SupplementalGroupsStrategyOptions defines the strategy type and options used to create the strategy.
998type SupplementalGroupsStrategyOptions struct {
999	// Rule is the strategy that will dictate what supplemental groups is used in the SecurityContext.
1000	// +optional
1001	Rule SupplementalGroupsStrategyType
1002	// Ranges are the allowed ranges of supplemental groups.  If you would like to force a single
1003	// supplemental group then supply a single range with the same start and end.
1004	// +optional
1005	Ranges []IDRange
1006}
1007
1008// SupplementalGroupsStrategyType denotes strategy types for determining valid supplemental
1009// groups for a SecurityContext.
1010type SupplementalGroupsStrategyType string
1011
1012const (
1013	// container must run as a particular gid.
1014	SupplementalGroupsStrategyMustRunAs SupplementalGroupsStrategyType = "MustRunAs"
1015	// container may make requests for any gid.
1016	SupplementalGroupsStrategyRunAsAny SupplementalGroupsStrategyType = "RunAsAny"
1017)
1018
1019// PodSecurityPolicyList is a list of PodSecurityPolicy objects.
1020type PodSecurityPolicyList struct {
1021	metav1.TypeMeta
1022	// +optional
1023	metav1.ListMeta
1024
1025	Items []PodSecurityPolicy
1026}
1027
1028// +genclient=true
1029
1030type NetworkPolicy struct {
1031	metav1.TypeMeta
1032	// +optional
1033	metav1.ObjectMeta
1034
1035	// Specification of the desired behavior for this NetworkPolicy.
1036	// +optional
1037	Spec NetworkPolicySpec
1038}
1039
1040type NetworkPolicySpec struct {
1041	// Selects the pods to which this NetworkPolicy object applies.  The array of ingress rules
1042	// is applied to any pods selected by this field. Multiple network policies can select the
1043	// same set of pods.  In this case, the ingress rules for each are combined additively.
1044	// This field is NOT optional and follows standard label selector semantics.
1045	// An empty podSelector matches all pods in this namespace.
1046	PodSelector metav1.LabelSelector
1047
1048	// List of ingress rules to be applied to the selected pods.
1049	// Traffic is allowed to a pod if namespace.networkPolicy.ingress.isolation is undefined and cluster policy allows it,
1050	// OR if the traffic source is the pod's local node,
1051	// OR if the traffic matches at least one ingress rule across all of the NetworkPolicy
1052	// objects whose podSelector matches the pod.
1053	// If this field is empty then this NetworkPolicy does not affect ingress isolation.
1054	// If this field is present and contains at least one rule, this policy allows any traffic
1055	// which matches at least one of the ingress rules in this list.
1056	// +optional
1057	Ingress []NetworkPolicyIngressRule
1058}
1059
1060// This NetworkPolicyIngressRule matches traffic if and only if the traffic matches both ports AND from.
1061type NetworkPolicyIngressRule struct {
1062	// List of ports which should be made accessible on the pods selected for this rule.
1063	// Each item in this list is combined using a logical OR.
1064	// If this field is not provided, this rule matches all ports (traffic not restricted by port).
1065	// If this field is empty, this rule matches no ports (no traffic matches).
1066	// If this field is present and contains at least one item, then this rule allows traffic
1067	// only if the traffic matches at least one port in the list.
1068	// TODO: Update this to be a pointer to slice as soon as auto-generation supports it.
1069	// +optional
1070	Ports []NetworkPolicyPort
1071
1072	// List of sources which should be able to access the pods selected for this rule.
1073	// Items in this list are combined using a logical OR operation.
1074	// If this field is not provided, this rule matches all sources (traffic not restricted by source).
1075	// If this field is empty, this rule matches no sources (no traffic matches).
1076	// If this field is present and contains at least on item, this rule allows traffic only if the
1077	// traffic matches at least one item in the from list.
1078	// TODO: Update this to be a pointer to slice as soon as auto-generation supports it.
1079	// +optional
1080	From []NetworkPolicyPeer
1081}
1082
1083type NetworkPolicyPort struct {
1084	// Optional.  The protocol (TCP or UDP) which traffic must match.
1085	// If not specified, this field defaults to TCP.
1086	// +optional
1087	Protocol *api.Protocol
1088
1089	// If specified, the port on the given protocol.  This can
1090	// either be a numerical or named port on a pod.  If this field is not provided,
1091	// this matches all port names and numbers.
1092	// If present, only traffic on the specified protocol AND port
1093	// will be matched.
1094	// +optional
1095	Port *intstr.IntOrString
1096}
1097
1098type NetworkPolicyPeer struct {
1099	// Exactly one of the following must be specified.
1100
1101	// This is a label selector which selects Pods in this namespace.
1102	// This field follows standard label selector semantics.
1103	// If not provided, this selector selects no pods.
1104	// If present but empty, this selector selects all pods in this namespace.
1105	// +optional
1106	PodSelector *metav1.LabelSelector
1107
1108	// Selects Namespaces using cluster scoped-labels.  This
1109	// matches all pods in all namespaces selected by this label selector.
1110	// This field follows standard label selector semantics.
1111	// If omitted, this selector selects no namespaces.
1112	// If present but empty, this selector selects all namespaces.
1113	// +optional
1114	NamespaceSelector *metav1.LabelSelector
1115}
1116
1117// NetworkPolicyList is a list of NetworkPolicy objects.
1118type NetworkPolicyList struct {
1119	metav1.TypeMeta
1120	// +optional
1121	metav1.ListMeta
1122
1123	Items []NetworkPolicy
1124}
1125