Class Deployment

  • All Implemented Interfaces:
    IApiEndpoint, IApiResource, IResource, software.amazon.jsii.JsiiSerializable, software.constructs.IConstruct, software.constructs.IDependable

    @Generated(value="jsii-pacmak/1.59.0 (build eb02c92)",
               date="2022-05-18T23:19:48.576Z")
    @Stability(Stable)
    public class Deployment
    extends Workload
    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.
    • Constructor Detail

      • Deployment

        protected Deployment​(software.amazon.jsii.JsiiObjectRef objRef)
      • Deployment

        protected Deployment​(software.amazon.jsii.JsiiObject.InitializationMode initializationMode)
      • Deployment

        @Stability(Stable)
        public Deployment​(@NotNull
                          software.constructs.Construct scope,
                          @NotNull
                          String id,
                          @Nullable
                          DeploymentProps props)
        Parameters:
        scope - This parameter is required.
        id - This parameter is required.
        props -
      • Deployment

        @Stability(Stable)
        public Deployment​(@NotNull
                          software.constructs.Construct scope,
                          @NotNull
                          String id)
        Parameters:
        scope - This parameter is required.
        id - This parameter is required.
    • Method Detail

      • exposeViaIngress

        @Stability(Stable)
        @NotNull
        public IngressV1Beta1 exposeViaIngress​(@NotNull
                                               String path,
                                               @Nullable
                                               ExposeDeploymentViaIngressOptions options)
        Expose a deployment via an ingress.

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

        Parameters:
        path - The ingress path to register under. This parameter is required.
        options - Additional options.
      • exposeViaIngress

        @Stability(Stable)
        @NotNull
        public IngressV1Beta1 exposeViaIngress​(@NotNull
                                               String path)
        Expose a deployment via an ingress.

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

        Parameters:
        path - The ingress path to register under. This parameter is required.
      • exposeViaService

        @Stability(Stable)
        @NotNull
        public Service exposeViaService​(@Nullable
                                        ExposeDeploymentViaServiceOptions options)
        Expose a deployment via a service.

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

        Parameters:
        options - Options to determine details of the service and port exposed.
      • exposeViaService

        @Stability(Stable)
        @NotNull
        public Service exposeViaService()
        Expose a deployment via a service.

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

      • getApiObject

        @Stability(Stable)
        @NotNull
        protected org.cdk8s.ApiObject getApiObject()
        The underlying cdk8s API object.

        Specified by:
        getApiObject in class Resource
        See Also:
        base.Resource.apiObject
      • getMinReady

        @Stability(Stable)
        @NotNull
        public org.cdk8s.Duration getMinReady()
        Minimum duration for which a newly created pod should be ready without any of its container crashing, for it to be considered available.
      • getProgressDeadline

        @Stability(Stable)
        @NotNull
        public org.cdk8s.Duration getProgressDeadline()
        The maximum duration for a deployment to make progress before it is considered to be failed.
      • getReplicas

        @Stability(Stable)
        @NotNull
        public Number getReplicas()
        Number of desired pods.