A CDK8s app which allows implementing Kubernetes operators using CDK8s constructs.
import { Operator } from 'cdk8s-operator'
new Operator(props?: OperatorProps)
Name | Type | Description |
---|---|---|
props |
OperatorProps |
No description. |
- Type: OperatorProps
Name | Description |
---|---|
toString |
Returns a string representation of this construct. |
synth |
Reads a Kubernetes manifest in JSON format from STDIN or the file specified as the first positional command-line argument. |
synthYaml |
Synthesizes the app into a YAML string. |
addProvider |
Adds a custom resource provider to this operator. |
public toString(): string
Returns a string representation of this construct.
public synth(): void
Reads a Kubernetes manifest in JSON format from STDIN or the file specified as the first positional command-line argument.
This manifest is expected to
include a single Kubernetes resource. Then, we match apiVersion
and
kind
to one of the registered providers and if we do, we invoke
apply()
, passing it the spec
of the input manifest and a chart as a
scope. The chart is then synthesized and the output manifest is written to
STDOUT.
public synthYaml(): string
Synthesizes the app into a YAML string.
public addProvider(provider: CustomResourceProvider): void
Adds a custom resource provider to this operator.
- Type: CustomResourceProvider
The provider to add.
Name | Description |
---|---|
isConstruct |
Checks if x is a construct. |
of |
No description. |
import { Operator } from 'cdk8s-operator'
Operator.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.
- Type: any
Any object.
import { Operator } from 'cdk8s-operator'
Operator.of(c: IConstruct)
- Type: constructs.IConstruct
Name | Type | Description |
---|---|---|
node |
constructs.Node |
The tree node. |
charts |
cdk8s.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 |
cdk8s.IResolver[] |
Resolvers used by this app. |
yamlOutputType |
cdk8s.YamlOutputType |
How to divide the YAML output into files. |
public readonly node: Node;
- Type: constructs.Node
The tree node.
public readonly charts: Chart[];
- Type: cdk8s.Chart[]
Returns all the charts in this app, sorted topologically.
public readonly outdir: string;
- Type: string
The output directory into which manifests will be synthesized.
public readonly outputFileExtension: string;
- Type: string
- Default: .k8s.yaml
The file extension to use for rendered YAML files.
public readonly resolvers: IResolver[];
- Type: cdk8s.IResolver[]
Resolvers used by this app.
This includes both custom resolvers
passed by the resolvers
property, as well as built-in resolvers.
public readonly yamlOutputType: YamlOutputType;
- Type: cdk8s.YamlOutputType
- Default: YamlOutputType.FILE_PER_CHART
How to divide the YAML output into files.
import { CustomResourceProvider } from 'cdk8s-operator'
const customResourceProvider: CustomResourceProvider = { ... }
Name | Type | Description |
---|---|---|
apiVersion |
string |
API version of the custom resource. |
handler |
ICustomResourceProviderHandler |
The construct handler. |
kind |
string |
Kind of this custom resource. |
public readonly apiVersion: string;
- Type: string
- Default: "v1"
API version of the custom resource.
public readonly handler: ICustomResourceProviderHandler;
The construct handler.
public readonly kind: string;
- Type: string
Kind of this custom resource.
import { OperatorProps } from 'cdk8s-operator'
const operatorProps: OperatorProps = { ... }
Name | Type | Description |
---|---|---|
inputFile |
string |
A Kubernetes JSON manifest with a single resource that is matched against one of the providers within this operator. |
outputFile |
string |
Where to write the synthesized output. |
public readonly inputFile: string;
- Type: string
- Default: first position command-line argument or "/dev/stdin"
A Kubernetes JSON manifest with a single resource that is matched against one of the providers within this operator.
public readonly outputFile: string;
- Type: string
- Default: "/dev/stdout"
Where to write the synthesized output.
import { ServerProps } from 'cdk8s-operator'
const serverProps: ServerProps = { ... }
Name | Type | Description |
---|---|---|
appCommand |
string |
The command to execute in order to synthesize the CDK app. |
public readonly appCommand: string;
- Type: string
The command to execute in order to synthesize the CDK app.
import { Server } from 'cdk8s-operator'
new Server(props: ServerProps)
Name | Type | Description |
---|---|---|
props |
ServerProps |
No description. |
- Type: ServerProps
Name | Description |
---|---|
close |
Stop server. |
listen |
Starts HTTP server. |
public close(): void
Stop server.
public listen(port?: number): number
Starts HTTP server.
- Type: number
The port to listen to.
If not specified, the PORT
environment
variable will be used. If that's not specified an available port will be
auto-selected.
- Implemented By: ICustomResourceProviderHandler
The handler for this custom resource provider.
Name | Description |
---|---|
apply |
No description. |
public apply(scope: Construct, id: string, spec: any): Construct
- Type: constructs.Construct
- Type: string
- Type: any