Skip to content

cdk8s (Java)

Constructs

ApiObject

Initializers

import org.cdk8s.ApiObject;

ApiObject.Builder.create(Construct scope, java.lang.String id)
    .apiVersion(java.lang.String)
    .kind(java.lang.String)
//  .metadata(ApiObjectMetadata)
    .build();
scopeRequired

the construct scope.


idRequired
  • Type: java.lang.String

namespace.


apiVersionRequired
  • Type: java.lang.String

API version.


kindRequired
  • Type: java.lang.String

Resource kind.


metadataOptional

Object metadata.

If name is not specified, an app-unique name will be allocated by the framework based on the path of the construct within thes construct tree.


Methods

addDependency
public addDependency(IConstruct dependencies)
dependenciesRequired

the dependencies to add.


addJsonPatch
public addJsonPatch(JsonPatch ops)
opsRequired

The JSON-Patch operations to apply.


toJson
public toJson()

Static Functions

isApiObject
import org.cdk8s.ApiObject;

ApiObject.isApiObject(java.lang.Object o)
oRequired
  • Type: java.lang.Object

The object to check.


of
import org.cdk8s.ApiObject;

ApiObject.of(IConstruct c)
cRequired

The higher-level construct.


Properties

apiGroupRequired
public java.lang.String getApiGroup();
  • Type: java.lang.String

The group portion of the API version (e.g. authorization.k8s.io).


apiVersionRequired
public java.lang.String getApiVersion();
  • Type: java.lang.String

The object’s API version (e.g. authorization.k8s.io/v1).


chartRequired
public Chart getChart();

The chart in which this object is defined.


kindRequired
public java.lang.String getKind();
  • Type: java.lang.String

The object kind.


metadataRequired
public ApiObjectMetadataDefinition getMetadata();

Metadata associated with this API object.


nameRequired
public java.lang.String getName();
  • Type: java.lang.String

The name of the API object.

If a name is specified in metadata.name this will be the name returned. Otherwise, a name will be generated by calling Chart.of(this).generatedObjectName(this), which by default uses the construct path to generate a DNS-compatible name for the resource.


App

Represents a cdk8s application.

Initializers

import org.cdk8s.App;

App.Builder.create()
//  .outdir(java.lang.String)
//  .outputFileExtension(java.lang.String)
//  .recordConstructMetadata(java.lang.Boolean)
//  .resolvers(java.util.List<IResolver>)
//  .yamlOutputType(YamlOutputType)
    .build();
outdirOptional
  • Type: java.lang.String
  • Default: CDK8S_OUTDIR if defined, otherwise “dist”

The directory to output Kubernetes manifests.

If you synthesize your application using cdk8s synth, you must also pass this value to the CLI using the --output option or the output property in the cdk8s.yaml configuration file. Otherwise, the CLI will not know about the output directory, and synthesis will fail.

This property is intended for internal and testing use.


outputFileExtensionOptional
  • Type: java.lang.String
  • Default: .k8s.yaml

The file extension to use for rendered YAML files.


recordConstructMetadataOptional
  • Type: java.lang.Boolean
  • Default: false

When set to true, the output directory will contain a construct-metadata.json file that holds construct related metadata on every resource in the app.


resolversOptional

A list of resolvers that can be used to replace property values before they are written to the manifest file.

When multiple resolvers are passed, they are invoked by order in the list, and only the first one that applies (e.g calls context.replaceValue) is invoked.

https://cdk8s.io/docs/latest/basics/app/#resolvers


yamlOutputTypeOptional

How to divide the YAML output into files.


Methods

synth
public synth()
synthYaml
public synthYaml()

Static Functions

of
import org.cdk8s.App;

App.of(IConstruct c)
cRequired

Properties

chartsRequired
public java.util.List<Chart> getCharts();

Returns all the charts in this app, sorted topologically.


outdirRequired
public java.lang.String getOutdir();
  • Type: java.lang.String

The output directory into which manifests will be synthesized.


outputFileExtensionRequired
public java.lang.String getOutputFileExtension();
  • Type: java.lang.String
  • Default: .k8s.yaml

The file extension to use for rendered YAML files.


resolversRequired
public java.util.List<IResolver> getResolvers();

Resolvers used by this app.

This includes both custom resolvers passed by the resolvers property, as well as built-in resolvers.


yamlOutputTypeRequired
public YamlOutputType getYamlOutputType();

How to divide the YAML output into files.


Chart

Initializers

import org.cdk8s.Chart;

Chart.Builder.create(Construct scope, java.lang.String id)
//  .disableResourceNameHashes(java.lang.Boolean)
//  .labels(java.util.Map<java.lang.String, java.lang.String>)
//  .namespace(java.lang.String)
    .build();
scopeRequired

idRequired
  • Type: java.lang.String

disableResourceNameHashesOptional
  • Type: java.lang.Boolean
  • Default: false

The autogenerated resource name by default is suffixed with a stable hash of the construct path.

Setting this property to true drops the hash suffix.


labelsOptional
  • Type: java.util.Mapjava.lang.String>
  • Default: no common labels

Labels to apply to all resources in this chart.


namespaceOptional
  • Type: java.lang.String
  • Default: no namespace is synthesized (usually this implies “default”)

The default namespace for all objects defined in this chart (directly or indirectly).

This namespace will only apply to objects that don’t have a namespace explicitly defined for them.


Methods

addDependency
public addDependency(IConstruct dependencies)
dependenciesRequired

the dependencies to add.


generateObjectName
public generateObjectName(ApiObject apiObject)
apiObjectRequired

The API object to generate a name for.


toJson
public toJson()

Static Functions

isChart
import org.cdk8s.Chart;

Chart.isChart(java.lang.Object x)
xRequired
  • Type: java.lang.Object

