Class CronJob.Builder
- java.lang.Object
-
- org.cdk8s.plus24.CronJob.Builder
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description CronJob.Builder
activeDeadline(org.cdk8s.Duration activeDeadline)
Specifies the duration the job may be active before the system tries to terminate it.CronJob.Builder
automountServiceAccountToken(Boolean automountServiceAccountToken)
Indicates whether a service account token should be automatically mounted.CronJob.Builder
backoffLimit(Number backoffLimit)
Specifies the number of retries before marking this job failed.CronJob
build()
CronJob.Builder
concurrencyPolicy(ConcurrencyPolicy concurrencyPolicy)
Specifies the concurrency policy for the job.CronJob.Builder
containers(List<? extends ContainerProps> containers)
List of containers belonging to the pod.static CronJob.Builder
create(software.constructs.Construct scope, String id)
CronJob.Builder
dns(PodDnsProps dns)
DNS settings for the pod.CronJob.Builder
dockerRegistryAuth(ISecret dockerRegistryAuth)
A secret containing docker credentials for authenticating to a registry.CronJob.Builder
failedJobsRetained(Number failedJobsRetained)
Specifies the number of failed jobs history retained.CronJob.Builder
hostAliases(List<? extends HostAlias> hostAliases)
HostAlias holds the mapping between IP and hostnames that will be injected as an entry in the pod's hosts file.CronJob.Builder
hostNetwork(Boolean hostNetwork)
Host network for the pod.CronJob.Builder
initContainers(List<? extends ContainerProps> initContainers)
List of initialization containers belonging to the pod.CronJob.Builder
isolate(Boolean isolate)
Isolates the pod.CronJob.Builder
metadata(org.cdk8s.ApiObjectMetadata metadata)
Metadata that all persisted resources must have, which includes all objects users must create.CronJob.Builder
podMetadata(org.cdk8s.ApiObjectMetadata podMetadata)
The pod metadata of this workload.CronJob.Builder
restartPolicy(RestartPolicy restartPolicy)
Restart policy for all containers within the pod.CronJob.Builder
schedule(org.cdk8s.Cron schedule)
Specifies the time in which the job would run again.CronJob.Builder
securityContext(PodSecurityContextProps securityContext)
SecurityContext holds pod-level security attributes and common container settings.CronJob.Builder
select(Boolean select)
Automatically allocates a pod label selector for this workload and add it to the pod metadata.CronJob.Builder
serviceAccount(IServiceAccount serviceAccount)
A service account provides an identity for processes that run in a Pod.CronJob.Builder
spread(Boolean spread)
Automatically spread pods across hostname and zones.CronJob.Builder
startingDeadline(org.cdk8s.Duration startingDeadline)
Kubernetes attempts to start cron jobs at its schedule time, but this is not guaranteed.CronJob.Builder
successfulJobsRetained(Number successfulJobsRetained)
Specifies the number of successful jobs history retained.CronJob.Builder
suspend(Boolean suspend)
Specifies if the cron job should be suspended.CronJob.Builder
terminationGracePeriod(org.cdk8s.Duration terminationGracePeriod)
Grace period until the pod is terminated.CronJob.Builder
timeZone(String timeZone)
Specifies the timezone for the job.CronJob.Builder
ttlAfterFinished(org.cdk8s.Duration ttlAfterFinished)
Limits the lifetime of a Job that has finished execution (either Complete or Failed).CronJob.Builder
volumes(List<? extends Volume> volumes)
List of volumes that can be mounted by containers belonging to the pod.
-
-
-
Method Detail
-
create
@Stability(Stable) public static CronJob.Builder create(software.constructs.Construct scope, String id)
- Parameters:
scope
- This parameter is required.id
- This parameter is required.- Returns:
- a new instance of
CronJob.Builder
.
-
metadata
@Stability(Stable) public CronJob.Builder metadata(org.cdk8s.ApiObjectMetadata metadata)
Metadata that all persisted resources must have, which includes all objects users must create.- Parameters:
metadata
- Metadata that all persisted resources must have, which includes all objects users must create. This parameter is required.- Returns:
this
-
automountServiceAccountToken
@Stability(Stable) public CronJob.Builder automountServiceAccountToken(Boolean automountServiceAccountToken)
Indicates whether a service account token should be automatically mounted.Default: false
- Parameters:
automountServiceAccountToken
- Indicates whether a service account token should be automatically mounted. This parameter is required.- Returns:
this
- See Also:
- https://kubernetes.io/docs/tasks/configure-pod-container/configure-service-account/#use-the-default-service-account-to-access-the-api-server
-
containers
@Stability(Stable) public CronJob.Builder containers(List<? extends ContainerProps> containers)
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.
- Parameters:
containers
- List of containers belonging to the pod. This parameter is required.- Returns:
this
-
dns
@Stability(Stable) public CronJob.Builder dns(PodDnsProps dns)
DNS settings for the pod.Default: policy: DnsPolicy.CLUSTER_FIRST hostnameAsFQDN: false
- Parameters:
dns
- DNS settings for the pod. This parameter is required.- Returns:
this
- See Also:
- https://kubernetes.io/docs/concepts/services-networking/dns-pod-service/
-
dockerRegistryAuth
@Stability(Stable) public CronJob.Builder dockerRegistryAuth(ISecret dockerRegistryAuth)
A secret containing docker credentials for authenticating to a registry.Default: - No auth. Images are assumed to be publicly available.
- Parameters:
dockerRegistryAuth
- A secret containing docker credentials for authenticating to a registry. This parameter is required.- Returns:
this
-
hostAliases
@Stability(Stable) public CronJob.Builder hostAliases(List<? extends HostAlias> hostAliases)
HostAlias holds the mapping between IP and hostnames that will be injected as an entry in the pod's hosts file.- Parameters:
hostAliases
- HostAlias holds the mapping between IP and hostnames that will be injected as an entry in the pod's hosts file. This parameter is required.- Returns:
this
-
hostNetwork
@Stability(Stable) public CronJob.Builder hostNetwork(Boolean hostNetwork)
Host network for the pod.Default: false
- Parameters:
hostNetwork
- Host network for the pod. This parameter is required.- Returns:
this
-
initContainers
@Stability(Stable) public CronJob.Builder initContainers(List<? extends ContainerProps> initContainers)
List of initialization containers belonging to the pod.Init containers are executed in order prior to containers being started. If any init container fails, the pod is considered to have failed and is handled according to its restartPolicy. The name for an init container or normal container must be unique among all containers. Init containers may not have Lifecycle actions, Readiness probes, Liveness probes, or Startup probes. The resourceRequirements of an init container are taken into account during scheduling by finding the highest request/limit for each resource type, and then using the max of of that value or the sum of the normal containers. Limits are applied to init containers in a similar fashion.
Init containers cannot currently be added ,removed or updated.
Default: - No init containers.
- Parameters:
initContainers
- List of initialization containers belonging to the pod. This parameter is required.- Returns:
this
- See Also:
- https://kubernetes.io/docs/concepts/workloads/pods/init-containers/
-
isolate
@Stability(Stable) public CronJob.Builder isolate(Boolean isolate)
Isolates the pod.This will prevent any ingress or egress connections to / from this pod. You can however allow explicit connections post instantiation by using the
.connections
property.Default: false
- Parameters:
isolate
- Isolates the pod. This parameter is required.- Returns:
this
-
restartPolicy
@Stability(Stable) public CronJob.Builder restartPolicy(RestartPolicy restartPolicy)
Restart policy for all containers within the pod.Default: RestartPolicy.ALWAYS
- Parameters:
restartPolicy
- Restart policy for all containers within the pod. This parameter is required.- Returns:
this
- See Also:
- https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle/#restart-policy
-
securityContext
@Stability(Stable) public CronJob.Builder securityContext(PodSecurityContextProps securityContext)
SecurityContext holds pod-level security attributes and common container settings.Default: fsGroupChangePolicy: FsGroupChangePolicy.FsGroupChangePolicy.ALWAYS ensureNonRoot: true
- Parameters:
securityContext
- SecurityContext holds pod-level security attributes and common container settings. This parameter is required.- Returns:
this
-
serviceAccount
@Stability(Stable) public CronJob.Builder serviceAccount(IServiceAccount serviceAccount)
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.
- Parameters:
serviceAccount
- A service account provides an identity for processes that run in a Pod. This parameter is required.- Returns:
this
- See Also:
- https://kubernetes.io/docs/tasks/configure-pod-container/configure-service-account/
-
terminationGracePeriod
@Stability(Stable) public CronJob.Builder terminationGracePeriod(org.cdk8s.Duration terminationGracePeriod)
Grace period until the pod is terminated.Default: Duration.seconds(30)
- Parameters:
terminationGracePeriod
- Grace period until the pod is terminated. This parameter is required.- Returns:
this
-
volumes
@Stability(Stable) public CronJob.Builder volumes(List<? extends Volume> volumes)
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.
- Parameters:
volumes
- List of volumes that can be mounted by containers belonging to the pod. This parameter is required.- Returns:
this
- See Also:
- https://kubernetes.io/docs/concepts/storage/volumes
-
podMetadata
@Stability(Stable) public CronJob.Builder podMetadata(org.cdk8s.ApiObjectMetadata podMetadata)
The pod metadata of this workload.- Parameters:
podMetadata
- The pod metadata of this workload. This parameter is required.- Returns:
this
-
select
@Stability(Stable) public CronJob.Builder select(Boolean select)
Automatically allocates a pod label selector for this workload and add it to the pod metadata.This ensures this workload manages pods created by its pod template.
Default: true
- Parameters:
select
- Automatically allocates a pod label selector for this workload and add it to the pod metadata. This parameter is required.- Returns:
this
-
spread
@Stability(Stable) public CronJob.Builder spread(Boolean spread)
Automatically spread pods across hostname and zones.Default: false
- Parameters:
spread
- Automatically spread pods across hostname and zones. This parameter is required.- Returns:
this
- See Also:
- https://kubernetes.io/docs/concepts/scheduling-eviction/topology-spread-constraints/#internal-default-constraints
-
activeDeadline
@Stability(Stable) public CronJob.Builder activeDeadline(org.cdk8s.Duration activeDeadline)
Specifies the duration the job may be active before the system tries to terminate it.Default: - If unset, then there is no deadline.
- Parameters:
activeDeadline
- Specifies the duration the job may be active before the system tries to terminate it. This parameter is required.- Returns:
this
-
backoffLimit
@Stability(Stable) public CronJob.Builder backoffLimit(Number backoffLimit)
Specifies the number of retries before marking this job failed.Default: - If not set, system defaults to 6.
- Parameters:
backoffLimit
- Specifies the number of retries before marking this job failed. This parameter is required.- Returns:
this
-
ttlAfterFinished
@Stability(Stable) public CronJob.Builder ttlAfterFinished(org.cdk8s.Duration ttlAfterFinished)
Limits the lifetime of a Job that has finished execution (either Complete or Failed).If this field is set, after the Job finishes, it is eligible to be automatically deleted. When the Job is being deleted, its lifecycle guarantees (e.g. finalizers) will be honored. If this field is set to zero, the Job becomes eligible to be deleted immediately after it finishes. This field is alpha-level and is only honored by servers that enable the
TTLAfterFinished
feature.Default: - If this field is unset, the Job won't be automatically deleted.
- Parameters:
ttlAfterFinished
- Limits the lifetime of a Job that has finished execution (either Complete or Failed). This parameter is required.- Returns:
this
-
schedule
@Stability(Stable) public CronJob.Builder schedule(org.cdk8s.Cron schedule)
Specifies the time in which the job would run again.This is defined as a cron expression in the CronJob resource.
- Parameters:
schedule
- Specifies the time in which the job would run again. This parameter is required.- Returns:
this
-
concurrencyPolicy
@Stability(Stable) public CronJob.Builder concurrencyPolicy(ConcurrencyPolicy concurrencyPolicy)
Specifies the concurrency policy for the job.Default: ConcurrencyPolicy.Forbid
- Parameters:
concurrencyPolicy
- Specifies the concurrency policy for the job. This parameter is required.- Returns:
this
-
failedJobsRetained
@Stability(Stable) public CronJob.Builder failedJobsRetained(Number failedJobsRetained)
Specifies the number of failed jobs history retained.This would retain the Job and the associated Pod resource and can be useful for debugging.
Default: 1
- Parameters:
failedJobsRetained
- Specifies the number of failed jobs history retained. This parameter is required.- Returns:
this
-
startingDeadline
@Stability(Stable) public CronJob.Builder startingDeadline(org.cdk8s.Duration startingDeadline)
Kubernetes attempts to start cron jobs at its schedule time, but this is not guaranteed.This deadline specifies how much time can pass after a schedule point, for which kubernetes can still start the job. For example, if this is set to 100 seconds, kubernetes is allowed to start the job at a maximum 100 seconds after the scheduled time.
Note that the Kubernetes CronJobController checks for things every 10 seconds, for this reason, a deadline below 10 seconds is not allowed, as it may cause your job to never be scheduled.
In addition, kubernetes will stop scheduling jobs if more than 100 schedules were missed (for any reason). This property also controls what time interval should kubernetes consider when counting for missed schedules.
For example, suppose a CronJob is set to schedule a new Job every one minute beginning at 08:30:00, and its
startingDeadline
field is not set. If the CronJob controller happens to be down from 08:29:00 to 10:21:00, the job will not start as the number of missed jobs which missed their schedule is greater than 100. However, ifstartingDeadline
is set to 200 seconds, kubernetes will only count 3 missed schedules, and thus start a new execution at 10:22:00.Default: Duration.seconds(10)
- Parameters:
startingDeadline
- Kubernetes attempts to start cron jobs at its schedule time, but this is not guaranteed. This parameter is required.- Returns:
this
-
successfulJobsRetained
@Stability(Stable) public CronJob.Builder successfulJobsRetained(Number successfulJobsRetained)
Specifies the number of successful jobs history retained.This would retain the Job and the associated Pod resource and can be useful for debugging.
Default: 3
- Parameters:
successfulJobsRetained
- Specifies the number of successful jobs history retained. This parameter is required.- Returns:
this
-
suspend
@Stability(Stable) public CronJob.Builder suspend(Boolean suspend)
Specifies if the cron job should be suspended.Only applies to future executions, current ones are remained untouched.
Default: false
- Parameters:
suspend
- Specifies if the cron job should be suspended. This parameter is required.- Returns:
this
-
timeZone
@Stability(Stable) public CronJob.Builder timeZone(String timeZone)
Specifies the timezone for the job.This helps aligining the schedule to follow the specified timezone.
Default: - Timezone of kube-controller-manager process.
- Parameters:
timeZone
- Specifies the timezone for the job. This parameter is required.- Returns:
this
- See Also:
- {@link https://en.wikipedia.org/wiki/List_of_tz_database_time_zones} for list of valid timezone values.
-
-