Skip to content

Latest commit

 

History

History
252 lines (153 loc) · 7.7 KB

API.md

File metadata and controls

252 lines (153 loc) · 7.7 KB

API Reference

Constructs

Grafana

Initializers

import { Grafana } from 'cdk8s-kube-prometheus'

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

scopeRequired
  • Type: constructs.Construct

idRequired
  • Type: string

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
  • Type: cdk8s.ApiObject

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 { Grafana } from 'cdk8s-kube-prometheus'

Grafana.isConstruct(x: any)

Checks if x is a construct.

Use this method instead of instanceof to properly detect Construct instances, even when the construct library is symlinked.

Explanation: in JavaScript, multiple copies of the constructs library on disk are seen as independent, completely different libraries. As a consequence, the class Construct in each copy of the constructs library is seen as a different class, and an instance of one class will not test as instanceof the other class. npm install will not create installations like this, but users may manually symlink construct libraries together or use a monorepo tool: in those cases, multiple copies of the constructs library can be accidentally installed, and instanceof will behave unpredictably. It is safest to avoid using instanceof, and using this type-testing method instead.

xRequired
  • Type: any

Any object.


isChart
import { Grafana } from 'cdk8s-kube-prometheus'

Grafana.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 { Grafana } from 'cdk8s-kube-prometheus'

Grafana.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 cdk8s.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[];
  • Type: cdk8s.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.