-
Notifications
You must be signed in to change notification settings - Fork 99
/
KubernetesApplication.java
302 lines (259 loc) · 7.58 KB
/
KubernetesApplication.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
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
/**
* Copyright 2018 The original authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.dekorate.kubernetes.annotation;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import io.dekorate.kubernetes.config.BaseConfig;
import io.dekorate.kubernetes.config.DeploymentStrategy;
import io.dekorate.project.BuildInfo;
import io.dekorate.project.Project;
import io.fabric8.kubernetes.api.model.Service;
import io.sundr.builder.annotations.Adapter;
import io.sundr.builder.annotations.Buildable;
import io.sundr.builder.annotations.BuildableReference;
import io.sundr.builder.annotations.Pojo;
@Buildable(builderPackage = "io.fabric8.kubernetes.api.builder", refs = {
@BuildableReference(Project.class),
@BuildableReference(BuildInfo.class)
})
@Pojo(name = "KubernetesConfig", relativePath = "../config", autobox = true, mutable = true, superClass = BaseConfig.class, withStaticBuilderMethod = true, withStaticAdapterMethod = false, adapter = @Adapter(suffix = "Adapter", relativePath = "../adapter", withMapAdapterMethod = true))
@Target({ ElementType.CONSTRUCTOR, ElementType.TYPE })
@Retention(RetentionPolicy.RUNTIME)
public @interface KubernetesApplication {
/**
* The name of the collection of component this component belongs to.
* This value will be use as:
* - docker image repo
* - labeling resources
*
* @return The specified group name.
*/
String partOf() default "";
/**
* The name of the application. This value will be used for naming Kubernetes
* resources like: - Deployment - Service and so on ... If no value is specified
* it will attempt to determine the name using the following rules: If its a
* maven/gradle project use the artifact id. Else if its a bazel project use the
* name. Else if the system property app.name is present it will be used. Else
* find the project root folder and use its name (root folder detection is done
* by moving to the parent folder until .git is found).
*
* @return The specified application name.
*/
String name() default "";
/**
* The version of the application. This value be used for things like: - The
* docker image tag. If no value specified it will attempt to determine the name
* using the following rules:
*
* @return The version.
*/
String version() default "";
/**
* The kind of the deployment resource to use.
* Supported values are 'Deployment', 'StatefulSet', 'Job' and 'CronJob' defaulting to the first.
*
* @return The deployment kind resource.
*/
String deploymentKind() default "Deployment";
/**
* The init containers.
*
* @return the init containers.
*/
Container[] initContainers() default {};
/**
* Custom labels to add to all resources.
*
* @return The labels.
*/
Label[] labels() default {};
/**
* Custom annotations to add to all resources.
*
* @return The annotations.
*/
Annotation[] annotations() default {};
/**
* Environment variables to add to all containers.
*
* @return The environment variables.
*/
Env[] envVars() default {};
/**
* Working directory.
*
* @return The working directory if specified, else empty string.
*/
String workingDir() default "";
/**
* The commands
*
* @return The commands.
*/
String[] command() default {};
/**
* The arguments
*
* @return The arguments.
*/
String[] arguments() default {};
/**
* The number of replicas to use.
*
* @return The number of replicas.
*/
int replicas() default 1;
/**
* Specifies the deployment strategy.
*/
DeploymentStrategy deploymentStrategy() default DeploymentStrategy.None;
/**
* Specifies rolling update configuration.
* The configuration is applied when DeploymentStrategy == RollingUpdate, or
* when explicit configuration has been provided. In the later case RollingUpdate is assumed.
*/
RollingUpdate rollingUpdate() default @RollingUpdate;
/**
* The service account.
*
* @return The service account or empty string if not specified.
*/
String serviceAccount() default "";
/**
* The application ports.
*/
Port[] ports() default {};
/**
* The type of service that will be generated for the application.
*/
ServiceType serviceType() default ServiceType.ClusterIP;
/**
* PersistentVolumeClaim volumes to add to all containers.
*/
PersistentVolumeClaimVolume[] pvcVolumes() default {};
/**
* Secret volumes to add to all containers.
*/
SecretVolume[] secretVolumes() default {};
/**
* The ConfigMap volumes to add to all containers.
*/
ConfigMapVolume[] configMapVolumes() default {};
/**
* The EmptyDir volumes to add to all containers.
*/
EmptyDirVolume[] emptyDirVolumes() default {};
/**
* Git repo volumes to add to all containers.
*/
GitRepoVolume[] gitRepoVolumes() default {};
/**
* Aws elastic block store volumes to add to all containers
*/
AwsElasticBlockStoreVolume[] awsElasticBlockStoreVolumes() default {};
/**
* Azure disk volumes to add
*/
AzureDiskVolume[] azureDiskVolumes() default {};
/**
* Azure file volumes to add
*/
AzureFileVolume[] azureFileVolumes() default {};
/**
* Mounts to add to all containers.
*
* @return The mounts.
*/
Mount[] mounts() default {};
/**
* Image pull policy.
*
* @return The image pull policy.
*/
ImagePullPolicy imagePullPolicy() default ImagePullPolicy.IfNotPresent;
/**
* The image pull secret
*/
String[] imagePullSecrets() default {};
/**
* The hostAliases
*/
HostAlias[] hostAliases() default {};
/**
* The liveness probe.
*
* @return The probe.
*/
Probe livenessProbe() default @Probe();
/**
* The readiness probe.
*
* @return The probe.
*/
Probe readinessProbe() default @Probe();
/**
* The startup probe.
*
* @return The probe.
*/
Probe startupProbe() default @Probe();
/**
* The resources that the application container requires.
*/
ResourceRequirements requestResources() default @ResourceRequirements();
/**
* The resource limit for the application container.
*/
ResourceRequirements limitResources() default @ResourceRequirements();
/**
* The sidecars.
*
* @return the sidecar containers.
*/
Container[] sidecars() default {};
/**
* @return the Ingress resource configuration.
*/
Ingress ingress() default @Ingress();
/**
* Controls whether the generated {@link Service} will be headless.
*
* @return true if headless.
*/
boolean headless() default false;
/**
* Flag to trigger the registration of the deploy hook. It's generally
* preferable to use `-Ddekorate.deploy=true` instead of hardcoding this here.
*
* @return True for automatic registration of the build hook.
*/
boolean autoDeployEnabled() default false;
/**
* The Kubernetes Jobs.
*
* @return the jobs;
*/
Job[] jobs() default {};
/**
* The Kubernetes CronJobs.
*
* @return the cronJobs;
*/
CronJob[] cronJobs() default {};
}