of
import org.cdk8s.Chart;

Chart.of(IConstruct c)
cRequired

a construct node.


Properties

apiObjectsRequired
public java.util.List<ApiObject> getApiObjects();

Returns all the included API objects.


labelsRequired
public java.util.Map<java.lang.String, java.lang.String> getLabels();
  • Type: java.util.Mapjava.lang.String>

Labels applied to all resources in this chart.

This is an immutable copy.


namespaceOptional
public java.lang.String getNamespace();
  • Type: java.lang.String

The default namespace for all objects in this chart.


Helm

Represents a Helm deployment.

Use this construct to import an existing Helm chart and incorporate it into your constructs.

Initializers

import org.cdk8s.Helm;

Helm.Builder.create(Construct scope, java.lang.String id)
    .chart(java.lang.String)
//  .helmExecutable(java.lang.String)
//  .helmFlags(java.util.List<java.lang.String>)
//  .namespace(java.lang.String)
//  .releaseName(java.lang.String)
//  .repo(java.lang.String)
//  .values(java.util.Map<java.lang.String, java.lang.Object>)
//  .version(java.lang.String)
    .build();
scopeRequired

idRequired
  • Type: java.lang.String

chartRequired
  • Type: java.lang.String

The chart name to use. It can be a chart from a helm repository or a local directory.

This name is passed to helm template and has all the relevant semantics.


helmExecutableOptional
  • Type: java.lang.String
  • Default: “helm”

The local helm executable to use in order to create the manifest the chart.


helmFlagsOptional
  • Type: java.util.List<java.lang.String>
  • Default: []

Additional flags to add to the helm execution.


namespaceOptional
  • Type: java.lang.String

Scope all resources in to a given namespace.


releaseNameOptional
  • Type: java.lang.String
  • Default: if unspecified, a name will be allocated based on the construct path

The release name.

https://helm.sh/docs/intro/using_helm/#three-big-concepts


repoOptional
  • Type: java.lang.String

Chart repository url where to locate the requested chart.


valuesOptional
  • Type: java.util.Mapjava.lang.Object>
  • Default: If no values are specified, chart will use the defaults.

Values to pass to the chart.


versionOptional
  • Type: java.lang.String

Version constraint for the chart version to use.

This constraint can be a specific tag (e.g. 1.1.1) or it may reference a valid range (e.g. ^2.0.0). If this is not specified, the latest version is used

This name is passed to helm template --version and has all the relevant semantics.


Properties

releaseNameRequired
public java.lang.String getReleaseName();
  • Type: java.lang.String

The helm release name.


Include

Reads a YAML manifest from a file or a URL and defines all resources as API objects within the defined scope.

The names (metadata.name) of imported resources will be preserved as-is from the manifest.

Initializers

import org.cdk8s.Include;

Include.Builder.create(Construct scope, java.lang.String id)
    .url(java.lang.String)
    .build();
scopeRequired

idRequired
  • Type: java.lang.String

urlRequired
  • Type: java.lang.String

Local file path or URL which includes a Kubernetes YAML manifest.


Properties

apiObjectsRequired
public java.util.List<ApiObject> getApiObjects();

Returns all the included API objects.


Structs

ApiObjectMetadata

Metadata associated with this object.

Initializer

import org.cdk8s.ApiObjectMetadata;

ApiObjectMetadata.builder()
//  .annotations(java.util.Map<java.lang.String, java.lang.String>)
//  .finalizers(java.util.List<java.lang.String>)
//  .labels(java.util.Map<java.lang.String, java.lang.String>)
//  .name(java.lang.String)
//  .namespace(java.lang.String)
//  .ownerReferences(java.util.List<OwnerReference>)
    .build();
annotationsOptional
public java.util.Map<java.lang.String, java.lang.String> getAnnotations();
  • Type: java.util.Mapjava.lang.String>
  • Default: No annotations.

Annotations is an unstructured key value map stored with a resource that may be set by external tools to store and retrieve arbitrary metadata.

They are not queryable and should be preserved when modifying objects.

http://kubernetes.io/docs/user-guide/annotations


finalizersOptional
public java.util.List<java.lang.String> getFinalizers();
  • Type: java.util.List<java.lang.String>
  • Default: No finalizers.

Namespaced keys that tell Kubernetes to wait until specific conditions are met before it fully deletes resources marked for deletion.

Must be empty before the object is deleted from the registry. Each entry is an identifier for the responsible component that will remove the entry from the list. If the deletionTimestamp of the object is non-nil, entries in this list can only be removed. Finalizers may be processed and removed in any order. Order is NOT enforced because it introduces significant risk of stuck finalizers. finalizers is a shared field, any actor with permission can reorder it. If the finalizer list is processed in order, then this can lead to a situation in which the component responsible for the first finalizer in the list is waiting for a signal (field value, external system, or other) produced by a component responsible for a finalizer later in the list, resulting in a deadlock. Without enforced ordering finalizers are free to order amongst themselves and are not vulnerable to ordering changes in the list.

https://kubernetes.io/docs/concepts/overview/working-with-objects/finalizers/


labelsOptional
public java.util.Map<java.lang.String, java.lang.String> getLabels();
  • Type: java.util.Mapjava.lang.String>
  • Default: No labels.

Map of string keys and values that can be used to organize and categorize (scope and select) objects.

May match selectors of replication controllers and services.

http://kubernetes.io/docs/user-guide/labels


nameOptional
public java.lang.String getName();
  • Type: java.lang.String
  • Default: an app-unique name generated by the chart

The unique, namespace-global, name of this object inside the Kubernetes cluster.

