Skip to content

cdk8s (TypeScript)

Constructs

ApiObject

Initializers

import { ApiObject } from 'cdk8s'

new ApiObject(scope: Construct, id: string, props: ApiObjectProps)
Name Type Description
scope constructs.Construct the construct scope.
id string namespace.
props ApiObjectProps options.

scopeRequired
  • Type: constructs.Construct

the construct scope.


idRequired
  • Type: string

namespace.


propsRequired

options.


Methods

Name Description
toString Returns a string representation of this construct.
addDependency Create a dependency between this ApiObject and other constructs.
addJsonPatch Applies a set of RFC-6902 JSON-Patch operations to the manifest synthesized for this API object.
toJson Renders the object to Kubernetes JSON.

toString
public toString(): string

Returns a string representation of this construct.

addDependency
public addDependency(dependencies: ...IConstruct[]): void

Create a dependency between this ApiObject and other constructs.

These can be other ApiObjects, Charts, or custom.

dependenciesRequired
  • Type: …constructs.IConstruct[]

the dependencies to add.


addJsonPatch
public addJsonPatch(ops: ...JsonPatch[]): void

Applies a set of RFC-6902 JSON-Patch operations to the manifest synthesized for this API object.

Example

  kubePod.addJsonPatch(JsonPatch.replace('/spec/enableServiceLinks', true));
opsRequired

The JSON-Patch operations to apply.


toJson
public toJson(): any

Renders the object to Kubernetes JSON.

To disable sorting of dictionary keys in output object set the CDK8S_DISABLE_SORT environment variable to any non-empty value.

Static Functions

Name Description
isConstruct Checks if x is a construct.
isApiObject Return whether the given object is an ApiObject.
of Returns the ApiObject named Resource which is a child of the given construct.

~~isConstruct~~
import { ApiObject } from 'cdk8s'

ApiObject.isConstruct(x: any)

Checks if x is a construct.

xRequired
  • Type: any

Any object.


isApiObject
import { ApiObject } from 'cdk8s'

ApiObject.isApiObject(o: any)

Return whether the given object is an ApiObject.

We do attribute detection since we can’t reliably use ‘instanceof’.

oRequired
  • Type: any

The object to check.


of
import { ApiObject } from 'cdk8s'

ApiObject.of(c: IConstruct)

Returns the ApiObject named Resource which is a child of the given construct.

If c is an ApiObject, it is returned directly. Throws an exception if the construct does not have a child named Default or if this child is not an ApiObject.

cRequired
  • Type: constructs.IConstruct

The higher-level construct.


Properties

Name Type Description
node constructs.Node The tree node.
apiGroup string The group portion of the API version (e.g. authorization.k8s.io).
apiVersion string The object’s API version (e.g. authorization.k8s.io/v1).
chart Chart The chart in which this object is defined.
kind string The object kind.
metadata ApiObjectMetadataDefinition Metadata associated with this API object.
name string The name of the API object.

nodeRequired
public readonly node: Node;
  • Type: constructs.Node

The tree node.


apiGroupRequired
public readonly apiGroup: string;
  • Type: string

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


apiVersionRequired
public readonly apiVersion: string;
  • Type: string

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


chartRequired
public readonly chart: Chart;

The chart in which this object is defined.


kindRequired
public readonly kind: string;
  • Type: string

The object kind.


metadataRequired
public readonly metadata: ApiObjectMetadataDefinition;

Metadata associated with this API object.


nameRequired
public readonly name: string;
  • Type: 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 { App } from 'cdk8s'

new App(props?: AppProps)
Name Type Description
props AppProps configuration options.

propsOptional

configuration options.


Methods

Name Description
toString Returns a string representation of this construct.
synth Synthesizes all manifests to the output directory.
synthYaml Synthesizes the app into a YAML string.

toString
public toString(): string

Returns a string representation of this construct.

synth
public synth(): void

Synthesizes all manifests to the output directory.

synthYaml
public synthYaml(): string

Synthesizes the app into a YAML string.

Static Functions

Name Description
isConstruct Checks if x is a construct.
of No description.

~~isConstruct~~
import { App } from 'cdk8s'

App.isConstruct(x: any)

Checks if x is a construct.

xRequired
  • Type: any

Any object.


of
import { App } from 'cdk8s'

App.of(c: IConstruct)
cRequired
  • Type: constructs.IConstruct

Properties

Name Type Description
node constructs.Node The tree node.
charts Chart[] Returns all the charts in this app, sorted topologically.
outdir string The output directory into which manifests will be synthesized.
outputFileExtension string The file extension to use for rendered YAML files.
resolvers IResolver[] Resolvers used by this app.
yamlOutputType YamlOutputType How to divide the YAML output into files.

nodeRequired
public readonly node: Node;
  • Type: constructs.Node

The tree node.


chartsRequired
public readonly charts: Chart[];

Returns all the charts in this app, sorted topologically.


outdirRequired
public readonly outdir: string;
  • Type: string

The output directory into which manifests will be synthesized.


outputFileExtensionRequired
public readonly outputFileExtension: string;
  • Type: string
  • Default: .k8s.yaml

