Class Deployment
- java.lang.Object
-
- software.amazon.jsii.JsiiObject
-
- software.constructs.Construct
-
- org.cdk8s.plus20.Resource
-
- org.cdk8s.plus20.Deployment
-
- All Implemented Interfaces:
IPodSpec,IPodTemplate,IResource,software.amazon.jsii.JsiiSerializable,software.constructs.IConstruct
@Generated(value="jsii-pacmak/1.57.0 (build f614666)", date="2022-04-26T09:02:10.458Z") @Stability(Stable) public class Deployment extends Resource implements IPodTemplate
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.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classDeployment.BuilderA fluent builder forDeployment.-
Nested classes/interfaces inherited from class software.amazon.jsii.JsiiObject
software.amazon.jsii.JsiiObject.InitializationMode
-
Nested classes/interfaces inherited from interface software.constructs.IConstruct
software.constructs.IConstruct.Jsii$Default
-
Nested classes/interfaces inherited from interface org.cdk8s.plus20.IPodTemplate
IPodTemplate.Jsii$Default, IPodTemplate.Jsii$Proxy
-
Nested classes/interfaces inherited from interface org.cdk8s.plus20.IResource
IResource.Jsii$Default
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedDeployment(software.amazon.jsii.JsiiObject.InitializationMode initializationMode)protectedDeployment(software.amazon.jsii.JsiiObjectRef objRef)Deployment(software.constructs.Construct scope, String id)Deployment(software.constructs.Construct scope, String id, DeploymentProps props)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ContaineraddContainer(ContainerProps cont)Add a container to the pod.voidaddHostAlias(HostAlias hostAlias)ContaineraddInitContainer(ContainerProps cont)Add an init container to the pod.voidaddVolume(Volume vol)Add a volume to the pod.IngressV1Beta1exposeViaIngress(String path)Expose a deployment via an ingress.IngressV1Beta1exposeViaIngress(String path, ExposeDeploymentViaIngressOptions options)Expose a deployment via an ingress.ServiceexposeViaService()Expose a deployment via a service.ServiceexposeViaService(ExposeDeploymentViaServiceOptions options)Expose a deployment via a service.protected org.cdk8s.ApiObjectgetApiObject()The underlying cdk8s API object.List<Container>getContainers()The containers belonging to the pod.PodDnsgetDns()The pod's DNS settings.List<HostAlias>getHostAliases()An optional list of hosts and IPs that will be injected into the pod's hosts file if specified.List<Container>getInitContainers()The init containers belonging to the pod.Map<String,String>getLabelSelector()The labels this deployment will match against in order to select pods.org.cdk8s.ApiObjectMetadataDefinitiongetPodMetadata()Provides read/write access to the underlying pod metadata of the resource.NumbergetReplicas()Number of desired pods.RestartPolicygetRestartPolicy()Restart policy for all containers within the pod.PodSecurityContextgetSecurityContext()The pod's security context.IServiceAccountgetServiceAccount()The service account used to run this pod.DeploymentStrategygetStrategy()The upgrade strategy of this deployment.List<Volume>getVolumes()The volumes associated with this pod.voidselectByLabel(String key, String value)Configure a label selector to this deployment.-
Methods inherited from class org.cdk8s.plus20.Resource
getMetadata, getName
-
Methods inherited from class software.constructs.Construct
onPrepare, onSynthesize, onValidate, toString
-
Methods inherited from class software.amazon.jsii.JsiiObject
jsiiAsyncCall, jsiiAsyncCall, jsiiCall, jsiiCall, jsiiGet, jsiiGet, jsiiSet, jsiiStaticCall, jsiiStaticCall, jsiiStaticGet, jsiiStaticGet, jsiiStaticSet, jsiiStaticSet
-
-
-
-
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
-
addContainer
@Stability(Stable) @NotNull public Container addContainer(@NotNull ContainerProps cont)
Add a container to the pod.- Specified by:
addContainerin interfaceIPodSpec- Parameters:
cont- This parameter is required.
-
addHostAlias
@Stability(Stable) public void addHostAlias(@NotNull HostAlias hostAlias)- Parameters:
hostAlias- This parameter is required.
-
addInitContainer
@Stability(Stable) @NotNull public Container addInitContainer(@NotNull ContainerProps cont)
Add an init container to the pod.- Specified by:
addInitContainerin interfaceIPodSpec- Parameters:
cont- This parameter is required.
-
addVolume
@Stability(Stable) public void addVolume(@NotNull Volume vol)Add a volume to the pod.
-
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>.
-
selectByLabel
@Stability(Stable) public void selectByLabel(@NotNull String key, @NotNull String value)Configure a label selector to this deployment.Pods that have the label will be selected by deployments configured with this spec.
- Parameters:
key- - The label key. This parameter is required.value- - The label value. This parameter is required.
-
getApiObject
@Stability(Stable) @NotNull protected org.cdk8s.ApiObject getApiObject()
The underlying cdk8s API object.- Specified by:
getApiObjectin classResource- See Also:
base.Resource.apiObject
-
getContainers
@Stability(Stable) @NotNull public List<Container> getContainers()
The containers belonging to the pod.Use
addContainerto add containers.- Specified by:
getContainersin interfaceIPodSpec
-
getDns
@Stability(Stable) @NotNull public PodDns getDns()
The pod's DNS settings.
-
getHostAliases
@Stability(Stable) @NotNull public List<HostAlias> getHostAliases()
An optional list of hosts and IPs that will be injected into the pod's hosts file if specified.This is only valid for non-hostNetwork pods.
- Specified by:
getHostAliasesin interfaceIPodSpec
-
getInitContainers
@Stability(Stable) @NotNull public List<Container> getInitContainers()
The init containers belonging to the pod.Use
addInitContainerto add init containers.- Specified by:
getInitContainersin interfaceIPodSpec
-
getLabelSelector
@Stability(Stable) @NotNull public Map<String,String> getLabelSelector()
The labels this deployment will match against in order to select pods.Returns a a copy. Use
selectByLabel()to add labels.
-
getPodMetadata
@Stability(Stable) @NotNull public org.cdk8s.ApiObjectMetadataDefinition getPodMetadata()
Provides read/write access to the underlying pod metadata of the resource.- Specified by:
getPodMetadatain interfaceIPodTemplate
-
getReplicas
@Stability(Stable) @NotNull public Number getReplicas()
Number of desired pods.
-
getSecurityContext
@Stability(Stable) @NotNull public PodSecurityContext getSecurityContext()
The pod's security context.- Specified by:
getSecurityContextin interfaceIPodSpec
-
getStrategy
@Stability(Stable) @NotNull public DeploymentStrategy getStrategy()
The upgrade strategy of this deployment.
-
getVolumes
@Stability(Stable) @NotNull public List<Volume> getVolumes()
The volumes associated with this pod.Use
addVolumeto add volumes.- Specified by:
getVolumesin interfaceIPodSpec
-
getRestartPolicy
@Stability(Stable) @Nullable public RestartPolicy getRestartPolicy()
Restart policy for all containers within the pod.- Specified by:
getRestartPolicyin interfaceIPodSpec
-
getServiceAccount
@Stability(Stable) @Nullable public IServiceAccount getServiceAccount()
The service account used to run this pod.- Specified by:
getServiceAccountin interfaceIPodSpec
-
-