Normally, you shouldn’t specify names for objects and let the CDK generate a name for you that is application-unique. The names CDK generates are composed from the construct path components, separated by dots and a suffix that is based on a hash of the entire path, to ensure uniqueness.

You can supply custom name allocation logic by overriding the chart.generateObjectName method.

If you use an explicit name here, bear in mind that this reduces the composability of your construct because it won’t be possible to include more than one instance in any app. Therefore it is highly recommended to leave this unspecified.


namespaceOptional
public java.lang.String getNamespace();
  • Type: java.lang.String
  • Default: undefined (will be assigned to the ‘default’ namespace)

Namespace defines the space within each name must be unique.

An empty namespace is equivalent to the “default” namespace, but “default” is the canonical representation. Not all objects are required to be scoped to a namespace - the value of this field for those objects will be empty. Must be a DNS_LABEL. Cannot be updated. More info: http://kubernetes.io/docs/user-guide/namespaces


ownerReferencesOptional
public java.util.List<OwnerReference> getOwnerReferences();

List of objects depended by this object.

If ALL objects in the list have been deleted, this object will be garbage collected. If this object is managed by a controller, then an entry in this list will point to this controller, with the controller field set to true. There cannot be more than one managing controller.

Kubernetes sets the value of this field automatically for objects that are dependents of other objects like ReplicaSets, DaemonSets, Deployments, Jobs and CronJobs, and ReplicationControllers. You can also configure these relationships manually by changing the value of this field. However, you usually don’t need to and can allow Kubernetes to automatically manage the relationships.

https://kubernetes.io/docs/concepts/overview/working-with-objects/owners-dependents/


ApiObjectMetadataDefinitionOptions

Options for ApiObjectMetadataDefinition.

Initializer

import org.cdk8s.ApiObjectMetadataDefinitionOptions;

ApiObjectMetadataDefinitionOptions.builder()
//  .annotations(java.util.Map<java.lang.String, java.lang.String>)
//  .finalizers(java.util.List<java.lang.String>)
//  .labels(java.util.Map<java.lang.String, java.lang.String>)
//  .name(java.lang.String)
//  .namespace(java.lang.String)
//  .ownerReferences(java.util.List<OwnerReference>)
    .apiObject(ApiObject)
    .build();
annotationsOptional
public java.util.Map<java.lang.String, java.lang.String> getAnnotations();
  • Type: java.util.Mapjava.lang.String>
  • Default: No annotations.

Annotations is an unstructured key value map stored with a resource that may be set by external tools to store and retrieve arbitrary metadata.

They are not queryable and should be preserved when modifying objects.

http://kubernetes.io/docs/user-guide/annotations


finalizersOptional
public java.util.List<java.lang.String> getFinalizers();
  • Type: java.util.List<java.lang.String>
  • Default: No finalizers.

Namespaced keys that tell Kubernetes to wait until specific conditions are met before it fully deletes resources marked for deletion.

Must be empty before the object is deleted from the registry. Each entry is an identifier for the responsible component that will remove the entry from the list. If the deletionTimestamp of the object is non-nil, entries in this list can only be removed. Finalizers may be processed and removed in any order. Order is NOT enforced because it introduces significant risk of stuck finalizers. finalizers is a shared field, any actor with permission can reorder it. If the finalizer list is processed in order, then this can lead to a situation in which the component responsible for the first finalizer in the list is waiting for a signal (field value, external system, or other) produced by a component responsible for a finalizer later in the list, resulting in a deadlock. Without enforced ordering finalizers are free to order amongst themselves and are not vulnerable to ordering changes in the list.

https://kubernetes.io/docs/concepts/overview/working-with-objects/finalizers/


labelsOptional
public java.util.Map<java.lang.String, java.lang.String> getLabels();
  • Type: java.util.Mapjava.lang.String>
  • Default: No labels.

Map of string keys and values that can be used to organize and categorize (scope and select) objects.

May match selectors of replication controllers and services.

http://kubernetes.io/docs/user-guide/labels


nameOptional
public java.lang.String getName();
  • Type: java.lang.String
  • Default: an app-unique name generated by the chart

The unique, namespace-global, name of this object inside the Kubernetes cluster.

Normally, you shouldn’t specify names for objects and let the CDK generate a name for you that is application-unique. The names CDK generates are composed from the construct path components, separated by dots and a suffix that is based on a hash of the entire path, to ensure uniqueness.

You can supply custom name allocation logic by overriding the chart.generateObjectName method.

If you use an explicit name here, bear in mind that this reduces the composability of your construct because it won’t be possible to include more than one instance in any app. Therefore it is highly recommended to leave this unspecified.


namespaceOptional
public java.lang.String getNamespace();
  • Type: java.lang.String
  • Default: undefined (will be assigned to the ‘default’ namespace)

Namespace defines the space within each name must be unique.

An empty namespace is equivalent to the “default” namespace, but “default” is the canonical representation. Not all objects are required to be scoped to a namespace - the value of this field for those objects will be empty. Must be a DNS_LABEL. Cannot be updated. More info: http://kubernetes.io/docs/user-guide/namespaces


ownerReferencesOptional
public java.util.List<OwnerReference> getOwnerReferences();

List of objects depended by this object.

If ALL objects in the list have been deleted, this object will be garbage collected. If this object is managed by a controller, then an entry in this list will point to this controller, with the controller field set to true. There cannot be more than one managing controller.

Kubernetes sets the value of this field automatically for objects that are dependents of other objects like ReplicaSets, DaemonSets, Deployments, Jobs and CronJobs, and ReplicationControllers. You can also configure these relationships manually by changing the value of this field. However, you usually don’t need to and can allow Kubernetes to automatically manage the relationships.

https://kubernetes.io/docs/concepts/overview/working-with-objects/owners-dependents/


apiObjectRequired
public ApiObject getApiObject();