The file extension to use for rendered YAML files.


resolversRequired
public readonly resolvers: IResolver[];

Resolvers used by this app.

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


yamlOutputTypeRequired
public readonly yamlOutputType: YamlOutputType;

How to divide the YAML output into files.


Chart

Initializers

import { Chart } from 'cdk8s'

new Chart(scope: Construct, id: string, props?: ChartProps)
Name Type Description
scope constructs.Construct No description.
id string No description.
props ChartProps No description.

scopeRequired
  • Type: constructs.Construct

idRequired
  • Type: string

propsOptional

Methods

Name Description
toString Returns a string representation of this construct.
addDependency Create a dependency between this Chart and other constructs.
generateObjectName Generates a app-unique name for an object given it’s construct node path.
toJson Renders this chart to a set of Kubernetes JSON resources.

toString
public toString(): string

Returns a string representation of this construct.

addDependency
public addDependency(dependencies: ...IConstruct[]): void

Create a dependency between this Chart and other constructs.

These can be other ApiObjects, Charts, or custom.

dependenciesRequired
  • Type: …constructs.IConstruct[]

the dependencies to add.


generateObjectName
public generateObjectName(apiObject: ApiObject): string

Generates a app-unique name for an object given it’s construct node path.

Different resource types may have different constraints on names (metadata.name). The previous version of the name generator was compatible with DNS_SUBDOMAIN but not with DNS_LABEL.

For example, Deployment names must comply with DNS_SUBDOMAIN while Service names must comply with DNS_LABEL.

Since there is no formal specification for this, the default name generation scheme for kubernetes objects in cdk8s was changed to DNS_LABEL, since it’s the common denominator for all kubernetes resources (supposedly).

You can override this method if you wish to customize object names at the chart level.

apiObjectRequired

The API object to generate a name for.


toJson
public toJson(): any[]

Renders this chart to a set of Kubernetes JSON resources.

Static Functions

Name Description
isConstruct Checks if x is a construct.
isChart Return whether the given object is a Chart.
of Finds the chart in which a node is defined.

~~isConstruct~~
import { Chart } from 'cdk8s'

Chart.isConstruct(x: any)

Checks if x is a construct.

xRequired
  • Type: any

Any object.


isChart
import { Chart } from 'cdk8s'

Chart.isChart(x: any)

Return whether the given object is a Chart.

We do attribute detection since we can’t reliably use ‘instanceof’.

xRequired
  • Type: any

of
import { Chart } from 'cdk8s'

Chart.of(c: IConstruct)

Finds the chart in which a node is defined.

cRequired
  • Type: constructs.IConstruct

a construct node.


Properties

Name Type Description
node constructs.Node The tree node.
apiObjects ApiObject[] Returns all the included API objects.
labels {[ key: string ]: string} Labels applied to all resources in this chart.
namespace string The default namespace for all objects in this chart.

nodeRequired
public readonly node: Node;
  • Type: constructs.Node

The tree node.


apiObjectsRequired
public readonly apiObjects: ApiObject[];

Returns all the included API objects.


labelsRequired
public readonly labels: {[ key: string ]: string};
  • Type: {[ key: string ]: string}

Labels applied to all resources in this chart.

This is an immutable copy.


namespaceOptional
public readonly namespace: string;
  • Type: 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 { Helm } from 'cdk8s'

new Helm(scope: Construct, id: string, props: HelmProps)
Name Type Description
scope constructs.Construct No description.
id string No description.
props HelmProps No description.

scopeRequired
  • Type: constructs.Construct

idRequired
  • Type: string

propsRequired

Methods

Name Description
toString Returns a string representation of this construct.

toString
public toString(): string

Returns a string representation of this construct.

Static Functions

Name Description
isConstruct Checks if x is a construct.

~~isConstruct~~
import { Helm } from 'cdk8s'

Helm.isConstruct(x: any)

Checks if x is a construct.

xRequired
  • Type: any

Any object.


Properties

Name Type Description
node constructs.Node The tree node.
apiObjects ApiObject[] Returns all the included API objects.
releaseName string The helm release name.

nodeRequired
public readonly node: Node;
  • Type: constructs.Node

The tree node.


apiObjectsRequired
public readonly apiObjects: ApiObject[];

Returns all the included API objects.


releaseNameRequired
public readonly releaseName: string;
  • Type: 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 { Include } from 'cdk8s'

new Include(scope: Construct, id: string, props: IncludeProps)
Name Type Description
scope constructs.Construct No description.
id string No description.
props IncludeProps No description.

scopeRequired
  • Type: constructs.Construct

idRequired
  • Type: string

propsRequired

Methods

Name Description
toString Returns a string representation of this construct.

toString
public toString(): string

Returns a string representation of this construct.

Static Functions

Name Description
isConstruct Checks if x is a construct.

~~isConstruct~~
import { Include } from 'cdk8s'

Include.isConstruct(x: any)

Checks if x is a construct.

xRequired
  • Type: any

Any object.


Properties

Name Type Description
node constructs.Node The tree node.
apiObjects ApiObject[] Returns all the included API objects.

