All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.cdk8s.plus22.Deployment Maven / Gradle / Ivy

package org.cdk8s.plus22;

/**
 * A Deployment provides declarative updates for Pods and ReplicaSets.
 * 

* You describe a desired state in a Deployment, and the Deployment Controller changes the actual * state to the desired state at a controlled rate. You can define Deployments to create new ReplicaSets, or to remove * existing Deployments and adopt all their resources with new Deployments. *

*

*

* Note: Do not manage ReplicaSets owned by a Deployment. Consider opening an issue in the main Kubernetes repository if your use case is not covered below. *

*

*

*

Use Case

*

* The following are typical use cases for Deployments: *

*

    *
  • Create a Deployment to rollout a ReplicaSet. The ReplicaSet creates Pods in the background. * Check the status of the rollout to see if it succeeds or not.
  • *
  • Declare the new state of the Pods by updating the PodTemplateSpec of the Deployment. * A new ReplicaSet is created and the Deployment manages moving the Pods from the old ReplicaSet to the new one at a controlled rate. * Each new ReplicaSet updates the revision of the Deployment.
  • *
  • Rollback to an earlier Deployment revision if the current state of the Deployment is not stable. * Each rollback updates the revision of the Deployment.
  • *
  • Scale up the Deployment to facilitate more load.
  • *
  • Pause the Deployment to apply multiple fixes to its PodTemplateSpec and then resume it to start a new rollout.
  • *
  • Use the status of the Deployment as an indicator that a rollout has stuck.
  • *
  • Clean up older ReplicaSets that you don't need anymore.
  • *
*/ @javax.annotation.Generated(value = "jsii-pacmak/1.47.0 (build 86d2c33)", date = "2021-12-08T00:16:55.087Z") @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable) @software.amazon.jsii.Jsii(module = org.cdk8s.plus22.$Module.class, fqn = "cdk8s-plus-22.Deployment") public class Deployment extends org.cdk8s.plus22.Resource implements org.cdk8s.plus22.IPodTemplate { protected Deployment(final software.amazon.jsii.JsiiObjectRef objRef) { super(objRef); } protected Deployment(final software.amazon.jsii.JsiiObject.InitializationMode initializationMode) { super(initializationMode); } /** * @param scope This parameter is required. * @param id This parameter is required. * @param props */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable) public Deployment(final @org.jetbrains.annotations.NotNull software.constructs.Construct scope, final @org.jetbrains.annotations.NotNull java.lang.String id, final @org.jetbrains.annotations.Nullable org.cdk8s.plus22.DeploymentProps props) { super(software.amazon.jsii.JsiiObject.InitializationMode.JSII); software.amazon.jsii.JsiiEngine.getInstance().createNewObject(this, new Object[] { java.util.Objects.requireNonNull(scope, "scope is required"), java.util.Objects.requireNonNull(id, "id is required"), props }); } /** * @param scope This parameter is required. * @param id This parameter is required. */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable) public Deployment(final @org.jetbrains.annotations.NotNull software.constructs.Construct scope, final @org.jetbrains.annotations.NotNull java.lang.String id) { super(software.amazon.jsii.JsiiObject.InitializationMode.JSII); software.amazon.jsii.JsiiEngine.getInstance().createNewObject(this, new Object[] { java.util.Objects.requireNonNull(scope, "scope is required"), java.util.Objects.requireNonNull(id, "id is required") }); } /** * Add a container to the pod. *

* @param container This parameter is required. */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable) @Override public @org.jetbrains.annotations.NotNull org.cdk8s.plus22.Container addContainer(final @org.jetbrains.annotations.NotNull org.cdk8s.plus22.ContainerProps container) { return software.amazon.jsii.Kernel.call(this, "addContainer", software.amazon.jsii.NativeType.forClass(org.cdk8s.plus22.Container.class), new Object[] { java.util.Objects.requireNonNull(container, "container is required") }); } /** * Add a volume to the pod. *

* @param volume This parameter is required. */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable) @Override public void addVolume(final @org.jetbrains.annotations.NotNull org.cdk8s.plus22.Volume volume) { software.amazon.jsii.Kernel.call(this, "addVolume", software.amazon.jsii.NativeType.VOID, new Object[] { java.util.Objects.requireNonNull(volume, "volume is required") }); } /** * Expose a deployment via an ingress. *

* This will first expose the deployment with a service, and then expose the service via an ingress. *

* @param path The ingress path to register under. This parameter is required. * @param options Additional options. */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable) public @org.jetbrains.annotations.NotNull org.cdk8s.plus22.Ingress exposeViaIngress(final @org.jetbrains.annotations.NotNull java.lang.String path, final @org.jetbrains.annotations.Nullable org.cdk8s.plus22.ExposeDeploymentViaIngressOptions options) { return software.amazon.jsii.Kernel.call(this, "exposeViaIngress", software.amazon.jsii.NativeType.forClass(org.cdk8s.plus22.Ingress.class), new Object[] { java.util.Objects.requireNonNull(path, "path is required"), options }); } /** * Expose a deployment via an ingress. *

* This will first expose the deployment with a service, and then expose the service via an ingress. *

* @param path The ingress path to register under. This parameter is required. */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable) public @org.jetbrains.annotations.NotNull org.cdk8s.plus22.Ingress exposeViaIngress(final @org.jetbrains.annotations.NotNull java.lang.String path) { return software.amazon.jsii.Kernel.call(this, "exposeViaIngress", software.amazon.jsii.NativeType.forClass(org.cdk8s.plus22.Ingress.class), new Object[] { java.util.Objects.requireNonNull(path, "path is required") }); } /** * Expose a deployment via a service. *

* This is equivalent to running kubectl expose deployment <deployment-name>. *

* @param options Options to determine details of the service and port exposed. */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable) public @org.jetbrains.annotations.NotNull org.cdk8s.plus22.Service exposeViaService(final @org.jetbrains.annotations.Nullable org.cdk8s.plus22.ExposeDeploymentViaServiceOptions options) { return software.amazon.jsii.Kernel.call(this, "exposeViaService", software.amazon.jsii.NativeType.forClass(org.cdk8s.plus22.Service.class), new Object[] { options }); } /** * Expose a deployment via a service. *

* This is equivalent to running kubectl expose deployment <deployment-name>. */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable) public @org.jetbrains.annotations.NotNull org.cdk8s.plus22.Service exposeViaService() { return software.amazon.jsii.Kernel.call(this, "exposeViaService", software.amazon.jsii.NativeType.forClass(org.cdk8s.plus22.Service.class)); } /** * Configure a label selector to this deployment. *

* Pods that have the label will be selected by deployments configured with this spec. *

* @param key - The label key. This parameter is required. * @param value - The label value. This parameter is required. */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable) public void selectByLabel(final @org.jetbrains.annotations.NotNull java.lang.String key, final @org.jetbrains.annotations.NotNull java.lang.String value) { software.amazon.jsii.Kernel.call(this, "selectByLabel", software.amazon.jsii.NativeType.VOID, new Object[] { java.util.Objects.requireNonNull(key, "key is required"), java.util.Objects.requireNonNull(value, "value is required") }); } /** * The underlying cdk8s API object. *

* @see base.Resource.apiObject */ @Override @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable) protected @org.jetbrains.annotations.NotNull org.cdk8s.ApiObject getApiObject() { return software.amazon.jsii.Kernel.get(this, "apiObject", software.amazon.jsii.NativeType.forClass(org.cdk8s.ApiObject.class)); } /** * The containers belonging to the pod. *

* Use addContainer to add containers. */ @Override @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable) public @org.jetbrains.annotations.NotNull java.util.List getContainers() { return java.util.Collections.unmodifiableList(software.amazon.jsii.Kernel.get(this, "containers", software.amazon.jsii.NativeType.listOf(software.amazon.jsii.NativeType.forClass(org.cdk8s.plus22.Container.class)))); } /** * The labels this deployment will match against in order to select pods. *

* Returns a a copy. Use selectByLabel() to add labels. */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable) public @org.jetbrains.annotations.NotNull java.util.Map getLabelSelector() { return java.util.Collections.unmodifiableMap(software.amazon.jsii.Kernel.get(this, "labelSelector", software.amazon.jsii.NativeType.mapOf(software.amazon.jsii.NativeType.forClass(java.lang.String.class)))); } /** * Provides read/write access to the underlying pod metadata of the resource. */ @Override @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable) public @org.jetbrains.annotations.NotNull org.cdk8s.ApiObjectMetadataDefinition getPodMetadata() { return software.amazon.jsii.Kernel.get(this, "podMetadata", software.amazon.jsii.NativeType.forClass(org.cdk8s.ApiObjectMetadataDefinition.class)); } /** * Number of desired pods. */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable) public @org.jetbrains.annotations.NotNull java.lang.Number getReplicas() { return software.amazon.jsii.Kernel.get(this, "replicas", software.amazon.jsii.NativeType.forClass(java.lang.Number.class)); } /** * The volumes associated with this pod. *

* Use addVolume to add volumes. */ @Override @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable) public @org.jetbrains.annotations.NotNull java.util.List getVolumes() { return java.util.Collections.unmodifiableList(software.amazon.jsii.Kernel.get(this, "volumes", software.amazon.jsii.NativeType.listOf(software.amazon.jsii.NativeType.forClass(org.cdk8s.plus22.Volume.class)))); } /** * Restart policy for all containers within the pod. */ @Override @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable) public @org.jetbrains.annotations.Nullable org.cdk8s.plus22.RestartPolicy getRestartPolicy() { return software.amazon.jsii.Kernel.get(this, "restartPolicy", software.amazon.jsii.NativeType.forClass(org.cdk8s.plus22.RestartPolicy.class)); } /** * The service account used to run this pod. */ @Override @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable) public @org.jetbrains.annotations.Nullable org.cdk8s.plus22.IServiceAccount getServiceAccount() { return software.amazon.jsii.Kernel.get(this, "serviceAccount", software.amazon.jsii.NativeType.forClass(org.cdk8s.plus22.IServiceAccount.class)); } /** * A fluent builder for {@link org.cdk8s.plus22.Deployment}. */ @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}. * @param scope This parameter is required. * @param id This parameter is required. */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable) public static Builder create(final software.constructs.Construct scope, final java.lang.String id) { return new Builder(scope, id); } private final software.constructs.Construct scope; private final java.lang.String id; private org.cdk8s.plus22.DeploymentProps.Builder props; private Builder(final software.constructs.Construct scope, final java.lang.String id) { this.scope = scope; this.id = id; } /** * Metadata that all persisted resources must have, which includes all objects users must create. *

* @return {@code this} * @param metadata Metadata that all persisted resources must have, which includes all objects users must create. This parameter is required. */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable) public Builder metadata(final org.cdk8s.ApiObjectMetadata metadata) { this.props().metadata(metadata); return this; } /** * List of containers belonging to the pod. *

* Containers cannot currently be * added or removed. There must be at least one container in a Pod. *

* You can add additionnal containers using podSpec.addContainer() *

* Default: - No containers. Note that a pod spec must include at least one container. *

* @return {@code this} * @param containers List of containers belonging to the pod. This parameter is required. */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable) public Builder containers(final java.util.List containers) { this.props().containers(containers); return this; } /** * Restart policy for all containers within the pod. *

* Default: RestartPolicy.ALWAYS *

* @return {@code this} * @see https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle/#restart-policy * @param restartPolicy Restart policy for all containers within the pod. This parameter is required. */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable) public Builder restartPolicy(final org.cdk8s.plus22.RestartPolicy restartPolicy) { this.props().restartPolicy(restartPolicy); return this; } /** * A service account provides an identity for processes that run in a Pod. *

* When you (a human) access the cluster (for example, using kubectl), you are * authenticated by the apiserver as a particular User Account (currently this * is usually admin, unless your cluster administrator has customized your * cluster). Processes in containers inside pods can also contact the * apiserver. When they do, they are authenticated as a particular Service * Account (for example, default). *

* Default: - No service account. *

* @return {@code this} * @see https://kubernetes.io/docs/tasks/configure-pod-container/configure-service-account/ * @param serviceAccount A service account provides an identity for processes that run in a Pod. This parameter is required. */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable) public Builder serviceAccount(final org.cdk8s.plus22.IServiceAccount serviceAccount) { this.props().serviceAccount(serviceAccount); return this; } /** * List of volumes that can be mounted by containers belonging to the pod. *

* You can also add volumes later using podSpec.addVolume() *

* Default: - No volumes. *

* @return {@code this} * @see https://kubernetes.io/docs/concepts/storage/volumes * @param volumes List of volumes that can be mounted by containers belonging to the pod. This parameter is required. */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable) public Builder volumes(final java.util.List volumes) { this.props().volumes(volumes); return this; } /** * The pod metadata. *

* @return {@code this} * @param podMetadata The pod metadata. This parameter is required. */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable) public Builder podMetadata(final org.cdk8s.ApiObjectMetadata podMetadata) { this.props().podMetadata(podMetadata); return this; } /** * Automatically allocates a pod selector for this deployment. *

* If this is set to false you must define your selector through * deployment.podMetadata.addLabel() and deployment.selectByLabel(). *

* Default: true *

* @return {@code this} * @param defaultSelector Automatically allocates a pod selector for this deployment. This parameter is required. */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable) public Builder defaultSelector(final java.lang.Boolean defaultSelector) { this.props().defaultSelector(defaultSelector); return this; } /** * Number of desired pods. *

* Default: 1 *

* @return {@code this} * @param replicas Number of desired pods. This parameter is required. */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable) public Builder replicas(final java.lang.Number replicas) { this.props().replicas(replicas); return this; } /** * @returns a newly built instance of {@link org.cdk8s.plus22.Deployment}. */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable) @Override public org.cdk8s.plus22.Deployment build() { return new org.cdk8s.plus22.Deployment( this.scope, this.id, this.props != null ? this.props.build() : null ); } private org.cdk8s.plus22.DeploymentProps.Builder props() { if (this.props == null) { this.props = new org.cdk8s.plus22.DeploymentProps.Builder(); } return this.props; } } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy