Class StatefulSet
- java.lang.Object
-
- software.amazon.jsii.JsiiObject
-
- software.constructs.Construct
-
- org.cdk8s.plus22.Resource
-
- org.cdk8s.plus22.StatefulSet
-
- All Implemented Interfaces:
IPodSpec,IPodTemplate,IResource,software.amazon.jsii.JsiiSerializable,software.constructs.IConstruct
@Generated(value="jsii-pacmak/1.52.1 (build 5ccc8f6)", date="2022-02-08T00:13:45.315Z") @Stability(Stable) public class StatefulSet extends Resource implements IPodTemplate
StatefulSet is the workload API object used to manage stateful applications.Manages the deployment and scaling of a set of Pods, and provides guarantees about the ordering and uniqueness of these Pods.
Like a Deployment, a StatefulSet manages Pods that are based on an identical container spec. Unlike a Deployment, a StatefulSet maintains a sticky identity for each of their Pods. These pods are created from the same spec, but are not interchangeable: each has a persistent identifier that it maintains across any rescheduling.
If you want to use storage volumes to provide persistence for your workload, you can use a StatefulSet as part of the solution. Although individual Pods in a StatefulSet are susceptible to failure, the persistent Pod identifiers make it easier to match existing volumes to the new Pods that replace any that have failed.
Using StatefulSets
StatefulSets are valuable for applications that require one or more of the following.
- Stable, unique network identifiers.
- Stable, persistent storage.
- Ordered, graceful deployment and scaling.
- Ordered, automated rolling updates.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classStatefulSet.BuilderA fluent builder forStatefulSet.-
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.plus22.IPodTemplate
IPodTemplate.Jsii$Default, IPodTemplate.Jsii$Proxy
-
Nested classes/interfaces inherited from interface org.cdk8s.plus22.IResource
IResource.Jsii$Default
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedStatefulSet(software.amazon.jsii.JsiiObject.InitializationMode initializationMode)protectedStatefulSet(software.amazon.jsii.JsiiObjectRef objRef)StatefulSet(software.constructs.Construct scope, String id, StatefulSetProps props)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ContaineraddContainer(ContainerProps container)Add a container to the pod.voidaddVolume(Volume volume)Add a volume to the pod.protected org.cdk8s.ApiObjectgetApiObject()The underlying cdk8s API object.List<Container>getContainers()The containers belonging to the pod.Map<String,String>getLabelSelector()The labels this statefulset will match against in order to select pods.PodManagementPolicygetPodManagementPolicy()Management policy to use for the set.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.IServiceAccountgetServiceAccount()The service account used to run this pod.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.plus22.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
-
StatefulSet
protected StatefulSet(software.amazon.jsii.JsiiObjectRef objRef)
-
StatefulSet
protected StatefulSet(software.amazon.jsii.JsiiObject.InitializationMode initializationMode)
-
StatefulSet
@Stability(Stable) public StatefulSet(@NotNull software.constructs.Construct scope, @NotNull String id, @NotNull StatefulSetProps props)- Parameters:
scope- This parameter is required.id- This parameter is required.props- This parameter is required.
-
-
Method Detail
-
addContainer
@Stability(Stable) @NotNull public Container addContainer(@NotNull ContainerProps container)
Add a container to the pod.- Specified by:
addContainerin interfaceIPodSpec- Parameters:
container- This parameter is required.
-
addVolume
@Stability(Stable) public void addVolume(@NotNull Volume volume)Add a volume to the pod.
-
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
-
getLabelSelector
@Stability(Stable) @NotNull public Map<String,String> getLabelSelector()
The labels this statefulset will match against in order to select pods.Returns a a copy. Use
selectByLabel()to add labels.
-
getPodManagementPolicy
@Stability(Stable) @NotNull public PodManagementPolicy getPodManagementPolicy()
Management policy to use for the set.
-
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.
-
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
-
-