Which ApiObject instance is the metadata attached to.


ApiObjectProps

Options for defining API objects.

Initializer

import org.cdk8s.ApiObjectProps;

ApiObjectProps.builder()
    .apiVersion(java.lang.String)
    .kind(java.lang.String)
//  .metadata(ApiObjectMetadata)
    .build();
apiVersionRequired
public java.lang.String getApiVersion();
  • Type: java.lang.String

API version.


kindRequired
public java.lang.String getKind();
  • Type: java.lang.String

Resource kind.


metadataOptional
public ApiObjectMetadata getMetadata();

Object metadata.

If name is not specified, an app-unique name will be allocated by the framework based on the path of the construct within thes construct tree.


AppProps

Initializer

import org.cdk8s.AppProps;

AppProps.builder()
//  .outdir(java.lang.String)
//  .outputFileExtension(java.lang.String)
//  .recordConstructMetadata(java.lang.Boolean)
//  .resolvers(java.util.List<IResolver>)
//  .yamlOutputType(YamlOutputType)
    .build();
outdirOptional
public java.lang.String getOutdir();
  • Type: java.lang.String
  • Default: CDK8S_OUTDIR if defined, otherwise “dist”

The directory to output Kubernetes manifests.

If you synthesize your application using cdk8s synth, you must also pass this value to the CLI using the --output option or the output property in the cdk8s.yaml configuration file. Otherwise, the CLI will not know about the output directory, and synthesis will fail.

This property is intended for internal and testing use.


outputFileExtensionOptional
public java.lang.String getOutputFileExtension();
  • Type: java.lang.String
  • Default: .k8s.yaml

The file extension to use for rendered YAML files.


recordConstructMetadataOptional
public java.lang.Boolean getRecordConstructMetadata();
  • Type: java.lang.Boolean
  • Default: false

When set to true, the output directory will contain a construct-metadata.json file that holds construct related metadata on every resource in the app.


resolversOptional
public java.util.List<IResolver> getResolvers();

A list of resolvers that can be used to replace property values before they are written to the manifest file.

When multiple resolvers are passed, they are invoked by order in the list, and only the first one that applies (e.g calls context.replaceValue) is invoked.

https://cdk8s.io/docs/latest/basics/app/#resolvers


yamlOutputTypeOptional
public YamlOutputType getYamlOutputType();

How to divide the YAML output into files.


ChartProps

Initializer

import org.cdk8s.ChartProps;

ChartProps.builder()
//  .disableResourceNameHashes(java.lang.Boolean)
//  .labels(java.util.Map<java.lang.String, java.lang.String>)
//  .namespace(java.lang.String)
    .build();
disableResourceNameHashesOptional
public java.lang.Boolean getDisableResourceNameHashes();
  • Type: java.lang.Boolean
  • Default: false

The autogenerated resource name by default is suffixed with a stable hash of the construct path.

Setting this property to true drops the hash suffix.


labelsOptional
public java.util.Map<java.lang.String, java.lang.String> getLabels();
  • Type: java.util.Mapjava.lang.String>
  • Default: no common labels

Labels to apply to all resources in this chart.


namespaceOptional
public java.lang.String getNamespace();
  • Type: java.lang.String
  • Default: no namespace is synthesized (usually this implies “default”)

The default namespace for all objects defined in this chart (directly or indirectly).

This namespace will only apply to objects that don’t have a namespace explicitly defined for them.


CronOptions

Options to configure a cron expression.

All fields are strings so you can use complex expressions. Absence of a field implies ‘*’

Initializer

import org.cdk8s.CronOptions;

CronOptions.builder()
//  .day(java.lang.String)
//  .hour(java.lang.String)
//  .minute(java.lang.String)
//  .month(java.lang.String)
//  .weekDay(java.lang.String)
    .build();
dayOptional
public java.lang.String getDay();
  • Type: java.lang.String
  • Default: Every day of the month

The day of the month to run this rule at.


hourOptional
public java.lang.String getHour();
  • Type: java.lang.String
  • Default: Every hour

The hour to run this rule at.


minuteOptional
public java.lang.String getMinute();
  • Type: java.lang.String
  • Default: Every minute

The minute to run this rule at.


monthOptional
public java.lang.String getMonth();
  • Type: java.lang.String
  • Default: Every month

The month to run this rule at.


weekDayOptional
public java.lang.String getWeekDay();
  • Type: java.lang.String
  • Default: Any day of the week

The day of the week to run this rule at.


GroupVersionKind

Initializer

import org.cdk8s.GroupVersionKind;

GroupVersionKind.builder()
    .apiVersion(java.lang.String)
    .kind(java.lang.String)
    .build();
apiVersionRequired
public java.lang.String getApiVersion();
  • Type: java.lang.String

The object’s API version (e.g. authorization.k8s.io/v1).


kindRequired
public java.lang.String getKind();
  • Type: java.lang.String

The object kind.


HelmProps

Options for Helm.

Initializer

import org.cdk8s.HelmProps;

HelmProps.builder()
    .chart(java.lang.String)
//  .helmExecutable(java.lang.String)
//  .helmFlags(java.util.List<java.lang.String>)
//  .namespace(java.lang.String)
//  .releaseName(java.lang.String)
//  .repo(java.lang.String)
//  .values(java.util.Map<java.lang.String, java.lang.Object>)
//  .version(java.lang.String)
    .build();
chartRequired
public java.lang.String getChart();
  • Type: java.lang.String

The chart name to use. It can be a chart from a helm repository or a local directory.

This name is passed to helm template and has all the relevant semantics.


helmExecutableOptional
public java.lang.String getHelmExecutable();
  • Type: java.lang.String
  • Default: “helm”

