
org.cdk8s.plus31.Container Maven / Gradle / Ivy
package org.cdk8s.plus31;
/**
* A single application container that you want to run within a pod.
*/
@javax.annotation.Generated(value = "jsii-pacmak/1.105.0 (build 0a2adcb)", date = "2024-11-15T12:15:24.784Z")
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable)
@software.amazon.jsii.Jsii(module = org.cdk8s.plus31.$Module.class, fqn = "cdk8s-plus-31.Container")
public class Container extends software.amazon.jsii.JsiiObject {
protected Container(final software.amazon.jsii.JsiiObjectRef objRef) {
super(objRef);
}
protected Container(final software.amazon.jsii.JsiiObject.InitializationMode initializationMode) {
super(initializationMode);
}
/**
* @param props This parameter is required.
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable)
public Container(final @org.jetbrains.annotations.NotNull org.cdk8s.plus31.ContainerProps props) {
super(software.amazon.jsii.JsiiObject.InitializationMode.JSII);
software.amazon.jsii.JsiiEngine.getInstance().createNewObject(this, new Object[] { java.util.Objects.requireNonNull(props, "props is required") });
}
/**
* Add a port to expose from this container.
*
* @param port This parameter is required.
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable)
public void addPort(final @org.jetbrains.annotations.NotNull org.cdk8s.plus31.ContainerPort port) {
software.amazon.jsii.Kernel.call(this, "addPort", software.amazon.jsii.NativeType.VOID, new Object[] { java.util.Objects.requireNonNull(port, "port is required") });
}
/**
* Mount a volume to a specific path so that it is accessible by the container.
*
* Every pod that is configured to use this container will autmoatically have access to the volume.
*
* @param path
- The desired path in the container.
This parameter is required.
* @param storage - The storage to mount.
This parameter is required.
* @param options
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable)
public void mount(final @org.jetbrains.annotations.NotNull java.lang.String path, final @org.jetbrains.annotations.NotNull org.cdk8s.plus31.IStorage storage, final @org.jetbrains.annotations.Nullable org.cdk8s.plus31.MountOptions options) {
software.amazon.jsii.Kernel.call(this, "mount", software.amazon.jsii.NativeType.VOID, new Object[] { java.util.Objects.requireNonNull(path, "path is required"), java.util.Objects.requireNonNull(storage, "storage is required"), options });
}
/**
* Mount a volume to a specific path so that it is accessible by the container.
*
* Every pod that is configured to use this container will autmoatically have access to the volume.
*
* @param path
- The desired path in the container.
This parameter is required.
* @param storage - The storage to mount.
This parameter is required.
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable)
public void mount(final @org.jetbrains.annotations.NotNull java.lang.String path, final @org.jetbrains.annotations.NotNull org.cdk8s.plus31.IStorage storage) {
software.amazon.jsii.Kernel.call(this, "mount", software.amazon.jsii.NativeType.VOID, new Object[] { java.util.Objects.requireNonNull(path, "path is required"), java.util.Objects.requireNonNull(storage, "storage is required") });
}
/**
* The environment of the container.
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable)
public @org.jetbrains.annotations.NotNull org.cdk8s.plus31.Env getEnv() {
return software.amazon.jsii.Kernel.get(this, "env", software.amazon.jsii.NativeType.forClass(org.cdk8s.plus31.Env.class));
}
/**
* The container image.
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable)
public @org.jetbrains.annotations.NotNull java.lang.String getImage() {
return software.amazon.jsii.Kernel.get(this, "image", software.amazon.jsii.NativeType.forClass(java.lang.String.class));
}
/**
* Image pull policy for this container.
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable)
public @org.jetbrains.annotations.NotNull org.cdk8s.plus31.ImagePullPolicy getImagePullPolicy() {
return software.amazon.jsii.Kernel.get(this, "imagePullPolicy", software.amazon.jsii.NativeType.forClass(org.cdk8s.plus31.ImagePullPolicy.class));
}
/**
* Volume mounts configured for this container.
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable)
public @org.jetbrains.annotations.NotNull java.util.List getMounts() {
return java.util.Collections.unmodifiableList(software.amazon.jsii.Kernel.get(this, "mounts", software.amazon.jsii.NativeType.listOf(software.amazon.jsii.NativeType.forClass(org.cdk8s.plus31.VolumeMount.class))));
}
/**
* The name of the container.
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable)
public @org.jetbrains.annotations.NotNull java.lang.String getName() {
return software.amazon.jsii.Kernel.get(this, "name", software.amazon.jsii.NativeType.forClass(java.lang.String.class));
}
/**
* Ports exposed by this containers.
*
* Returns a copy, use addPort
to modify.
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable)
public @org.jetbrains.annotations.NotNull java.util.List getPorts() {
return java.util.Collections.unmodifiableList(software.amazon.jsii.Kernel.get(this, "ports", software.amazon.jsii.NativeType.listOf(software.amazon.jsii.NativeType.forClass(org.cdk8s.plus31.ContainerPort.class))));
}
/**
* The security context of the container.
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable)
public @org.jetbrains.annotations.NotNull org.cdk8s.plus31.ContainerSecurityContext getSecurityContext() {
return software.amazon.jsii.Kernel.get(this, "securityContext", software.amazon.jsii.NativeType.forClass(org.cdk8s.plus31.ContainerSecurityContext.class));
}
/**
* Arguments to the entrypoint.
*
* @return a copy of the arguments array, cannot be modified.
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable)
public @org.jetbrains.annotations.Nullable java.util.List getArgs() {
return java.util.Optional.ofNullable((java.util.List)(software.amazon.jsii.Kernel.get(this, "args", software.amazon.jsii.NativeType.listOf(software.amazon.jsii.NativeType.forClass(java.lang.String.class))))).map(java.util.Collections::unmodifiableList).orElse(null);
}
/**
* Entrypoint array (the command to execute when the container starts).
*
* @return a copy of the entrypoint array, cannot be modified
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable)
public @org.jetbrains.annotations.Nullable java.util.List getCommand() {
return java.util.Optional.ofNullable((java.util.List)(software.amazon.jsii.Kernel.get(this, "command", software.amazon.jsii.NativeType.listOf(software.amazon.jsii.NativeType.forClass(java.lang.String.class))))).map(java.util.Collections::unmodifiableList).orElse(null);
}
/**
* @deprecated
* - use
portNumber
.
*
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Deprecated)
@Deprecated
public @org.jetbrains.annotations.Nullable java.lang.Number getPort() {
return software.amazon.jsii.Kernel.get(this, "port", software.amazon.jsii.NativeType.forClass(java.lang.Number.class));
}
/**
* The port number that was configured for this container.
*
* If undefined, either the container doesn't expose a port, or its
* port configuration is stored in the ports
field.
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable)
public @org.jetbrains.annotations.Nullable java.lang.Number getPortNumber() {
return software.amazon.jsii.Kernel.get(this, "portNumber", software.amazon.jsii.NativeType.forClass(java.lang.Number.class));
}
/**
* Compute resources (CPU and memory requests and limits) required by the container.
*
* @see https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable)
public @org.jetbrains.annotations.Nullable org.cdk8s.plus31.ContainerResources getResources() {
return software.amazon.jsii.Kernel.get(this, "resources", software.amazon.jsii.NativeType.forClass(org.cdk8s.plus31.ContainerResources.class));
}
/**
* The restart policy of the container.
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable)
public @org.jetbrains.annotations.Nullable org.cdk8s.plus31.ContainerRestartPolicy getRestartPolicy() {
return software.amazon.jsii.Kernel.get(this, "restartPolicy", software.amazon.jsii.NativeType.forClass(org.cdk8s.plus31.ContainerRestartPolicy.class));
}
/**
* The working directory inside the container.
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable)
public @org.jetbrains.annotations.Nullable java.lang.String getWorkingDir() {
return software.amazon.jsii.Kernel.get(this, "workingDir", software.amazon.jsii.NativeType.forClass(java.lang.String.class));
}
/**
* A fluent builder for {@link org.cdk8s.plus31.Container}.
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable)
public static final class Builder implements software.amazon.jsii.Builder {
/**
* @return a new instance of {@link Builder}.
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable)
public static Builder create() {
return new Builder();
}
private final org.cdk8s.plus31.ContainerProps.Builder props;
private Builder() {
this.props = new org.cdk8s.plus31.ContainerProps.Builder();
}
/**
* Arguments to the entrypoint. The docker image's CMD is used if command
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.
*
* Default: []
*
* @return {@code this}
* @see https://kubernetes.io/docs/tasks/inject-data-application/define-command-argument-container/#running-a-command-in-a-shell
* @param args Arguments to the entrypoint. The docker image's CMD is used if command
is not provided. This parameter is required.
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable)
public Builder args(final java.util.List args) {
this.props.args(args);
return this;
}
/**
* 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
*
* Default: - The docker image's ENTRYPOINT.
*
* @return {@code this}
* @param command Entrypoint array. This parameter is required.
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable)
public Builder command(final java.util.List command) {
this.props.command(command);
return this;
}
/**
* List of sources to populate environment variables in the container.
*
* When a key exists in multiple sources, the value associated with
* the last source will take precedence. Values defined by the envVariables
property
* with a duplicate key will take precedence.
*
* Default: - No sources.
*
* @return {@code this}
* @param envFrom List of sources to populate environment variables in the container. This parameter is required.
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable)
public Builder envFrom(final java.util.List extends org.cdk8s.plus31.EnvFrom> envFrom) {
this.props.envFrom(envFrom);
return this;
}
/**
* Environment variables to set in the container.
*
* Default: - No environment variables.
*
* @return {@code this}
* @param envVariables Environment variables to set in the container. This parameter is required.
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable)
public Builder envVariables(final java.util.Map envVariables) {
this.props.envVariables(envVariables);
return this;
}
/**
* Image pull policy for this container.
*
* Default: ImagePullPolicy.ALWAYS
*
* @return {@code this}
* @param imagePullPolicy Image pull policy for this container. This parameter is required.
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable)
public Builder imagePullPolicy(final org.cdk8s.plus31.ImagePullPolicy imagePullPolicy) {
this.props.imagePullPolicy(imagePullPolicy);
return this;
}
/**
* Describes actions that the management system should take in response to container lifecycle events.
*
* @return {@code this}
* @param lifecycle Describes actions that the management system should take in response to container lifecycle events. This parameter is required.
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable)
public Builder lifecycle(final org.cdk8s.plus31.ContainerLifecycle lifecycle) {
this.props.lifecycle(lifecycle);
return this;
}
/**
* Periodic probe of container liveness.
*
* Container will be restarted if the probe fails.
*
* Default: - no liveness probe is defined
*
* @return {@code this}
* @param liveness Periodic probe of container liveness. This parameter is required.
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable)
public Builder liveness(final org.cdk8s.plus31.Probe liveness) {
this.props.liveness(liveness);
return this;
}
/**
* Name of the container specified as a DNS_LABEL.
*
* Each container in a pod must have a unique name (DNS_LABEL). Cannot be updated.
*
* Default: 'main'
*
* @return {@code this}
* @param name Name of the container specified as a DNS_LABEL. This parameter is required.
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable)
public Builder name(final java.lang.String name) {
this.props.name(name);
return this;
}
/**
* @return {@code this}
* @deprecated
* - use
portNumber
.
*
* @param port This parameter is required.
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Deprecated)
@Deprecated
public Builder port(final java.lang.Number port) {
this.props.port(port);
return this;
}
/**
* Number of port to expose on the pod's IP address.
*
* This must be a valid port number, 0 < x < 65536.
*
* This is a convinience property if all you need a single TCP numbered port.
* In case more advanced configuartion is required, use the ports
property.
*
* This port is added to the list of ports mentioned in the ports
property.
*
* Default: - Only the ports mentiond in the `ports` property are exposed.
*
* @return {@code this}
* @param portNumber Number of port to expose on the pod's IP address. This parameter is required.
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable)
public Builder portNumber(final java.lang.Number portNumber) {
this.props.portNumber(portNumber);
return this;
}
/**
* List of ports to expose from this container.
*
* Default: - Only the port mentioned in the `portNumber` property is exposed.
*
* @return {@code this}
* @param ports List of ports to expose from this container. This parameter is required.
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable)
public Builder ports(final java.util.List extends org.cdk8s.plus31.ContainerPort> ports) {
this.props.ports(ports);
return this;
}
/**
* Determines when the container is ready to serve traffic.
*
* Default: - no readiness probe is defined
*
* @return {@code this}
* @param readiness Determines when the container is ready to serve traffic. This parameter is required.
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable)
public Builder readiness(final org.cdk8s.plus31.Probe readiness) {
this.props.readiness(readiness);
return this;
}
/**
* Compute resources (CPU and memory requests and limits) required by the container.
*
* Default: cpu:
* request: 1000 millis
* limit: 1500 millis
* memory:
* request: 512 mebibytes
* limit: 2048 mebibytes
*
* @return {@code this}
* @see https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/
* @param resources Compute resources (CPU and memory requests and limits) required by the container. This parameter is required.
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable)
public Builder resources(final org.cdk8s.plus31.ContainerResources resources) {
this.props.resources(resources);
return this;
}
/**
* Kubelet will start init containers with restartPolicy=Always in the order with other init containers, but instead of waiting for its completion, it will wait for the container startup completion Currently, only accepted value is Always.
*
* Default: - no restart policy is defined and the pod restart policy is applied
*
* @return {@code this}
* @see https://kubernetes.io/docs/concepts/workloads/pods/sidecar-containers/
* @param restartPolicy Kubelet will start init containers with restartPolicy=Always in the order with other init containers, but instead of waiting for its completion, it will wait for the container startup completion Currently, only accepted value is Always. This parameter is required.
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable)
public Builder restartPolicy(final org.cdk8s.plus31.ContainerRestartPolicy restartPolicy) {
this.props.restartPolicy(restartPolicy);
return this;
}
/**
* SecurityContext defines the security options the container should be run with.
*
* If set, the fields override equivalent fields of the pod's security context.
*
* Default: ensureNonRoot: true
* privileged: false
* readOnlyRootFilesystem: true
* allowPrivilegeEscalation: false
* user: 25000
* group: 26000
*
* @return {@code this}
* @see https://kubernetes.io/docs/tasks/configure-pod-container/security-context/
* @param securityContext SecurityContext defines the security options the container should be run with. This parameter is required.
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable)
public Builder securityContext(final org.cdk8s.plus31.ContainerSecurityContextProps securityContext) {
this.props.securityContext(securityContext);
return this;
}
/**
* StartupProbe indicates that the Pod has successfully initialized.
*
* If specified, no other probes are executed until this completes successfully
*
* Default: - If a port is provided, then knocks on that port
* to determine when the container is ready for readiness and
* liveness probe checks.
* Otherwise, no startup probe is defined.
*
* @return {@code this}
* @param startup StartupProbe indicates that the Pod has successfully initialized. This parameter is required.
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable)
public Builder startup(final org.cdk8s.plus31.Probe startup) {
this.props.startup(startup);
return this;
}
/**
* Pod volumes to mount into the container's filesystem.
*
* Cannot be updated.
*
* @return {@code this}
* @param volumeMounts Pod volumes to mount into the container's filesystem. This parameter is required.
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable)
public Builder volumeMounts(final java.util.List extends org.cdk8s.plus31.VolumeMount> volumeMounts) {
this.props.volumeMounts(volumeMounts);
return this;
}
/**
* 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.
*
* Default: - The container runtime's default.
*
* @return {@code this}
* @param workingDir Container's working directory. This parameter is required.
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable)
public Builder workingDir(final java.lang.String workingDir) {
this.props.workingDir(workingDir);
return this;
}
/**
* Docker image name.
*
* @return {@code this}
* @param image Docker image name. This parameter is required.
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable)
public Builder image(final java.lang.String image) {
this.props.image(image);
return this;
}
/**
* @return a newly built instance of {@link org.cdk8s.plus31.Container}.
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable)
@Override
public org.cdk8s.plus31.Container build() {
return new org.cdk8s.plus31.Container(
this.props.build()
);
}
}
}