Org.Cdk8s.Operator
0.1.475
dotnet add package Org.Cdk8s.Operator --version 0.1.475
NuGet\Install-Package Org.Cdk8s.Operator -Version 0.1.475
<PackageReference Include="Org.Cdk8s.Operator" Version="0.1.475" />
<PackageVersion Include="Org.Cdk8s.Operator" Version="0.1.475" />
<PackageReference Include="Org.Cdk8s.Operator" />
paket add Org.Cdk8s.Operator --version 0.1.475
#r "nuget: Org.Cdk8s.Operator, 0.1.475"
#:package Org.Cdk8s.Operator@0.1.475
#addin nuget:?package=Org.Cdk8s.Operator&version=0.1.475
#tool nuget:?package=Org.Cdk8s.Operator&version=0.1.475
cdk8s-operator
Create Kubernetes CRD Operators using CDK8s Constructs
This is a multi-language (jsii) library and a command-line tool that allows you to create Kubernetes operators for CRDs (Custom Resource Definitions) using CDK8s.
Getting Started
Let's create our first CRD served by a CDK8s construct using TypeScript.
Install CDK8s
Make sure your system has the required CDK8s prerequisites.
Install the CDK8s CLI globally through npm:
$ npm i -g cdk8s-cli
Installing...
# Verify installation
$ cdk8s --version
1.0.0-beta.3
Create a new CDK8s app
Now, let's create a new CDK8s typescript app:
mkdir hello-operator && cd hello-operator
git init
cdk8s init typescript-app
Install cdk8s-operator
Next, let's install this module as a dependency of our TypeScript project:
npm install cdk8s-operator
Construct
We will start by creating the construct that implements the abstraction. This is is just a normal CDK8s custom construct:
Let's create a construct called PodCollection which represents a collection of
pods:
pod-collection.ts:
import { Pod } from 'cdk8s-plus-17';
import { Construct } from 'constructs';
export interface PodCollectionProps {
/** Number of pods */
readonly count: number;
/** The docker image to deploy */
readonly image: string;
}
export class PodCollection extends Construct {
constructor(scope: Construct, id: string, props: PodCollectionProps) {
super(scope, id);
for (let i = 0; i < props.count; ++i) {
new Pod(this, `pod-${i}`, {
containers: [ { image: props.image } ]
});
}
}
}
Operator App
Now, we will need to replace out main.ts file with an "operator app", which is
a special kind of CDK8s app designed to be executed by the cdk8s-server CLI
which is included in this module.
The Operator app construct can be used to create "CDK8s Operators" which are
CDK8s apps that accept input from a file (or STDIN) with a Kubernetes manifest,
instantiates a construct with the spec as its input and emits the resulting
manifest to STDOUT.
Replace the contents of main.ts with the following. We initialize an
Operator app and then register a provider which handles resources of API
version samples.cdk8s.org/v1alpha1 and kind PodCollection.
main.ts:
import { Operator } from 'cdk8s-operator';
import { PodCollection } from './pod-collection';
const app = new Operator();
app.addProvider({
apiVersion: 'samples.cdk8s.org/v1alpha1',
kind: 'PodCollection',
handler: {
apply: (scope, id, props) => new PodCollection(scope, id, props)
}
})
app.synth();
A single operator can handle any number of resource kinds. Simply call
addProvider()for each apiVersion/kind.
Using Operators
To use this operator, create an input.json file, e.g:
input.json:
{
"apiVersion": "samples.cdk8s.org/v1alpha1",
"kind": "PodCollection",
"metadata": {
"name": "my-collection"
},
"spec": {
"image": "paulbouwer/hello-kubernetes",
"count": 5
}
}
Compile your code:
# delete `main.test.ts` since it has some code that won't compile
$ rm -f main.test.*
# compile
$ npm run compile
And run:
$ node main.js input.json
<details> <summary>STDOUT</summary>
apiVersion: "v1"
kind: "Pod"
metadata:
name: "my-collection-pod-0-c8735c52"
spec:
containers:
- env: []
image: "paulbouwer/hello-kubernetes"
imagePullPolicy: "Always"
name: "main"
ports: []
volumeMounts: []
volumes: []
---
apiVersion: "v1"
kind: "Pod"
metadata:
name: "my-collection-pod-1-c89f58d7"
spec:
containers:
- env: []
image: "paulbouwer/hello-kubernetes"
imagePullPolicy: "Always"
name: "main"
ports: []
volumeMounts: []
volumes: []
---
apiVersion: "v1"
kind: "Pod"
metadata:
name: "my-collection-pod-2-c88d4268"
spec:
containers:
- env: []
image: "paulbouwer/hello-kubernetes"
imagePullPolicy: "Always"
name: "main"
ports: []
volumeMounts: []
volumes: []
---
apiVersion: "v1"
kind: "Pod"
metadata:
name: "my-collection-pod-3-c86866b1"
spec:
containers:
- env: []
image: "paulbouwer/hello-kubernetes"
imagePullPolicy: "Always"
name: "main"
ports: []
volumeMounts: []
volumes: []
---
apiVersion: "v1"
kind: "Pod"
metadata:
name: "my-collection-pod-4-c8b74b1d"
spec:
containers:
- env: []
image: "paulbouwer/hello-kubernetes"
imagePullPolicy: "Always"
name: "main"
ports: []
volumeMounts: []
volumes: []
</details>
cdk8s-server
This library is shipped with a program called cdk8s-server which can be used
to host your operator inside an HTTP server. This server can be used as a
sidecar container with a generic CRD operator (TBD).
$ PORT=8080 npx cdk8s-server
Listening on 8080
- App command: node main.js
- Request body should include a single k8s resource in JSON format
- Request will be piped through STDIN to "node main.js"
- Response is the STDOUT and expected to be a multi-resource yaml manifest
Now, you can send input.json over HTTP:
$ curl -d @input.json http://localhost:8080
MANIFEST...
License
Apache 2.0
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net6.0
- Amazon.JSII.Runtime (>= 1.141.0 && < 2.0.0)
- Constructs (>= 10.0.0 && < 11.0.0)
- Org.Cdk8s (>= 2.68.91 && < 3.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 0.1.475 | 57 | 10/5/2026 |
| 0.1.474 | 75 | 10/2/2026 |
| 0.1.473 | 105 | 9/28/2026 |
| 0.1.472 | 94 | 9/27/2026 |
| 0.1.471 | 98 | 9/21/2026 |
| 0.1.470 | 97 | 9/14/2026 |
| 0.1.469 | 115 | 9/7/2026 |
| 0.1.468 | 106 | 9/1/2026 |
| 0.1.467 | 101 | 8/31/2026 |
| 0.1.466 | 110 | 8/29/2026 |
| 0.1.465 | 109 | 8/28/2026 |
| 0.1.464 | 112 | 8/25/2026 |
| 0.1.463 | 111 | 8/24/2026 |
| 0.1.462 | 113 | 8/22/2026 |
| 0.1.461 | 121 | 8/17/2026 |
| 0.1.460 | 119 | 8/13/2026 |
| 0.1.459 | 115 | 8/10/2026 |
| 0.1.458 | 133 | 8/4/2026 |
| 0.1.457 | 124 | 8/3/2026 |
| 0.1.456 | 121 | 7/30/2026 |