The local helm executable to use in order to create the manifest the chart.


helmFlagsOptional
public java.util.List<java.lang.String> getHelmFlags();
  • Type: java.util.List<java.lang.String>
  • Default: []

Additional flags to add to the helm execution.


namespaceOptional
public java.lang.String getNamespace();
  • Type: java.lang.String

Scope all resources in to a given namespace.


releaseNameOptional
public java.lang.String getReleaseName();
  • Type: java.lang.String
  • Default: if unspecified, a name will be allocated based on the construct path

The release name.

https://helm.sh/docs/intro/using_helm/#three-big-concepts


repoOptional
public java.lang.String getRepo();
  • Type: java.lang.String

Chart repository url where to locate the requested chart.


valuesOptional
public java.util.Map<java.lang.String, java.lang.Object> getValues();
  • Type: java.util.Mapjava.lang.Object>
  • Default: If no values are specified, chart will use the defaults.

Values to pass to the chart.


versionOptional
public java.lang.String getVersion();
  • Type: java.lang.String

Version constraint for the chart version to use.

This constraint can be a specific tag (e.g. 1.1.1) or it may reference a valid range (e.g. ^2.0.0). If this is not specified, the latest version is used

This name is passed to helm template --version and has all the relevant semantics.


IncludeProps

Initializer

import org.cdk8s.IncludeProps;

IncludeProps.builder()
    .url(java.lang.String)
    .build();
urlRequired
public java.lang.String getUrl();
  • Type: java.lang.String

Local file path or URL which includes a Kubernetes YAML manifest.


NameOptions

Options for name generation.

Initializer

import org.cdk8s.NameOptions;

NameOptions.builder()
//  .delimiter(java.lang.String)
//  .extra(java.util.List<java.lang.String>)
//  .includeHash(java.lang.Boolean)
//  .maxLen(java.lang.Number)
    .build();
delimiterOptional
public java.lang.String getDelimiter();
  • Type: java.lang.String
  • Default: “-“

Delimiter to use between components.


extraOptional
public java.util.List<java.lang.String> getExtra();
  • Type: java.util.List<java.lang.String>
  • Default: [] use the construct path components

Extra components to include in the name.


includeHashOptional
public java.lang.Boolean getIncludeHash();
  • Type: java.lang.Boolean
  • Default: true

Include a short hash as last part of the name.


maxLenOptional
public java.lang.Number getMaxLen();
  • Type: java.lang.Number
  • Default: 63

Maximum allowed length for the name.


OwnerReference

OwnerReference contains enough information to let you identify an owning object.

An owning object must be in the same namespace as the dependent, or be cluster-scoped, so there is no namespace field.

Initializer

import org.cdk8s.OwnerReference;

OwnerReference.builder()
    .apiVersion(java.lang.String)
    .kind(java.lang.String)
    .name(java.lang.String)
    .uid(java.lang.String)
//  .blockOwnerDeletion(java.lang.Boolean)
//  .controller(java.lang.Boolean)
    .build();
apiVersionRequired
public java.lang.String getApiVersion();
  • Type: java.lang.String

API version of the referent.


kindRequired
public java.lang.String getKind();
  • Type: java.lang.String

Kind of the referent.

https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds


nameRequired
public java.lang.String getName();
  • Type: java.lang.String

Name of the referent.

http://kubernetes.io/docs/user-guide/identifiers#names


uidRequired
public java.lang.String getUid();
  • Type: java.lang.String

UID of the referent.

http://kubernetes.io/docs/user-guide/identifiers#uids


blockOwnerDeletionOptional
public java.lang.Boolean getBlockOwnerDeletion();
  • Type: java.lang.Boolean
  • Default: false. To set this field, a user needs “delete” permission of the owner, otherwise 422 (Unprocessable Entity) will be returned.

If true, AND if the owner has the “foregroundDeletion” finalizer, then the owner cannot be deleted from the key-value store until this reference is removed.

Defaults to false. To set this field, a user needs “delete” permission of the owner, otherwise 422 (Unprocessable Entity) will be returned.


controllerOptional
public java.lang.Boolean getController();
  • Type: java.lang.Boolean

If true, this reference points to the managing controller.


SizeConversionOptions

Options for how to convert time to a different unit.

Initializer

import org.cdk8s.SizeConversionOptions;

SizeConversionOptions.builder()
//  .rounding(SizeRoundingBehavior)
    .build();
roundingOptional
public SizeRoundingBehavior getRounding();

How conversions should behave when it encounters a non-integer result.


TimeConversionOptions

Options for how to convert time to a different unit.

Initializer

import org.cdk8s.TimeConversionOptions;

TimeConversionOptions.builder()
//  .integral(java.lang.Boolean)
    .build();
integralOptional
public java.lang.Boolean getIntegral();
  • Type: java.lang.Boolean
  • Default: true

If true, conversions into a larger time unit (e.g. Seconds to Minutes) will fail if the result is not an integer.


Classes

ApiObjectMetadataDefinition

Object metadata.

Initializers

import org.cdk8s.ApiObjectMetadataDefinition;

ApiObjectMetadataDefinition.Builder.create()
//  .annotations(java.util.Map<java.lang.String, java.lang.String>)
//  .finalizers(java.util.List<java.lang.String>)
//  .labels(java.util.Map<java.lang.String, java.lang.String>)
//  .name(java.lang.String)
//  .namespace(java.lang.String)
//  .ownerReferences(java.util.List<OwnerReference>)
    .apiObject(ApiObject)
    .build();
annotationsOptional
  • Type: java.util.Mapjava.lang.String>
  • Default: No annotations.

Annotations is an unstructured key value map stored with a resource that may be set by external tools to store and retrieve arbitrary metadata.

They are not queryable and should be preserved when modifying objects.

