Skip to content

Commit 9e882c7

Browse files
committed
Init container support
1 parent dc2fe9d commit 9e882c7

File tree

20 files changed

+565
-11
lines changed

20 files changed

+565
-11
lines changed

docs/domains/Domain.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -457,6 +457,13 @@
457457
"$ref": "https://github.com/garethr/kubernetes-json-schema/blob/master/v1.9.0/_definitions.json#/definitions/io.k8s.api.core.v1.EnvVar"
458458
}
459459
},
460+
"initContainers": {
461+
"description": "Initialization containers",
462+
"type": "array",
463+
"items": {
464+
"$ref": "https://github.com/garethr/kubernetes-json-schema/blob/master/v1.9.0/_definitions.json#/definitions/io.k8s.api.core.v1.Container"
465+
}
466+
},
460467
"nodeSelector": {
461468
"description": "Selector which must match a node\u0027s labels for the pod to be scheduled on that node.",
462469
"$ref": "#/definitions/Map"

docs/domains/Domain.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ ServerPod describes the configuration for a Kubernetes pod for a server.
102102
| annotations | Map | The annotations to be attached to generated resources. |
103103
| containerSecurityContext | [Security Context](k8s1.9.0.md#security-context) | Container-level security attributes. Will override any matching pod-level attributes. |
104104
| env | array of [Env Var](k8s1.9.0.md#env-var) | A list of environment variables to add to a server |
105+
| initContainers | array of [Container](k8s1.9.0.md#container) | Initialization containers |
105106
| labels | Map | The labels to be attached to generated resources. The label names must not start with 'weblogic.'. |
106107
| livenessProbe | [Probe Tuning](#probe-tuning) | Settings for the liveness probe associated with a server. |
107108
| nodeSelector | Map | Selector which must match a node's labels for the pod to be scheduled on that node. |

docs/domains/index.html

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" style="position:absolute;width:0;height:0">
3535
<defs>
3636
<symbol viewBox="0 0 20 20" id="unlocked">
37-
<path d="M15.8 8H14V5.6C14 2.703 12.665 1 10 1 7.334 1 6 2.703 6 5.6V6h2v-.801C8 3.754 8.797 3 10 3c1.203 0 2 .754 2 2.199V8H4c-.553 0-1 .646-1 1.199V17c0 .549.428 1.139.951 1.307l1.197.387C5.672 18.861 6.55 19 7.1 19h5.8c.549 0 1.428-.139 1.951-.307l1.196-.387c.524-.167.953-.757.953-1.306V9.199C17 8.646 16.352 8 15.8 8z"></path>
37+
<path d="M15.8 8H14V5.6C14 2.703 12.665 1 10 1 7.334 1 6 2.703 6 5.6V6h2v-.801C8 3.754 8.797 3 10 3c1.203 0 2 .754 2 2.199V8H4c-.553 0-1 .646-1 1.199V17c0 .549.428 1.139.951 1.307l1.197.387C5.672 18.861 6.55 19 7.1 19h5.8c.549 0 1.428-.139 1.951-.307l1.196-.387c.524-.167.953-.757.953-1.306V9.199C17 8.646 16.352 8 15.8 8z"></path>
3838
</symbol>
3939

4040
<symbol viewBox="0 0 20 20" id="locked">
@@ -1377,6 +1377,13 @@
13771377
"$ref": "https://github.com/garethr/kubernetes-json-schema/blob/master/v1.9.0/_definitions.json#/definitions/io.k8s.api.core.v1.EnvVar"
13781378
}
13791379
},
1380+
"initContainers": {
1381+
"description": "Initialization containers",
1382+
"type": "array",
1383+
"items": {
1384+
"$ref": "https://github.com/garethr/kubernetes-json-schema/blob/master/v1.9.0/_definitions.json#/definitions/io.k8s.api.core.v1.Container"
1385+
}
1386+
},
13801387
"nodeSelector": {
13811388
"description": "Selector which must match a node\u0027s labels for the pod to be scheduled on that node.",
13821389
"$ref": "#/definitions/Map"
@@ -1474,4 +1481,4 @@
14741481
</script>
14751482
</body>
14761483

1477-
</html>
1484+
</html>

docs/domains/k8s1.9.0.md

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,34 @@ EnvVar represents an environment variable present in a Container.
6767
| value | string | Variable references $(VAR_NAME) are expanded using the previous defined environment variables in the container and any service environment variables. If a variable cannot be resolved, the reference in the input string will be unchanged. The $(VAR_NAME) syntax can be escaped with a double $$, ie: $$(VAR_NAME). Escaped references will never be expanded, regardless of whether the variable exists or not. Defaults to "". |
6868
| valueFrom | [Env Var Source](#env-var-source) | Source for the environment variable's value. Cannot be used if value is not empty. |
6969

70+
### Container
71+
72+
A single application container that you want to run within a pod.
73+
74+
| Name | Type | Description |
75+
| --- | --- | --- |
76+
| args | array of string | Arguments to the entrypoint. The docker image's CMD is used if this is not provided. Variable references $(VAR_NAME) are expanded using the container's environment. If a variable cannot be resolved, the reference in the input string will be unchanged. The $(VAR_NAME) syntax can be escaped with a double $$, ie: $$(VAR_NAME). Escaped references will never be expanded, regardless of whether the variable exists or not. Cannot be updated. More info: https://kubernetes.io/docs/tasks/inject-data-application/define-command-argument-container/#running-a-command-in-a-shell |
77+
| command | array of string | Entrypoint array. Not executed within a shell. The docker image's ENTRYPOINT is used if this is not provided. Variable references $(VAR_NAME) are expanded using the container's environment. If a variable cannot be resolved, the reference in the input string will be unchanged. The $(VAR_NAME) syntax can be escaped with a double $$, ie: $$(VAR_NAME). Escaped references will never be expanded, regardless of whether the variable exists or not. Cannot be updated. More info: https://kubernetes.io/docs/tasks/inject-data-application/define-command-argument-container/#running-a-command-in-a-shell |
78+
| env | array of [Env Var](#env-var) | List of environment variables to set in the container. Cannot be updated. |
79+
| envFrom | array of [Env From Source](#env-from-source) | List of sources to populate environment variables in the container. The keys defined within a source must be a C_IDENTIFIER. All invalid keys will be reported as an event when the container is starting. When a key exists in multiple sources, the value associated with the last source will take precedence. Values defined by an Env with a duplicate key will take precedence. Cannot be updated. |
80+
| image | string | Docker image name. More info: https://kubernetes.io/docs/concepts/containers/images This field is optional to allow higher level config management to default or override container images in workload controllers like Deployments and StatefulSets. |
81+
| imagePullPolicy | string | Image pull policy. One of Always, Never, IfNotPresent. Defaults to Always if :latest tag is specified, or IfNotPresent otherwise. Cannot be updated. More info: https://kubernetes.io/docs/concepts/containers/images#updating-images |
82+
| lifecycle | [Lifecycle](#lifecycle) | Actions that the management system should take in response to container lifecycle events. Cannot be updated. |
83+
| livenessProbe | [Probe](#probe) | Periodic probe of container liveness. Container will be restarted if the probe fails. Cannot be updated. More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes |
84+
| name | string | Name of the container specified as a DNS_LABEL. Each container in a pod must have a unique name (DNS_LABEL). Cannot be updated. |
85+
| ports | array of [Container Port](#container-port) | List of ports to expose from the container. Exposing a port here gives the system additional information about the network connections a container uses, but is primarily informational. Not specifying a port here DOES NOT prevent that port from being exposed. Any port which is listening on the default "0.0.0.0" address inside a container will be accessible from the network. Cannot be updated. |
86+
| readinessProbe | [Probe](#probe) | Periodic probe of container service readiness. Container will be removed from service endpoints if the probe fails. Cannot be updated. More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes |
87+
| resources | [Resource Requirements](#resource-requirements) | Compute Resources required by this container. Cannot be updated. More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes#resources |
88+
| securityContext | [Security Context](#security-context) | Security options the pod should run with. More info: https://kubernetes.io/docs/concepts/policy/security-context/ More info: https://kubernetes.io/docs/tasks/configure-pod-container/security-context/ |
89+
| stdin | boolean | Whether this container should allocate a buffer for stdin in the container runtime. If this is not set, reads from stdin in the container will always result in EOF. Default is false. |
90+
| stdinOnce | boolean | Whether the container runtime should close the stdin channel after it has been opened by a single attach. When stdin is true the stdin stream will remain open across multiple attach sessions. If stdinOnce is set to true, stdin is opened on container start, is empty until the first client attaches to stdin, and then remains open and accepts data until the client disconnects, at which time stdin is closed and remains closed until the container is restarted. If this flag is false, a container processes that reads from stdin will never receive an EOF. Default is false |
91+
| terminationMessagePath | string | Optional: Path at which the file to which the container's termination message will be written is mounted into the container's filesystem. Message written is intended to be brief final status, such as an assertion failure message. Will be truncated by the node if greater than 4096 bytes. The total message length across all containers will be limited to 12kb. Defaults to /dev/termination-log. Cannot be updated. |
92+
| terminationMessagePolicy | string | Indicate how the termination message should be populated. File will use the contents of terminationMessagePath to populate the container status message on both success and failure. FallbackToLogsOnError will use the last chunk of container log output if the termination message file is empty and the container exited with an error. The log output is limited to 2048 bytes or 80 lines, whichever is smaller. Defaults to File. Cannot be updated. |
93+
| tty | boolean | Whether this container should allocate a TTY for itself, also requires 'stdin' to be true. Default is false. |
94+
| volumeDevices | array of [Volume Device](#volume-device) | volumeDevices is the list of block devices to be used by the container. This is an alpha feature and may change in the future. |
95+
| volumeMounts | array of [Volume Mount](#volume-mount) | Pod volumes to mount into the container's filesystem. Cannot be updated. |
96+
| workingDir | string | Container's working directory. If not specified, the container runtime's default will be used, which might be configured in the container image. Cannot be updated. |
97+
7098
### Pod Security Context
7199

72100
PodSecurityContext holds pod-level security attributes and common container settings. Some fields are also present in container.securityContext. Field values of container.securityContext take precedence over field values of PodSecurityContext.
@@ -165,6 +193,51 @@ Volume represents a named volume in a pod that may be accessed by any container
165193
| Name | Type | Description |
166194
| --- | --- | --- |
167195

196+
### Env Var
197+
198+
| Name | Type | Description |
199+
| --- | --- | --- |
200+
201+
### Env From Source
202+
203+
| Name | Type | Description |
204+
| --- | --- | --- |
205+
206+
### Lifecycle
207+
208+
| Name | Type | Description |
209+
| --- | --- | --- |
210+
211+
### Probe
212+
213+
| Name | Type | Description |
214+
| --- | --- | --- |
215+
216+
### Container Port
217+
218+
| Name | Type | Description |
219+
| --- | --- | --- |
220+
221+
### Resource Requirements
222+
223+
| Name | Type | Description |
224+
| --- | --- | --- |
225+
226+
### Security Context
227+
228+
| Name | Type | Description |
229+
| --- | --- | --- |
230+
231+
### Volume Device
232+
233+
| Name | Type | Description |
234+
| --- | --- | --- |
235+
236+
### Volume Mount
237+
238+
| Name | Type | Description |
239+
| --- | --- | --- |
240+
168241
### AWS Elastic Block Store Volume Source
169242

170243
| Name | Type | Description |

model/src/main/java/oracle/kubernetes/weblogic/domain/ClusterConfigurator.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
// Copyright 2018, Oracle Corporation and/or its affiliates. All rights reserved.
1+
// Copyright 2018, 2019, Oracle Corporation and/or its affiliates. All rights reserved.
22
// Licensed under the Universal Permissive License v 1.0 as shown at
33
// http://oss.oracle.com/licenses/upl.
44

55
package oracle.kubernetes.weblogic.domain;
66

7+
import io.kubernetes.client.models.V1Container;
78
import io.kubernetes.client.models.V1PodSecurityContext;
89
import io.kubernetes.client.models.V1SecurityContext;
910

@@ -85,6 +86,8 @@ ClusterConfigurator withLivenessProbeSettings(
8586

8687
ClusterConfigurator withAdditionalVolumeMount(String name, String path);
8788

89+
ClusterConfigurator withInitContainer(V1Container initContainer);
90+
8891
ClusterConfigurator withPodLabel(String name, String value);
8992

9093
ClusterConfigurator withPodAnnotation(String name, String value);

model/src/main/java/oracle/kubernetes/weblogic/domain/DomainConfigurator.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
// Copyright 2018, Oracle Corporation and/or its affiliates. All rights reserved.
1+
// Copyright 2018, 2019, Oracle Corporation and/or its affiliates. All rights reserved.
22
// Licensed under the Universal Permissive License v 1.0 as shown at
33
// http://oss.oracle.com/licenses/upl.
44

55
package oracle.kubernetes.weblogic.domain;
66

7+
import io.kubernetes.client.models.V1Container;
78
import io.kubernetes.client.models.V1LocalObjectReference;
89
import io.kubernetes.client.models.V1ObjectMeta;
910
import io.kubernetes.client.models.V1PodSecurityContext;
@@ -200,6 +201,8 @@ protected DomainSpec getDomainSpec() {
200201

201202
public abstract DomainConfigurator withAdditionalVolumeMount(String name, String path);
202203

204+
public abstract DomainConfigurator withInitContainer(V1Container initContainer);
205+
203206
public abstract DomainConfigurator withPodLabel(String name, String value);
204207

205208
public abstract DomainConfigurator withPodAnnotation(String name, String value);

model/src/main/java/oracle/kubernetes/weblogic/domain/ServerConfigurator.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
// Copyright 2018, Oracle Corporation and/or its affiliates. All rights reserved.
1+
// Copyright 2018, 2019, Oracle Corporation and/or its affiliates. All rights reserved.
22
// Licensed under the Universal Permissive License v 1.0 as shown at
33
// http://oss.oracle.com/licenses/upl.
44

55
package oracle.kubernetes.weblogic.domain;
66

7+
import io.kubernetes.client.models.V1Container;
78
import io.kubernetes.client.models.V1PodSecurityContext;
89
import io.kubernetes.client.models.V1SecurityContext;
910

@@ -81,6 +82,8 @@ ServerConfigurator withReadinessProbeSettings(
8182

8283
ServerConfigurator withAdditionalVolumeMount(String name, String path);
8384

85+
ServerConfigurator withInitContainer(V1Container initContainer);
86+
8487
ServerConfigurator withPodLabel(String name, String value);
8588

8689
ServerConfigurator withPodAnnotation(String name, String value);

model/src/main/java/oracle/kubernetes/weblogic/domain/model/BaseConfiguration.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
import com.google.gson.annotations.Expose;
88
import com.google.gson.annotations.SerializedName;
9+
import io.kubernetes.client.models.V1Container;
910
import io.kubernetes.client.models.V1EnvVar;
1011
import io.kubernetes.client.models.V1PodSecurityContext;
1112
import io.kubernetes.client.models.V1ResourceRequirements;
@@ -200,6 +201,10 @@ void addAdditionalVolumeMount(String name, String path) {
200201
serverPod.addAdditionalVolumeMount(name, path);
201202
}
202203

204+
void addInitContainer(V1Container initContainer) {
205+
serverPod.addInitContainer(initContainer);
206+
}
207+
203208
Map<String, String> getPodLabels() {
204209
return serverPod.getLabels();
205210
}
@@ -236,6 +241,10 @@ public Map<String, String> getServiceAnnotations() {
236241
return serverService.getAnnotations();
237242
}
238243

244+
public List<V1Container> getInitContainers() {
245+
return serverPod.getInitContainers();
246+
}
247+
239248
void addServiceAnnotation(String name, String value) {
240249
serverService.addAnnotations(name, value);
241250
}

model/src/main/java/oracle/kubernetes/weblogic/domain/model/ClusterSpec.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44

55
package oracle.kubernetes.weblogic.domain.model;
66

7+
import io.kubernetes.client.models.V1Container;
8+
import java.util.Collections;
9+
import java.util.List;
710
import java.util.Map;
811
import javax.annotation.Nonnull;
912

@@ -39,4 +42,14 @@ public abstract class ClusterSpec {
3942
*/
4043
@Nonnull
4144
public abstract Map<String, String> getClusterAnnotations();
45+
46+
/**
47+
* Returns the list of initContainers.
48+
*
49+
* @return a list of containers
50+
*/
51+
@Nonnull
52+
public List<V1Container> getInitContainers() {
53+
return Collections.emptyList();
54+
}
4255
}

model/src/main/java/oracle/kubernetes/weblogic/domain/model/ClusterSpecCommonImpl.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
package oracle.kubernetes.weblogic.domain.model;
66

7+
import io.kubernetes.client.models.V1Container;
8+
import java.util.List;
79
import java.util.Map;
810

911
public class ClusterSpecCommonImpl extends ClusterSpec {
@@ -37,4 +39,9 @@ public Map<String, String> getClusterLabels() {
3739
public Map<String, String> getClusterAnnotations() {
3840
return cluster.getClusterAnnotations();
3941
}
42+
43+
@Override
44+
public List<V1Container> getInitContainers() {
45+
return cluster.getInitContainers();
46+
}
4047
}

0 commit comments

Comments
 (0)