nodeRequired
public readonly node: Node;
  • Type: constructs.Node

The tree node.


apiObjectsRequired
public readonly apiObjects: ApiObject[];

Returns all the included API objects.


Structs

ApiObjectMetadata

Metadata associated with this object.

Initializer

import { ApiObjectMetadata } from 'cdk8s'

const apiObjectMetadata: ApiObjectMetadata = { ... }

Properties

Name Type Description
annotations {[ key: string ]: string} Annotations is an unstructured key value map stored with a resource that may be set by external tools to store and retrieve arbitrary metadata.
finalizers string[] Namespaced keys that tell Kubernetes to wait until specific conditions are met before it fully deletes resources marked for deletion.
labels {[ key: string ]: string} Map of string keys and values that can be used to organize and categorize (scope and select) objects.
name string The unique, namespace-global, name of this object inside the Kubernetes cluster.
namespace string Namespace defines the space within each name must be unique.
ownerReferences OwnerReference[] List of objects depended by this object.

annotationsOptional
public readonly annotations: {[ key: string ]: string};
  • Type: {[ key: string ]: 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 readonly finalizers: string[];
  • Type: 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 readonly labels: {[ key: string ]: string};
  • Type: {[ key: string ]: 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 readonly name: string;
  • Type: 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 readonly namespace: string;
  • Type: 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 readonly ownerReferences: OwnerReference[];

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 { ApiObjectMetadataDefinitionOptions } from 'cdk8s'

const apiObjectMetadataDefinitionOptions: ApiObjectMetadataDefinitionOptions = { ... }

Properties

Name Type Description
annotations {[ key: string ]: string} Annotations is an unstructured key value map stored with a resource that may be set by external tools to store and retrieve arbitrary metadata.
finalizers string[] Namespaced keys that tell Kubernetes to wait until specific conditions are met before it fully deletes resources marked for deletion.
labels {[ key: string ]: string} Map of string keys and values that can be used to organize and categorize (scope and select) objects.
name string The unique, namespace-global, name of this object inside the Kubernetes cluster.
namespace string Namespace defines the space within each name must be unique.
ownerReferences OwnerReference[] List of objects depended by this object.
apiObject ApiObject Which ApiObject instance is the metadata attached to.

annotationsOptional
public readonly annotations: {[ key: string ]: string};
  • Type: {[ key: string ]: 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 readonly finalizers: string[];
  • Type: 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 readonly labels: {[ key: string ]: string};
  • Type: {[ key: string ]: 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 readonly name: string;
  • Type: 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 readonly namespace: string;
  • Type: 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 readonly ownerReferences: OwnerReference[];

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 readonly apiObject: ApiObject;

Which ApiObject instance is the metadata attached to.


ApiObjectProps

Options for defining API objects.

Initializer

import { ApiObjectProps } from 'cdk8s'

const apiObjectProps: ApiObjectProps = { ... }

Properties

Name Type Description
apiVersion string API version.
kind string Resource kind.
metadata ApiObjectMetadata Object metadata.

apiVersionRequired
public readonly apiVersion: string;
  • Type: string

API version.


kindRequired
public readonly kind: string;
  • Type: string

Resource kind.


metadataOptional
public readonly metadata: ApiObjectMetadata;

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 { AppProps } from 'cdk8s'

const appProps: AppProps = { ... }

Properties

Name Type Description
outdir string The directory to output Kubernetes manifests.
outputFileExtension string The file extension to use for rendered YAML files.
recordConstructMetadata boolean 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.
resolvers IResolver[] A list of resolvers that can be used to replace property values before they are written to the manifest file.
yamlOutputType YamlOutputType How to divide the YAML output into files.

outdirOptional
public readonly outdir: string;
  • Type: 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 readonly outputFileExtension: string;
  • Type: string
  • Default: .k8s.yaml

The file extension to use for rendered YAML files.


recordConstructMetadataOptional
public readonly recordConstructMetadata: boolean;
  • Type: 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 readonly resolvers: IResolver[];

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 readonly yamlOutputType: YamlOutputType;

How to divide the YAML output into files.


ChartProps

Initializer

import { ChartProps } from 'cdk8s'

const chartProps: ChartProps = { ... }

Properties

Name Type Description
disableResourceNameHashes boolean The autogenerated resource name by default is suffixed with a stable hash of the construct path.
labels {[ key: string ]: string} Labels to apply to all resources in this chart.
namespace string The default namespace for all objects defined in this chart (directly or indirectly).

disableResourceNameHashesOptional
public readonly disableResourceNameHashes: boolean;
  • Type: 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 readonly labels: {[ key: string ]: string};
  • Type: {[ key: string ]: string}
  • Default: no common labels

Labels to apply to all resources in this chart.


namespaceOptional
public readonly namespace: string;
  • Type: 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 { CronOptions } from 'cdk8s'

const cronOptions: CronOptions = { ... }

Properties

Name Type Description
day string The day of the month to run this rule at.
hour string The hour to run this rule at.
minute string The minute to run this rule at.
month string The month to run this rule at.
weekDay string The day of the week to run this rule at.

dayOptional
public readonly day: string;
  • Type: string
  • Default: Every day of the month

The day of the month to run this rule at.


hourOptional
public readonly hour: string;
  • Type: string
  • Default: Every hour

The hour to run this rule at.


minuteOptional
public readonly minute: string;
  • Type: string
  • Default: Every minute

The minute to run this rule at.


monthOptional
public readonly month: string;
  • Type: string
  • Default: Every month

The month to run this rule at.


weekDayOptional
public readonly weekDay: string;
  • Type: string
  • Default: Any day of the week

The day of the week to run this rule at.


GroupVersionKind

Initializer

import { GroupVersionKind } from 'cdk8s'

const groupVersionKind: GroupVersionKind = { ... }

Properties

Name Type Description
apiVersion string The object’s API version (e.g. authorization.k8s.io/v1).
kind string The object kind.

apiVersionRequired
public readonly apiVersion: string;
  • Type: string

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


kindRequired
public readonly kind: string;
  • Type: string

The object kind.


HelmProps

Options for Helm.

Initializer

import { HelmProps } from 'cdk8s'

const helmProps: HelmProps = { ... }

Properties

Name Type Description
chart string The chart name to use. It can be a chart from a helm repository or a local directory.
helmExecutable string The local helm executable to use in order to create the manifest the chart.
helmFlags string[] Additional flags to add to the helm execution.
namespace string Scope all resources in to a given namespace.
releaseName string The release name.
repo string Chart repository url where to locate the requested chart.
values {[ key: string ]: any} Values to pass to the chart.
version string Version constraint for the chart version to use.

chartRequired
public readonly chart: string;
  • Type: 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.


Example

"bitnami/redis"
helmExecutableOptional
public readonly helmExecutable: string;
  • Type: string
  • Default: “helm”

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


helmFlagsOptional
public readonly helmFlags: string[];
  • Type: string[]
  • Default: []

Additional flags to add to the helm execution.


namespaceOptional
public readonly namespace: string;
  • Type: string

Scope all resources in to a given namespace.


releaseNameOptional
public readonly releaseName: string;
  • Type: 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 readonly repo: string;
  • Type: string

Chart repository url where to locate the requested chart.


valuesOptional
public readonly values: {[ key: string ]: any};
  • Type: {[ key: string ]: any}
  • Default: If no values are specified, chart will use the defaults.

Values to pass to the chart.


versionOptional
public readonly version: string;
  • Type: 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.


Example

"^2.0.0"

IncludeProps

Initializer

import { IncludeProps } from 'cdk8s'

const includeProps: IncludeProps = { ... }

Properties

Name Type Description
url string Local file path or URL which includes a Kubernetes YAML manifest.

urlRequired
public readonly url: string;
  • Type: string

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


Example

mymanifest.yaml

NameOptions

Options for name generation.

Initializer

import { NameOptions } from 'cdk8s'

const nameOptions: NameOptions = { ... }

Properties

Name Type Description
delimiter string Delimiter to use between components.
extra string[] Extra components to include in the name.
includeHash boolean Include a short hash as last part of the name.
maxLen number Maximum allowed length for the name.

delimiterOptional
public readonly delimiter: string;
  • Type: string
  • Default: “-“

Delimiter to use between components.


extraOptional
public readonly extra: string[];
  • Type: string[]
  • Default: [] use the construct path components

Extra components to include in the name.


includeHashOptional
public readonly includeHash: boolean;
  • Type: boolean
  • Default: true

Include a short hash as last part of the name.


maxLenOptional
public readonly maxLen: number;
  • Type: 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 { OwnerReference } from 'cdk8s'

const ownerReference: OwnerReference = { ... }

Properties

Name Type Description
apiVersion string API version of the referent.
kind string Kind of the referent.
name string Name of the referent.
uid string UID of the referent.
blockOwnerDeletion boolean 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.
controller boolean If true, this reference points to the managing controller.

apiVersionRequired
public readonly apiVersion: string;
  • Type: string

API version of the referent.


kindRequired
public readonly kind: string;
  • Type: string

Kind of the referent.

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


nameRequired
public readonly name: string;
  • Type: string

Name of the referent.

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


uidRequired
public readonly uid: string;
  • Type: string

UID of the referent.

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


blockOwnerDeletionOptional
public readonly blockOwnerDeletion: boolean;
  • Type: 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 readonly controller: boolean;
  • Type: boolean

If true, this reference points to the managing controller.


SizeConversionOptions

Options for how to convert size to a different unit.

Initializer

import { SizeConversionOptions } from 'cdk8s'

const sizeConversionOptions: SizeConversionOptions = { ... }

Properties

Name Type Description
rounding SizeRoundingBehavior How conversions should behave when it encounters a non-integer result.

roundingOptional
public readonly rounding: SizeRoundingBehavior;

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


TimeConversionOptions

Options for how to convert time to a different unit.

Initializer

import { TimeConversionOptions } from 'cdk8s'

const timeConversionOptions: TimeConversionOptions = { ... }

Properties

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

integralOptional
public readonly integral: boolean;
  • Type: 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 { ApiObjectMetadataDefinition } from 'cdk8s'

new ApiObjectMetadataDefinition(options: ApiObjectMetadataDefinitionOptions)
Name Type Description
options ApiObjectMetadataDefinitionOptions No description.

optionsRequired

Methods

Name Description
add Adds an arbitrary key/value to the object metadata.
addAnnotation Add an annotation.
addFinalizers Add one or more finalizers.
addLabel Add a label.
addOwnerReference Add an owner.
getLabel No description.
toJson Synthesizes a k8s ObjectMeta for this metadata set.

add
public add(key: string, value: any): void

Adds an arbitrary key/value to the object metadata.

keyRequired
  • Type: string

Metadata key.


valueRequired
  • Type: any

Metadata value.


addAnnotation
public addAnnotation(key: string, value: string): void

Add an annotation.

keyRequired
  • Type: string

The key.


valueRequired
  • Type: string

The value.


addFinalizers
public addFinalizers(finalizers: ...string[]): void

Add one or more finalizers.

finalizersRequired
  • Type: …string[]

the finalizers.


addLabel
public addLabel(key: string, value: string): void

Add a label.

keyRequired
  • Type: string

The key.


valueRequired
  • Type: string

The value.


addOwnerReference
public addOwnerReference(owner: OwnerReference): void

Add an owner.

ownerRequired

the owner.


getLabel
public getLabel(key: string): string
keyRequired
  • Type: string

the label.


toJson
public toJson(): any

Synthesizes a k8s ObjectMeta for this metadata set.

Properties

Name Type Description
name string The name of the API object.
namespace string The object’s namespace.

nameOptional
public readonly name: string;
  • Type: 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 readonly namespace: string;
  • Type: string

The object’s namespace.


Cron

Represents a cron schedule.

Initializers

import { Cron } from 'cdk8s'

new Cron(cronOptions?: CronOptions)
Name Type Description
cronOptions CronOptions No description.

cronOptionsOptional

Static Functions

Name Description
annually Create a cron schedule which runs first day of January every year.
daily Create a cron schedule which runs every day at midnight.
everyMinute Create a cron schedule which runs every minute.
hourly Create a cron schedule which runs every hour.
monthly Create a cron schedule which runs first day of every month.
schedule Create a custom cron schedule from a set of cron fields.
weekly Create a cron schedule which runs every week on Sunday.

annually
import { Cron } from 'cdk8s'

Cron.annually()

Create a cron schedule which runs first day of January every year.

daily
import { Cron } from 'cdk8s'

Cron.daily()

Create a cron schedule which runs every day at midnight.

everyMinute
import { Cron } from 'cdk8s'

Cron.everyMinute()

Create a cron schedule which runs every minute.

hourly
import { Cron } from 'cdk8s'

Cron.hourly()

Create a cron schedule which runs every hour.

monthly
import { Cron } from 'cdk8s'

Cron.monthly()

Create a cron schedule which runs first day of every month.

schedule
import { Cron } from 'cdk8s'

Cron.schedule(options: CronOptions)

Create a custom cron schedule from a set of cron fields.

optionsRequired

weekly
import { Cron } from 'cdk8s'

Cron.weekly()

Create a cron schedule which runs every week on Sunday.

Properties

Name Type Description
expressionString string Retrieve the expression for this schedule.

expressionStringRequired
public readonly expressionString: string;
  • Type: 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 { DependencyGraph } from 'cdk8s'

new DependencyGraph(node: Node)
Name Type Description
node constructs.Node No description.

nodeRequired
  • Type: constructs.Node

Methods

Name Description
topology No description.

topology
public topology(): IConstruct[]

Vertex.topology ()

Properties

Name Type Description
root DependencyVertex Returns the root of the graph.

rootRequired
public readonly root: DependencyVertex;

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 { DependencyVertex } from 'cdk8s'

new DependencyVertex(value?: IConstruct)
Name Type Description
value constructs.IConstruct No description.

valueOptional
  • Type: constructs.IConstruct

Methods

Name Description
addChild Adds a vertex as a dependency of the current node.
topology Returns a topologically sorted array of the constructs in the sub-graph.

addChild
public addChild(dep: DependencyVertex): void

Adds a vertex as a dependency of the current node.

Also updates the parents of dep, so that it contains this node as a parent.

This operation will fail in case it creates a cycle in the graph.

depRequired

The dependency.


topology
public topology(): IConstruct[]

Returns a topologically sorted array of the constructs in the sub-graph.

Properties

Name Type Description
inbound DependencyVertex[] Returns the parents of the vertex (i.e dependants).
outbound DependencyVertex[] Returns the children of the vertex (i.e dependencies).
value constructs.IConstruct Returns the IConstruct this graph vertex represents.

inboundRequired
public readonly inbound: DependencyVertex[];

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


outboundRequired
public readonly outbound: DependencyVertex[];

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


valueOptional
public readonly value: IConstruct;
  • Type: constructs.IConstruct

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

Name Description
toDays Return the total number of days in this Duration.
toHours Return the total number of hours in this Duration.
toHumanString Turn this duration into a human-readable string.
toIsoString Return an ISO 8601 representation of this period.
toMilliseconds Return the total number of milliseconds in this Duration.
toMinutes Return the total number of minutes in this Duration.
toSeconds Return the total number of seconds in this Duration.
unitLabel Return unit of Duration.

toDays
public toDays(opts?: TimeConversionOptions): number

Return the total number of days in this Duration.

optsOptional

toHours
public toHours(opts?: TimeConversionOptions): number

Return the total number of hours in this Duration.

optsOptional

toHumanString
public toHumanString(): string

Turn this duration into a human-readable string.

toIsoString
public toIsoString(): string

Return an ISO 8601 representation of this period.

https://www.iso.org/fr/standard/70907.html

toMilliseconds
public toMilliseconds(opts?: TimeConversionOptions): number

Return the total number of milliseconds in this Duration.

optsOptional

toMinutes
public toMinutes(opts?: TimeConversionOptions): number

Return the total number of minutes in this Duration.

optsOptional

toSeconds
public toSeconds(opts?: TimeConversionOptions): number

Return the total number of seconds in this Duration.

optsOptional

unitLabel
public unitLabel(): string

Return unit of Duration.

Static Functions

Name Description
days Create a Duration representing an amount of days.
hours Create a Duration representing an amount of hours.
millis Create a Duration representing an amount of milliseconds.
minutes Create a Duration representing an amount of minutes.
parse Parse a period formatted according to the ISO 8601 standard.
seconds Create a Duration representing an amount of seconds.

days
import { Duration } from 'cdk8s'

Duration.days(amount: number)

Create a Duration representing an amount of days.

amountRequired
  • Type: number

the amount of Days the Duration will represent.


hours
import { Duration } from 'cdk8s'

Duration.hours(amount: number)

Create a Duration representing an amount of hours.

amountRequired
  • Type: number

the amount of Hours the Duration will represent.


millis
import { Duration } from 'cdk8s'

Duration.millis(amount: number)

Create a Duration representing an amount of milliseconds.

amountRequired
  • Type: number

the amount of Milliseconds the Duration will represent.


minutes
import { Duration } from 'cdk8s'

Duration.minutes(amount: number)

Create a Duration representing an amount of minutes.

amountRequired
  • Type: number

the amount of Minutes the Duration will represent.


parse
import { Duration } from 'cdk8s'

Duration.parse(duration: string)

Parse a period formatted according to the ISO 8601 standard.

https://www.iso.org/fr/standard/70907.html

durationRequired
  • Type: string

an ISO-formtted duration to be parsed.


seconds
import { Duration } from 'cdk8s'

Duration.seconds(amount: number)

Create a Duration representing an amount of seconds.

amountRequired
  • Type: number

the amount of Seconds the Duration will represent.


ImplicitTokenResolver

Resolves implicit tokens.

Initializers

import { ImplicitTokenResolver } from 'cdk8s'

new ImplicitTokenResolver()
Name Type Description

Methods

Name Description
resolve This function is invoked on every property during cdk8s synthesis.

resolve
public resolve(context: ResolutionContext): void

This function is invoked on every property during cdk8s synthesis.

To replace a value, implementations must invoke context.replaceValue.

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.

Example

const output = JsonPatch.apply(input,
 JsonPatch.replace('/world/hi/there', 'goodbye'),
 JsonPatch.add('/world/foo/', 'boom'),
 JsonPatch.remove('/hello'));

Static Functions

Name Description
add Adds a value to an object or inserts it into an array.
apply Applies a set of JSON-Patch (RFC-6902) operations to document and returns the result.
copy Copies a value from one location to another within the JSON document.
move Moves a value from one location to the other.
remove Removes a value from an object or array.
replace Replaces a value.
test Tests that the specified value is set in the document.

add
import { JsonPatch } from 'cdk8s'

JsonPatch.add(path: string, value: any)

Adds a value to an object or inserts it into an array.

In the case of an array, the value is inserted before the given index. The - character can be used instead of an index to insert at the end of an array.

Example

JsonPatch.add('/biscuits/1', { "name": "Ginger Nut" })
pathRequired
  • Type: string

valueRequired
  • Type: any

apply
import { JsonPatch } from 'cdk8s'

JsonPatch.apply(document: any, ops: ...JsonPatch[])

Applies a set of JSON-Patch (RFC-6902) operations to document and returns the result.

documentRequired
  • Type: any

The document to patch.


opsRequired

The operations to apply.


copy
import { JsonPatch } from 'cdk8s'

JsonPatch.copy(from: string, path: string)

Copies a value from one location to another within the JSON document.

Both from and path are JSON Pointers.

Example

JsonPatch.copy('/biscuits/0', '/best_biscuit')
fromRequired
  • Type: string

pathRequired
  • Type: string

move
import { JsonPatch } from 'cdk8s'

JsonPatch.move(from: string, path: string)

Moves a value from one location to the other.

Both from and path are JSON Pointers.

Example

JsonPatch.move('/biscuits', '/cookies')
fromRequired
  • Type: string

pathRequired
  • Type: string

remove
import { JsonPatch } from 'cdk8s'

JsonPatch.remove(path: string)

Removes a value from an object or array.

Example

JsonPatch.remove('/biscuits/0')
pathRequired
  • Type: string

replace
import { JsonPatch } from 'cdk8s'

JsonPatch.replace(path: string, value: any)

Replaces a value.

Equivalent to a “remove” followed by an “add”.

Example

JsonPatch.replace('/biscuits/0/name', 'Chocolate Digestive')
pathRequired
  • Type: string

valueRequired
  • Type: any

test
import { JsonPatch } from 'cdk8s'

JsonPatch.test(path: string, value: any)

Tests that the specified value is set in the document.

If the test fails, then the patch as a whole should not apply.

Example

JsonPatch.test('/best_biscuit/name', 'Choco Leibniz')
pathRequired
  • Type: string

valueRequired
  • Type: any

Lazy

Methods

Name Description
produce No description.

produce
public produce(): any

Static Functions

Name Description
any No description.

any
import { Lazy } from 'cdk8s'

Lazy.any(producer: IAnyProducer)
producerRequired

LazyResolver

Resolvers instanecs of Lazy.

Initializers

import { LazyResolver } from 'cdk8s'

new LazyResolver()
Name Type Description

Methods

Name Description
resolve This function is invoked on every property during cdk8s synthesis.

resolve
public resolve(context: ResolutionContext): void

This function is invoked on every property during cdk8s synthesis.

To replace a value, implementations must invoke context.replaceValue.

contextRequired

Names

Utilities for generating unique and stable names.

Static Functions

Name Description
toDnsLabel Generates a unique and stable name compatible DNS_LABEL from RFC-1123 from a path.
toLabelValue Generates a unique and stable name compatible label key name segment and label value from a path.

toDnsLabel
import { Names } from 'cdk8s'

Names.toDnsLabel(scope: Construct, options?: NameOptions)

Generates a unique and stable name compatible DNS_LABEL from RFC-1123 from a path.

The generated name will: - contain at most 63 characters - contain only lowercase alphanumeric characters or ‘-’ - start with an alphanumeric character - end with an alphanumeric character

The generated name will have the form: --..--

Where are the path components (assuming they are is separated by “/”).

Note that if the total length is longer than 63 characters, we will trim the first components since the last components usually encode more meaning.

https://tools.ietf.org/html/rfc1123

scopeRequired
  • Type: constructs.Construct

The construct for which to render the DNS label.


optionsOptional

Name options.


toLabelValue
import { Names } from 'cdk8s'

Names.toLabelValue(scope: Construct, options?: NameOptions)

Generates a unique and stable name compatible label key name segment and label value from a path.

The name segment is required and must be 63 characters or less, beginning and ending with an alphanumeric character ([a-z0-9A-Z]) with dashes (-), underscores (_), dots (.), and alphanumerics between.

Valid label values must be 63 characters or less and must be empty or begin and end with an alphanumeric character ([a-z0-9A-Z]) with dashes (-), underscores (_), dots (.), and alphanumerics between.

The generated name will have the form: ..

Where are the path components (assuming they are is separated by “/”).

Note that if the total length is longer than 63 characters, we will trim the first components since the last components usually encode more meaning.

https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/#syntax-and-character-set

scopeRequired
  • Type: constructs.Construct

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 { NumberStringUnionResolver } from 'cdk8s'

new NumberStringUnionResolver()
Name Type Description

Methods

Name Description
resolve This function is invoked on every property during cdk8s synthesis.

resolve
public resolve(context: ResolutionContext): void

This function is invoked on every property during cdk8s synthesis.

To replace a value, implementations must invoke context.replaceValue.

contextRequired

ResolutionContext

Context object for a specific resolution process.

Initializers

import { ResolutionContext } from 'cdk8s'

new ResolutionContext(obj: ApiObject, key: string[], value: any)
Name Type Description
obj ApiObject Which ApiObject is currently being resolved.
key string[] Which key is currently being resolved.
value any The value associated to the key currently being resolved.

objRequired

Which ApiObject is currently being resolved.


keyRequired
  • Type: string[]

Which key is currently being resolved.


valueRequired
  • Type: any

The value associated to the key currently being resolved.


Methods

Name Description
replaceValue Replaces the original value in this resolution context with a new value.

replaceValue
public replaceValue(newValue: any): void

Replaces the original value in this resolution context with a new value.

The new value is what will end up in the manifest.

newValueRequired
  • Type: any

Properties

Name Type Description
key string[] Which key is currently being resolved.
obj ApiObject Which ApiObject is currently being resolved.
value any The value associated to the key currently being resolved.
replaced boolean Whether or not the value was replaced by invoking the replaceValue method.
replacedValue any The replaced value that was set via the replaceValue method.

keyRequired
public readonly key: string[];
  • Type: string[]

Which key is currently being resolved.


objRequired
public readonly obj: ApiObject;

Which ApiObject is currently being resolved.


valueRequired
public readonly value: any;
  • Type: any

The value associated to the key currently being resolved.


replacedRequired
public readonly replaced: boolean;
  • Type: boolean

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


replacedValueRequired
public readonly replacedValue: any;
  • Type: any

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

Name Description
asString Returns amount with abbreviated storage unit.
toGibibytes Return this storage as a total number of gibibytes.
toKibibytes Return this storage as a total number of kibibytes.
toMebibytes Return this storage as a total number of mebibytes.
toPebibytes Return this storage as a total number of pebibytes.
toTebibytes Return this storage as a total number of tebibytes.

asString
public asString(): string

Returns amount with abbreviated storage unit.

toGibibytes
public toGibibytes(opts?: SizeConversionOptions): number

Return this storage as a total number of gibibytes.

optsOptional

toKibibytes
public toKibibytes(opts?: SizeConversionOptions): number

Return this storage as a total number of kibibytes.

optsOptional

toMebibytes
public toMebibytes(opts?: SizeConversionOptions): number

Return this storage as a total number of mebibytes.

optsOptional

toPebibytes
public toPebibytes(opts?: SizeConversionOptions): number

Return this storage as a total number of pebibytes.

optsOptional

toTebibytes
public toTebibytes(opts?: SizeConversionOptions): number

Return this storage as a total number of tebibytes.

optsOptional

Static Functions

Name Description
gibibytes Create a Storage representing an amount gibibytes.
kibibytes Create a Storage representing an amount kibibytes.
mebibytes Create a Storage representing an amount mebibytes.
pebibyte Create a Storage representing an amount pebibytes.
tebibytes Create a Storage representing an amount tebibytes.

gibibytes
import { Size } from 'cdk8s'

Size.gibibytes(amount: number)

Create a Storage representing an amount gibibytes.

1 GiB = 1024 MiB

amountRequired
  • Type: number

kibibytes
import { Size } from 'cdk8s'

Size.kibibytes(amount: number)

Create a Storage representing an amount kibibytes.

1 KiB = 1024 bytes

amountRequired
  • Type: number

mebibytes
import { Size } from 'cdk8s'

Size.mebibytes(amount: number)

Create a Storage representing an amount mebibytes.

1 MiB = 1024 KiB

amountRequired
  • Type: number

pebibyte
import { Size } from 'cdk8s'

Size.pebibyte(amount: number)

Create a Storage representing an amount pebibytes.

1 PiB = 1024 TiB

amountRequired
  • Type: number

tebibytes
import { Size } from 'cdk8s'

Size.tebibytes(amount: number)

Create a Storage representing an amount tebibytes.

1 TiB = 1024 GiB

amountRequired
  • Type: number

Testing

Testing utilities for cdk8s applications.

Static Functions

Name Description
app Returns an app for testing with the following properties: - Output directory is a temp dir.
chart No description.
synth Returns the Kubernetes manifest synthesized from this chart.

app
import { Testing } from 'cdk8s'

Testing.app(props?: AppProps)

Returns an app for testing with the following properties: - Output directory is a temp dir.

propsOptional

chart
import { Testing } from 'cdk8s'

Testing.chart()
synth
import { Testing } from 'cdk8s'

Testing.synth(chart: Chart)

Returns the Kubernetes manifest synthesized from this chart.

chartRequired

Yaml

YAML utilities.

Static Functions

Name Description
formatObjects No description.
load Downloads a set of YAML documents (k8s manifest for example) from a URL or a file and returns them as javascript objects.
save Saves a set of objects as a multi-document YAML file.
stringify Stringify a document (or multiple documents) into YAML.
tmp Saves a set of YAML documents into a temp file (in /tmp).

~~formatObjects~~
import { Yaml } from 'cdk8s'

Yaml.formatObjects(docs: any[])
docsRequired
  • Type: any[]

load
import { Yaml } from 'cdk8s'

Yaml.load(urlOrFile: string)

Downloads a set of YAML documents (k8s manifest for example) from a URL or a file and returns them as javascript objects.

Empty documents are filtered out.

urlOrFileRequired
  • Type: string

a URL of a file path to load from.


save
import { Yaml } from 'cdk8s'

Yaml.save(filePath: string, docs: any[])

Saves a set of objects as a multi-document YAML file.

filePathRequired
  • Type: string

The output path.


docsRequired
  • Type: any[]

The set of objects.


stringify
import { Yaml } from 'cdk8s'

Yaml.stringify(docs: ...any[])

Stringify a document (or multiple documents) into YAML.

We convert undefined values to null, but ignore any documents that are undefined.

docsRequired
  • Type: …any[]

A set of objects to convert to YAML.


tmp
import { Yaml } from 'cdk8s'

Yaml.tmp(docs: any[])

Saves a set of YAML documents into a temp file (in /tmp).

docsRequired
  • Type: any[]

the set of documents to save.


Protocols

IAnyProducer

Methods

Name Description
produce No description.

produce
public produce(): any

IResolver

Contract for resolver objects.

Methods

Name Description
resolve This function is invoked on every property during cdk8s synthesis.

resolve
public resolve(context: ResolutionContext): void

This function is invoked on every property during cdk8s synthesis.

To replace a value, implementations must invoke context.replaceValue.

contextRequired

Enums

SizeRoundingBehavior

Rounding behaviour when converting between units of Size.

Members

Name Description
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.

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.

Members

Name Description
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.

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.