http://kubernetes.io/docs/user-guide/annotations


finalizersOptional
  • Type: java.util.List<java.lang.String>
  • Default: No finalizers.

Namespaced keys that tell Kubernetes to wait until specific conditions are met before it fully deletes resources marked for deletion.

Must be empty before the object is deleted from the registry. Each entry is an identifier for the responsible component that will remove the entry from the list. If the deletionTimestamp of the object is non-nil, entries in this list can only be removed. Finalizers may be processed and removed in any order. Order is NOT enforced because it introduces significant risk of stuck finalizers. finalizers is a shared field, any actor with permission can reorder it. If the finalizer list is processed in order, then this can lead to a situation in which the component responsible for the first finalizer in the list is waiting for a signal (field value, external system, or other) produced by a component responsible for a finalizer later in the list, resulting in a deadlock. Without enforced ordering finalizers are free to order amongst themselves and are not vulnerable to ordering changes in the list.

https://kubernetes.io/docs/concepts/overview/working-with-objects/finalizers/


labelsOptional
  • Type: java.util.Mapjava.lang.String>
  • Default: No labels.

Map of string keys and values that can be used to organize and categorize (scope and select) objects.

May match selectors of replication controllers and services.

http://kubernetes.io/docs/user-guide/labels


nameOptional
  • Type: java.lang.String
  • Default: an app-unique name generated by the chart

The unique, namespace-global, name of this object inside the Kubernetes cluster.

Normally, you shouldn’t specify names for objects and let the CDK generate a name for you that is application-unique. The names CDK generates are composed from the construct path components, separated by dots and a suffix that is based on a hash of the entire path, to ensure uniqueness.

You can supply custom name allocation logic by overriding the chart.generateObjectName method.

If you use an explicit name here, bear in mind that this reduces the composability of your construct because it won’t be possible to include more than one instance in any app. Therefore it is highly recommended to leave this unspecified.


namespaceOptional
  • Type: java.lang.String
  • Default: undefined (will be assigned to the ‘default’ namespace)

Namespace defines the space within each name must be unique.

An empty namespace is equivalent to the “default” namespace, but “default” is the canonical representation. Not all objects are required to be scoped to a namespace - the value of this field for those objects will be empty. Must be a DNS_LABEL. Cannot be updated. More info: http://kubernetes.io/docs/user-guide/namespaces


ownerReferencesOptional

List of objects depended by this object.

If ALL objects in the list have been deleted, this object will be garbage collected. If this object is managed by a controller, then an entry in this list will point to this controller, with the controller field set to true. There cannot be more than one managing controller.

Kubernetes sets the value of this field automatically for objects that are dependents of other objects like ReplicaSets, DaemonSets, Deployments, Jobs and CronJobs, and ReplicationControllers. You can also configure these relationships manually by changing the value of this field. However, you usually don’t need to and can allow Kubernetes to automatically manage the relationships.

https://kubernetes.io/docs/concepts/overview/working-with-objects/owners-dependents/


apiObjectRequired

Which ApiObject instance is the metadata attached to.


Methods

add
public add(java.lang.String key, java.lang.Object value)
keyRequired
  • Type: java.lang.String

Metadata key.


valueRequired
  • Type: java.lang.Object

Metadata value.


addAnnotation
public addAnnotation(java.lang.String key, java.lang.String value)
keyRequired
  • Type: java.lang.String

The key.


valueRequired
  • Type: java.lang.String

The value.


addFinalizers
public addFinalizers(java.lang.String finalizers)
finalizersRequired
  • Type: java.lang.String

the finalizers.


addLabel
public addLabel(java.lang.String key, java.lang.String value)
keyRequired
  • Type: java.lang.String

The key.


valueRequired
  • Type: java.lang.String

The value.


addOwnerReference
public addOwnerReference(OwnerReference owner)
ownerRequired

the owner.


getLabel
public getLabel(java.lang.String key)
keyRequired
  • Type: java.lang.String

the label.


toJson
public toJson()

Properties

nameOptional
public java.lang.String getName();
  • Type: java.lang.String

The name of the API object.

If a name is specified in metadata.name this will be the name returned. Otherwise, a name will be generated by calling Chart.of(this).generatedObjectName(this), which by default uses the construct path to generate a DNS-compatible name for the resource.


namespaceOptional
public java.lang.String getNamespace();
  • Type: java.lang.String

The object’s namespace.


Cron

Represents a cron schedule.

Initializers

import org.cdk8s.Cron;

Cron.Builder.create()
//  .day(java.lang.String)
//  .hour(java.lang.String)
//  .minute(java.lang.String)
//  .month(java.lang.String)
//  .weekDay(java.lang.String)
    .build();
dayOptional
  • Type: java.lang.String
  • Default: Every day of the month

The day of the month to run this rule at.


hourOptional
  • Type: java.lang.String
  • Default: Every hour

The hour to run this rule at.


minuteOptional
  • Type: java.lang.String
  • Default: Every minute

The minute to run this rule at.


monthOptional
  • Type: java.lang.String
  • Default: Every month

The month to run this rule at.


weekDayOptional
  • Type: java.lang.String
  • Default: Any day of the week

The day of the week to run this rule at.


Static Functions

annually
import org.cdk8s.Cron;

Cron.annually()
daily
import org.cdk8s.Cron;

Cron.daily()
everyMinute
import org.cdk8s.Cron;

Cron.everyMinute()
hourly
import org.cdk8s.Cron;

Cron.hourly()
monthly
import org.cdk8s.Cron;

Cron.monthly()
schedule
import org.cdk8s.Cron;

Cron.schedule(CronOptions options)
optionsRequired

weekly
import org.cdk8s.Cron;

Cron.weekly()

