-
Notifications
You must be signed in to change notification settings - Fork 1.2k
/
PodTemplate.java
194 lines (166 loc) · 7.74 KB
/
PodTemplate.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
/*
* Copyright Strimzi authors.
* License: Apache License 2.0 (see the file LICENSE or http://apache.org/licenses/LICENSE-2.0.html).
*/
package io.strimzi.api.kafka.model.template;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import io.fabric8.kubernetes.api.model.Affinity;
import io.fabric8.kubernetes.api.model.HostAlias;
import io.fabric8.kubernetes.api.model.LocalObjectReference;
import io.fabric8.kubernetes.api.model.PodSecurityContext;
import io.fabric8.kubernetes.api.model.Toleration;
import io.fabric8.kubernetes.api.model.TopologySpreadConstraint;
import io.strimzi.api.kafka.model.Constants;
import io.strimzi.api.kafka.model.UnknownPropertyPreserving;
import io.strimzi.crdgenerator.annotations.Description;
import io.strimzi.crdgenerator.annotations.DescriptionFile;
import io.strimzi.crdgenerator.annotations.KubeLink;
import io.strimzi.crdgenerator.annotations.Minimum;
import io.sundr.builder.annotations.Buildable;
import io.vertx.core.cli.annotations.DefaultValue;
import lombok.EqualsAndHashCode;
import java.io.Serializable;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* Representation of a pod template for Strimzi resources.
*/
@Buildable(
editableEnabled = false,
builderPackage = Constants.FABRIC8_KUBERNETES_API
)
@JsonInclude(JsonInclude.Include.NON_DEFAULT)
@JsonPropertyOrder({"metadata", "imagePullSecrets", "securityContext", "terminationGracePeriodSeconds", "affinity",
"tolerations", "topologySpreadConstraint", "priorityClassName", "schedulerName", "hostAliases"})
@EqualsAndHashCode
@DescriptionFile
public class PodTemplate implements Serializable, UnknownPropertyPreserving {
private static final long serialVersionUID = 1L;
private MetadataTemplate metadata;
private List<LocalObjectReference> imagePullSecrets;
private PodSecurityContext securityContext;
private int terminationGracePeriodSeconds = 30;
private Affinity affinity;
private List<Toleration> tolerations;
private List<TopologySpreadConstraint> topologySpreadConstraints;
private String priorityClassName;
private String schedulerName;
private List<HostAlias> hostAliases;
private Boolean enableServiceLinks;
private Map<String, Object> additionalProperties = new HashMap<>(0);
@Description("Metadata applied to the resource.")
@JsonInclude(JsonInclude.Include.NON_EMPTY)
public MetadataTemplate getMetadata() {
return metadata;
}
public void setMetadata(MetadataTemplate metadata) {
this.metadata = metadata;
}
@Description("Configures pod-level security attributes and common container settings.")
@KubeLink(group = "core", version = "v1", kind = "podsecuritycontext")
@JsonInclude(JsonInclude.Include.NON_EMPTY)
public PodSecurityContext getSecurityContext() {
return securityContext;
}
public void setSecurityContext(PodSecurityContext securityContext) {
this.securityContext = securityContext;
}
@Description("List of references to secrets in the same namespace to use for pulling any of the images used by this Pod. " +
"When the `STRIMZI_IMAGE_PULL_SECRETS` environment variable in Cluster Operator and the `imagePullSecrets` option are specified, only the `imagePullSecrets` variable is used and the `STRIMZI_IMAGE_PULL_SECRETS` variable is ignored.")
@KubeLink(group = "core", version = "v1", kind = "localobjectreference")
@JsonInclude(JsonInclude.Include.NON_EMPTY)
public List<LocalObjectReference> getImagePullSecrets() {
return imagePullSecrets;
}
public void setImagePullSecrets(List<LocalObjectReference> imagePullSecrets) {
this.imagePullSecrets = imagePullSecrets;
}
@Description("The grace period is the duration in seconds after the processes running in the pod are sent a termination signal, and the time when the processes are forcibly halted with a kill signal. " +
"Set this value to longer than the expected cleanup time for your process. " +
"Value must be a non-negative integer. " +
"A zero value indicates delete immediately. " +
"You might need to increase the grace period for very large Kafka clusters, so that the Kafka brokers have enough time to transfer their work to another broker before they are terminated. " +
"Defaults to 30 seconds.")
@JsonInclude(JsonInclude.Include.NON_DEFAULT)
@DefaultValue("30")
@Minimum(0)
public int getTerminationGracePeriodSeconds() {
return terminationGracePeriodSeconds;
}
public void setTerminationGracePeriodSeconds(int terminationGracePeriodSeconds) {
this.terminationGracePeriodSeconds = terminationGracePeriodSeconds;
}
@Description("The pod's affinity rules.")
@KubeLink(group = "core", version = "v1", kind = "affinity")
@JsonInclude(JsonInclude.Include.NON_NULL)
public Affinity getAffinity() {
return affinity;
}
public void setAffinity(Affinity affinity) {
this.affinity = affinity;
}
@Description("The pod's tolerations.")
@KubeLink(group = "core", version = "v1", kind = "toleration")
@JsonInclude(JsonInclude.Include.NON_EMPTY)
public List<Toleration> getTolerations() {
return tolerations;
}
public void setTolerations(List<Toleration> tolerations) {
this.tolerations = tolerations;
}
@Description("The pod's topology spread constraints.")
@KubeLink(group = "core", version = "v1", kind = "topologyspreadconstraint")
@JsonInclude(JsonInclude.Include.NON_EMPTY)
public List<TopologySpreadConstraint> getTopologySpreadConstraints() {
return topologySpreadConstraints;
}
public void setTopologySpreadConstraints(List<TopologySpreadConstraint> topologySpreadConstraints) {
this.topologySpreadConstraints = topologySpreadConstraints;
}
@Description("The name of the priority class used to assign priority to the pods. " +
"For more information about priority classes, see {K8sPriorityClass}.")
@JsonInclude(JsonInclude.Include.NON_EMPTY)
public String getPriorityClassName() {
return priorityClassName;
}
public void setPriorityClassName(String priorityClassName) {
this.priorityClassName = priorityClassName;
}
@Description("The name of the scheduler used to dispatch this `Pod`. " +
"If not specified, the default scheduler will be used.")
@JsonInclude(JsonInclude.Include.NON_EMPTY)
public String getSchedulerName() {
return schedulerName;
}
public void setSchedulerName(String schedulerName) {
this.schedulerName = schedulerName;
}
@Description("The pod's HostAliases. " +
"HostAliases is an optional list of hosts and IPs that will be injected into the Pod's hosts file if specified.")
@KubeLink(group = "core", version = "v1", kind = "HostAlias")
@JsonInclude(JsonInclude.Include.NON_EMPTY)
public List<HostAlias> getHostAliases() {
return hostAliases;
}
public void setHostAliases(List<HostAlias> hostAliases) {
this.hostAliases = hostAliases;
}
@Description("Indicates whether information about services should be injected into Pod's environment variables.")
@JsonInclude(JsonInclude.Include.NON_DEFAULT)
public Boolean getEnableServiceLinks() {
return enableServiceLinks;
}
public void setEnableServiceLinks(Boolean enableServiceLinks) {
this.enableServiceLinks = enableServiceLinks;
}
@Override
public Map<String, Object> getAdditionalProperties() {
return this.additionalProperties;
}
@Override
public void setAdditionalProperty(String name, Object value) {
this.additionalProperties.put(name, value);
}
}