Properties

expressionStringRequired
public java.lang.String getExpressionString();
  • Type: java.lang.String

Retrieve the expression for this schedule.


DependencyGraph

Represents the dependency graph for a given Node.

This graph includes the dependency relationships between all nodes in the node (construct) sub-tree who’s root is this Node.

Note that this means that lonely nodes (no dependencies and no dependants) are also included in this graph as childless children of the root node of the graph.

The graph does not include cross-scope dependencies. That is, if a child on the current scope depends on a node from a different scope, that relationship is not represented in this graph.

Initializers

import org.cdk8s.DependencyGraph;

new DependencyGraph(Node node);
nodeRequired

Methods

topology
public topology()

Properties

rootRequired
public DependencyVertex getRoot();

Returns the root of the graph.

Note that this vertex will always have null as its .value since it is an artifical root that binds all the connected spaces of the graph.


DependencyVertex

Represents a vertex in the graph.

The value of each vertex is an IConstruct that is accessible via the .value getter.

Initializers

import org.cdk8s.DependencyVertex;

new DependencyVertex();
new DependencyVertex(IConstruct value);
valueOptional

Methods

addChild
public addChild(DependencyVertex dep)
depRequired

The dependency.


topology
public topology()

Properties

inboundRequired
public java.util.List<DependencyVertex> getInbound();

Returns the parents of the vertex (i.e dependants).


outboundRequired
public java.util.List<DependencyVertex> getOutbound();

Returns the children of the vertex (i.e dependencies).


valueOptional
public IConstruct getValue();

Returns the IConstruct this graph vertex represents.

null in case this is the root of the graph.


Duration

Represents a length of time.

The amount can be specified either as a literal value (e.g: 10) which cannot be negative.

Methods

toDays
public toDays()
public toDays(TimeConversionOptions opts)
optsOptional

toHours
public toHours()
public toHours(TimeConversionOptions opts)
optsOptional

toHumanString
public toHumanString()
toIsoString
public toIsoString()
toMilliseconds
public toMilliseconds()
public toMilliseconds(TimeConversionOptions opts)
optsOptional

toMinutes
public toMinutes()
public toMinutes(TimeConversionOptions opts)
optsOptional

toSeconds
public toSeconds()
public toSeconds(TimeConversionOptions opts)
optsOptional

unitLabel
public unitLabel()

Static Functions

days
import org.cdk8s.Duration;

Duration.days(java.lang.Number amount)
amountRequired
  • Type: java.lang.Number

the amount of Days the Duration will represent.


hours
import org.cdk8s.Duration;

Duration.hours(java.lang.Number amount)
amountRequired
  • Type: java.lang.Number

the amount of Hours the Duration will represent.


millis
import org.cdk8s.Duration;

Duration.millis(java.lang.Number amount)
amountRequired
  • Type: java.lang.Number

the amount of Milliseconds the Duration will represent.


minutes
import org.cdk8s.Duration;

Duration.minutes(java.lang.Number amount)
amountRequired
  • Type: java.lang.Number

the amount of Minutes the Duration will represent.


parse
import org.cdk8s.Duration;

Duration.parse(java.lang.String duration)
durationRequired
  • Type: java.lang.String

an ISO-formtted duration to be parsed.


seconds
import org.cdk8s.Duration;

Duration.seconds(java.lang.Number amount)
amountRequired
  • Type: java.lang.Number

the amount of Seconds the Duration will represent.


ImplicitTokenResolver

Resolves implicit tokens.

Initializers

import org.cdk8s.ImplicitTokenResolver;

new ImplicitTokenResolver();

Methods

resolve
public resolve(ResolutionContext context)
contextRequired

JsonPatch

Utility for applying RFC-6902 JSON-Patch to a document.

Use the the JsonPatch.apply(doc, ...ops) function to apply a set of operations to a JSON document and return the result.

Operations can be created using the factory methods JsonPatch.add(), JsonPatch.remove(), etc.

Static Functions

add
import org.cdk8s.JsonPatch;

JsonPatch.add(java.lang.String path, java.lang.Object value)
pathRequired
  • Type: java.lang.String

valueRequired
  • Type: java.lang.Object

apply
import org.cdk8s.JsonPatch;

JsonPatch.apply(java.lang.Object document, JsonPatch ops)
documentRequired
  • Type: java.lang.Object

The document to patch.


opsRequired

The operations to apply.


copy
import org.cdk8s.JsonPatch;

JsonPatch.copy(java.lang.String from, java.lang.String path)
fromRequired
  • Type: java.lang.String

pathRequired
  • Type: java.lang.String

move
import org.cdk8s.JsonPatch;

JsonPatch.move(java.lang.String from, java.lang.String path)
fromRequired
  • Type: java.lang.String

pathRequired
  • Type: java.lang.String

remove
import org.cdk8s.JsonPatch;

JsonPatch.remove(java.lang.String path)
pathRequired
  • Type: java.lang.String

replace
import org.cdk8s.JsonPatch;

JsonPatch.replace(java.lang.String path, java.lang.Object value)
pathRequired
  • Type: java.lang.String

valueRequired
  • Type: java.lang.Object

test
import org.cdk8s.JsonPatch;

JsonPatch.test(java.lang.String path, java.lang.Object value)
pathRequired
  • Type: java.lang.String

valueRequired
  • Type: java.lang.Object

Lazy

Methods

produce
public produce()

Static Functions

any
import org.cdk8s.Lazy;

Lazy.any(IAnyProducer producer)
producerRequired

LazyResolver

Resolvers instanecs of Lazy.

Initializers

import org.cdk8s.LazyResolver;

new LazyResolver();

Methods

resolve
public resolve(ResolutionContext context)
contextRequired

Names

Utilities for generating unique and stable names.

Static Functions

toDnsLabel
import org.cdk8s.Names;

Names.toDnsLabel(Construct scope)
Names.toDnsLabel(Construct scope, NameOptions options)
scopeRequired

The construct for which to render the DNS label.


optionsOptional

Name options.


toLabelValue
import org.cdk8s.Names;

Names.toLabelValue(Construct scope)
Names.toLabelValue(Construct scope, NameOptions options)
scopeRequired

The construct for which to render the DNS label.


optionsOptional

Name options.


NumberStringUnionResolver

Resolves union types that allow using either number or string (as generated by the CLI).

E.g IntOrString, Quantity, …

Initializers

import org.cdk8s.NumberStringUnionResolver;

new NumberStringUnionResolver();

Methods

resolve
public resolve(ResolutionContext context)
contextRequired

ResolutionContext

Context object for a specific resolution process.

Initializers

import org.cdk8s.ResolutionContext;

new ResolutionContext(ApiObject obj, java.util.List<java.lang.String> key, java.lang.Object value);
objRequired

Which ApiObject is currently being resolved.


keyRequired
  • Type: java.util.List<java.lang.String>

Which key is currently being resolved.


valueRequired
  • Type: java.lang.Object

The value associated to the key currently being resolved.


Methods

replaceValue
public replaceValue(java.lang.Object newValue)
newValueRequired
  • Type: java.lang.Object

Properties

keyRequired
public java.util.List<java.lang.String> getKey();
  • Type: java.util.List<java.lang.String>

Which key is currently being resolved.


objRequired
public ApiObject getObj();

Which ApiObject is currently being resolved.


valueRequired
public java.lang.Object getValue();
  • Type: java.lang.Object

The value associated to the key currently being resolved.


replacedRequired
public java.lang.Boolean getReplaced();
  • Type: java.lang.Boolean

Whether or not the value was replaced by invoking the replaceValue method.


replacedValueRequired
public java.lang.Object getReplacedValue();
  • Type: java.lang.Object

The replaced value that was set via the replaceValue method.


Size

Represents the amount of digital storage.

The amount can be specified either as a literal value (e.g: 10) which cannot be negative.

When the amount is passed as a token, unit conversion is not possible.

Methods

toGibibytes
public toGibibytes()
public toGibibytes(SizeConversionOptions opts)
optsOptional

toKibibytes
public toKibibytes()
public toKibibytes(SizeConversionOptions opts)
optsOptional

toMebibytes
public toMebibytes()
public toMebibytes(SizeConversionOptions opts)
optsOptional

toPebibytes
public toPebibytes()
public toPebibytes(SizeConversionOptions opts)
optsOptional

toTebibytes
public toTebibytes()
public toTebibytes(SizeConversionOptions opts)
optsOptional

Static Functions

gibibytes
import org.cdk8s.Size;

Size.gibibytes(java.lang.Number amount)
amountRequired
  • Type: java.lang.Number

kibibytes
import org.cdk8s.Size;

Size.kibibytes(java.lang.Number amount)
amountRequired
  • Type: java.lang.Number

mebibytes
import org.cdk8s.Size;

Size.mebibytes(java.lang.Number amount)
amountRequired
  • Type: java.lang.Number

pebibyte
import org.cdk8s.Size;

Size.pebibyte(java.lang.Number amount)
amountRequired
  • Type: java.lang.Number

tebibytes
import org.cdk8s.Size;

Size.tebibytes(java.lang.Number amount)
amountRequired
  • Type: java.lang.Number

Testing

Testing utilities for cdk8s applications.

Static Functions

app
import org.cdk8s.Testing;

Testing.app()
Testing.app(AppProps props)
propsOptional

chart
import org.cdk8s.Testing;

Testing.chart()
synth
import org.cdk8s.Testing;

Testing.synth(Chart chart)
chartRequired

Yaml

YAML utilities.

Static Functions

~~formatObjects~~
import org.cdk8s.Yaml;

Yaml.formatObjects(java.util.List<java.lang.Object> docs)
docsRequired
  • Type: java.util.List<java.lang.Object>

load
import org.cdk8s.Yaml;

Yaml.load(java.lang.String urlOrFile)
urlOrFileRequired
  • Type: java.lang.String

a URL of a file path to load from.


save
import org.cdk8s.Yaml;

Yaml.save(java.lang.String filePath, java.util.List<java.lang.Object> docs)
filePathRequired
  • Type: java.lang.String

The output path.


docsRequired
  • Type: java.util.List<java.lang.Object>

The set of objects.


stringify
import org.cdk8s.Yaml;

Yaml.stringify(java.lang.Object docs)
docsRequired
  • Type: java.lang.Object

A set of objects to convert to YAML.


tmp
import org.cdk8s.Yaml;

Yaml.tmp(java.util.List<java.lang.Object> docs)
docsRequired
  • Type: java.util.List<java.lang.Object>

the set of documents to save.


Protocols

IAnyProducer

Methods

produce
public produce()

IResolver

Contract for resolver objects.

Methods

resolve
public resolve(ResolutionContext context)
contextRequired

Enums

SizeRoundingBehavior

Rounding behaviour when converting between units of Size.

FAIL

Fail the conversion if the result is not an integer.


FLOOR

If the result is not an integer, round it to the closest integer less than the result.


NONE

Don’t round.

Return even if the result is a fraction.


YamlOutputType

The method to divide YAML output into files.

FILE_PER_APP

All resources are output into a single YAML file.


FILE_PER_CHART

Resources are split into seperate files by chart.


FILE_PER_RESOURCE

Each resource is output to its own file.


FOLDER_PER_CHART_FILE_PER_RESOURCE

Each chart in its own folder and each resource in its own file.