@jttc/projen-project-types 1.0.0-beta.0 → 1.0.0-beta.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.cz-config.js +83 -43
- package/.czrc +1 -1
- package/.jsii +4637 -14
- package/AGENTS.md +132 -0
- package/API.md +31146 -7
- package/README.md +197 -29
- package/docs/components/cdk8s.md +724 -0
- package/docs/components/commitzent.md +261 -0
- package/docs/components/k3d.md +456 -0
- package/docs/default-configurations.md +267 -0
- package/docs/index.md +86 -1
- package/docs/project-types/cdk-app.md +481 -0
- package/docs/project-types/cdk-library.md +321 -0
- package/docs/project-types/cdk8s-app.md +353 -0
- package/docs/project-types/cdk8s-library.md +442 -0
- package/docs/project-types/nx-monorepo.md +382 -0
- package/lib/cdk/cdk-app-project.d.ts +12 -0
- package/lib/cdk/cdk-app-project.js +28 -0
- package/lib/cdk/cdk-library-project.d.ts +12 -0
- package/lib/cdk/cdk-library-project.js +28 -0
- package/lib/cdk/cdk8s-app-project.d.ts +14 -0
- package/lib/cdk/cdk8s-app-project.js +54 -0
- package/lib/cdk/cdk8s-library-project.d.ts +14 -0
- package/lib/cdk/cdk8s-library-project.js +50 -0
- package/lib/cdk/index.d.ts +5 -0
- package/lib/cdk/index.js +22 -0
- package/lib/cdk/interfaces/cdk-app-options.d.ts +7 -0
- package/lib/cdk/interfaces/cdk-app-options.js +3 -0
- package/lib/cdk/interfaces/cdk-library-options.d.ts +7 -0
- package/lib/cdk/interfaces/cdk-library-options.js +3 -0
- package/lib/cdk/interfaces/cdk8s-app-options.d.ts +18 -0
- package/lib/cdk/interfaces/cdk8s-app-options.js +3 -0
- package/lib/cdk/interfaces/cdk8s-library-options.d.ts +8 -0
- package/lib/cdk/interfaces/cdk8s-library-options.js +3 -0
- package/lib/cdk/interfaces/index.d.ts +5 -0
- package/lib/cdk/interfaces/index.js +22 -0
- package/lib/cdk/interfaces/jsii-options.d.ts +7 -0
- package/lib/cdk/interfaces/jsii-options.js +3 -0
- package/lib/cdk/interfaces/project-global-options.d.ts +15 -0
- package/lib/cdk/interfaces/project-global-options.js +3 -0
- package/lib/cdk/jsii-project.d.ts +12 -0
- package/lib/cdk/jsii-project.js +24 -0
- package/lib/common/common-options.d.ts +40 -0
- package/lib/common/common-options.js +110 -0
- package/lib/components/agents/agents.d.ts +21 -0
- package/lib/components/agents/agents.js +476 -0
- package/lib/components/agents/index.d.ts +1 -0
- package/lib/components/agents/index.js +18 -0
- package/lib/components/cdk8s/cdk8s.d.ts +11 -0
- package/lib/components/cdk8s/cdk8s.js +124 -0
- package/lib/components/cdk8s/index.d.ts +2 -0
- package/lib/components/cdk8s/index.js +19 -0
- package/lib/components/cdk8s/interfaces/Cdk8s.d.ts +34 -0
- package/lib/components/cdk8s/interfaces/Cdk8s.js +12 -0
- package/lib/components/cdk8s/main-library.ts.template +35 -0
- package/lib/components/cdk8s/main.test.ts.template +3 -0
- package/lib/components/cdk8s/main.ts.template +38 -0
- package/lib/components/commitzent/commitzent.d.ts +8 -0
- package/lib/components/commitzent/commitzent.js +100 -0
- package/lib/components/commitzent/index.d.ts +2 -0
- package/lib/components/commitzent/index.js +19 -0
- package/lib/components/commitzent/interfaces/Icommitzent.d.ts +34 -0
- package/lib/components/commitzent/interfaces/Icommitzent.js +3 -0
- package/lib/components/index.d.ts +4 -0
- package/lib/components/index.js +21 -0
- package/lib/components/k3d/index.d.ts +3 -0
- package/lib/components/k3d/index.js +20 -0
- package/lib/components/k3d/k3d.d.ts +33 -0
- package/lib/components/k3d/k3d.js +109 -0
- package/lib/components/k3d/k3dBase.d.ts +4 -0
- package/lib/components/k3d/k3dBase.js +23 -0
- package/lib/components/k3d/types.d.ts +64 -0
- package/lib/components/k3d/types.js +8 -0
- package/lib/index.d.ts +5 -3
- package/lib/index.js +20 -12
- package/lib/monorepo/components/NxConfiguration.d.ts +17 -0
- package/lib/monorepo/components/NxConfiguration.js +105 -0
- package/lib/monorepo/components/index.d.ts +2 -0
- package/lib/monorepo/components/index.js +19 -0
- package/lib/monorepo/components/publish-release.d.ts +5 -0
- package/lib/monorepo/components/publish-release.js +80 -0
- package/lib/monorepo/index.d.ts +3 -0
- package/lib/monorepo/index.js +20 -0
- package/lib/monorepo/interfaces/Nx.d.ts +130 -0
- package/lib/monorepo/interfaces/Nx.js +3 -0
- package/lib/monorepo/interfaces/NxMonorepo.d.ts +3 -0
- package/lib/monorepo/interfaces/NxMonorepo.js +3 -0
- package/lib/monorepo/interfaces/index.d.ts +2 -0
- package/lib/monorepo/interfaces/index.js +19 -0
- package/lib/monorepo/monorepo.d.ts +16 -0
- package/lib/monorepo/monorepo.js +131 -0
- package/lib/terraform/components/index.d.ts +2 -0
- package/lib/terraform/components/index.js +19 -0
- package/lib/terraform/components/terraform-deploy-github-workflow.d.ts +26 -0
- package/lib/terraform/components/terraform-deploy-github-workflow.js +92 -0
- package/lib/terraform/components/terraform-plan-github-workflow.d.ts +31 -0
- package/lib/terraform/components/terraform-plan-github-workflow.js +155 -0
- package/lib/terraform/index.d.ts +5 -0
- package/lib/terraform/index.js +22 -0
- package/lib/terraform/providers/hetzner-provider.d.ts +105 -0
- package/lib/terraform/providers/hetzner-provider.js +83 -0
- package/lib/terraform/providers/index.d.ts +2 -0
- package/lib/terraform/providers/index.js +19 -0
- package/lib/terraform/providers/provider-strategy.d.ts +44 -0
- package/lib/terraform/providers/provider-strategy.js +38 -0
- package/lib/terraform/terraform-base-project.d.ts +38 -0
- package/lib/terraform/terraform-base-project.js +97 -0
- package/lib/terraform/terraform-module-project.d.ts +24 -0
- package/lib/terraform/terraform-module-project.js +77 -0
- package/lib/terraform/terraform-stack-project.d.ts +28 -0
- package/lib/terraform/terraform-stack-project.js +83 -0
- package/mkdocs.yml +12 -0
- package/package.json +14 -7
|
@@ -0,0 +1,442 @@
|
|
|
1
|
+
# CDK8s Library Project
|
|
2
|
+
|
|
3
|
+
The CDK8s Library Project type provides an opinionated setup for creating AWS CDK construct libraries with CDK8s integration for Kubernetes deployment, combining best practices and common configurations.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
This project type extends the standard `AwsCdkConstructLibrary` from projen with additional CDK8s features:
|
|
8
|
+
|
|
9
|
+
- **CDK8s integration** for Kubernetes manifest generation
|
|
10
|
+
- **Multi-version Kubernetes support** (v1.29 to v1.33)
|
|
11
|
+
- **Prettier configuration** and **VSCode settings** - see [Default Configurations](../default-configurations.md)
|
|
12
|
+
- **Common project structure** and tooling setup
|
|
13
|
+
- **Configurable CDK8s options** for custom workflows
|
|
14
|
+
|
|
15
|
+
## Quick Start
|
|
16
|
+
|
|
17
|
+
To create a new CDK8s Library project, use the projen CLI:
|
|
18
|
+
|
|
19
|
+
```bash linenums="1"
|
|
20
|
+
npx projen new --from @jttc/projen-project-types cdk8s-library
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
This command will create a new project with the CDK8s Library template and prompt you for the required configuration options such as:
|
|
24
|
+
|
|
25
|
+
- Project name
|
|
26
|
+
- Author information
|
|
27
|
+
- Repository URL
|
|
28
|
+
- CDK version
|
|
29
|
+
- Kubernetes version
|
|
30
|
+
- Default branch
|
|
31
|
+
|
|
32
|
+
After the project is created, you can customize it further by editing the `.projenrc.ts` file:
|
|
33
|
+
|
|
34
|
+
```typescript linenums="1" title=".projenrc.ts" hl_lines="4 8 12 13 14 15"
|
|
35
|
+
import { Cdk8sLibrary } from '@jttc/projen-project-types';
|
|
36
|
+
import { K8sVersion } from '@jttc/projen-project-types';
|
|
37
|
+
|
|
38
|
+
const project = new Cdk8sLibrary({
|
|
39
|
+
name: 'my-awesome-cdk8s-library',
|
|
40
|
+
author: 'Your Name',
|
|
41
|
+
authorAddress: 'your.email@example.com',
|
|
42
|
+
repositoryUrl: 'https://github.com/yourusername/my-awesome-cdk8s-library.git',
|
|
43
|
+
cdkVersion: '2.1.0',
|
|
44
|
+
defaultReleaseBranch: 'main',
|
|
45
|
+
|
|
46
|
+
// CDK8s specific configuration
|
|
47
|
+
k8sVersion: K8sVersion.V1_31,
|
|
48
|
+
appPath: 'src/k8s',
|
|
49
|
+
outputPath: 'manifests',
|
|
50
|
+
imports: ['custom-k8s-constructs@1.0.0'],
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
project.synth();
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
**Highlighted lines explanation:**
|
|
57
|
+
|
|
58
|
+
- **Line 4**: Choose a descriptive name for your CDK8s construct library
|
|
59
|
+
- **Line 8**: Pin to a specific CDK version for consistency
|
|
60
|
+
- **Line 13**: Set the Kubernetes version for CDK8s imports
|
|
61
|
+
- **Line 14**: Configure custom path for Kubernetes source code
|
|
62
|
+
- **Line 15**: Set output directory for generated manifests
|
|
63
|
+
- **Line 16**: Add custom Kubernetes imports
|
|
64
|
+
|
|
65
|
+
## Features
|
|
66
|
+
|
|
67
|
+
### CDK8s Integration
|
|
68
|
+
|
|
69
|
+
The CDK8s Library project includes full CDK8s integration with:
|
|
70
|
+
|
|
71
|
+
- **Automatic CDK8s setup** with configurable Kubernetes versions
|
|
72
|
+
- **Import generation** from Kubernetes APIs and custom resources
|
|
73
|
+
- **TypeScript-first** Kubernetes manifest authoring
|
|
74
|
+
- **CDK8s tasks** for building and synthesizing manifests
|
|
75
|
+
|
|
76
|
+
### Kubernetes Version Support
|
|
77
|
+
|
|
78
|
+
Choose from multiple supported Kubernetes versions:
|
|
79
|
+
|
|
80
|
+
| Version | CDK8s Plus Package | Description |
|
|
81
|
+
|---------|-------------------|-------------|
|
|
82
|
+
| v1.29 | `cdk8s-plus-29` | Kubernetes 1.29 API support |
|
|
83
|
+
| v1.30 | `cdk8s-plus-30` | Kubernetes 1.30 API support (default) |
|
|
84
|
+
| v1.31 | `cdk8s-plus-31` | Kubernetes 1.31 API support |
|
|
85
|
+
| v1.32 | `cdk8s-plus-32` | Kubernetes 1.32 API support |
|
|
86
|
+
| v1.33 | `cdk8s-plus-33` | Kubernetes 1.33 API support |
|
|
87
|
+
|
|
88
|
+
### Common Configurations
|
|
89
|
+
|
|
90
|
+
This project type includes the same common configurations as other project types:
|
|
91
|
+
|
|
92
|
+
!!! info "Default Configurations"
|
|
93
|
+
For complete details about Prettier and VSCode configurations, see [Default Configurations](../default-configurations.md). This includes:
|
|
94
|
+
|
|
95
|
+
- [Prettier Configuration](../default-configurations.md#prettier-configuration) - Code formatting rules and customization
|
|
96
|
+
- [VSCode Configuration](../default-configurations.md#vscode-configuration) - Editor settings and recommended extensions
|
|
97
|
+
|
|
98
|
+
## Configuration Options
|
|
99
|
+
|
|
100
|
+
### Basic Configuration
|
|
101
|
+
|
|
102
|
+
All standard `AwsCdkConstructLibraryOptions` are supported, plus CDK8s-specific options:
|
|
103
|
+
|
|
104
|
+
```typescript linenums="1" title="Basic CDK8s Library Configuration"
|
|
105
|
+
const project = new Cdk8sLibrary({
|
|
106
|
+
// Required CDK options
|
|
107
|
+
name: 'my-cdk8s-library',
|
|
108
|
+
author: 'Your Name',
|
|
109
|
+
authorAddress: 'your.email@example.com',
|
|
110
|
+
repositoryUrl: 'https://github.com/yourusername/my-cdk8s-library.git',
|
|
111
|
+
cdkVersion: '2.1.0',
|
|
112
|
+
defaultReleaseBranch: 'main',
|
|
113
|
+
|
|
114
|
+
// Optional CDK8s configurations (see sections below)
|
|
115
|
+
});
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
### CDK8s-Specific Options
|
|
119
|
+
|
|
120
|
+
#### Kubernetes Version
|
|
121
|
+
|
|
122
|
+
```typescript linenums="1" title="Kubernetes Version Configuration" hl_lines="3"
|
|
123
|
+
import { K8sVersion } from '@jttc/projen-project-types';
|
|
124
|
+
|
|
125
|
+
const project = new Cdk8sLibrary({
|
|
126
|
+
// ... other options
|
|
127
|
+
k8sVersion: K8sVersion.V1_31, // Default: V1_30
|
|
128
|
+
});
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
#### Custom Paths
|
|
132
|
+
|
|
133
|
+
Configure where CDK8s files are located:
|
|
134
|
+
|
|
135
|
+
```typescript linenums="1" title="Custom Path Configuration" hl_lines="3 4 5"
|
|
136
|
+
const project = new Cdk8sLibrary({
|
|
137
|
+
// ... other options
|
|
138
|
+
appPath: 'src/k8s', // Default: 'src'
|
|
139
|
+
appFile: 'app.ts', // Default: 'main.ts'
|
|
140
|
+
outputPath: 'manifests', // Default: 'kubernetes'
|
|
141
|
+
});
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
#### Custom Imports
|
|
145
|
+
|
|
146
|
+
Add additional Kubernetes resource imports:
|
|
147
|
+
|
|
148
|
+
```typescript linenums="1" title="Custom Imports Configuration" hl_lines="3 4 5 6"
|
|
149
|
+
const project = new Cdk8sLibrary({
|
|
150
|
+
// ... other options
|
|
151
|
+
imports: [
|
|
152
|
+
'cert-manager@v1.8.0',
|
|
153
|
+
'prometheus-operator@v0.60.0',
|
|
154
|
+
'custom-crds@latest',
|
|
155
|
+
],
|
|
156
|
+
});
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
### Common Configuration Options
|
|
160
|
+
|
|
161
|
+
For Prettier and VSCode configuration options, refer to [Default Configurations](../default-configurations.md):
|
|
162
|
+
|
|
163
|
+
- **Prettier**: [Customization Guide](../default-configurations.md#customization)
|
|
164
|
+
- **VSCode**: [Configuration Options](../default-configurations.md#customization)
|
|
165
|
+
|
|
166
|
+
## Examples
|
|
167
|
+
|
|
168
|
+
### Basic CDK8s Library
|
|
169
|
+
|
|
170
|
+
Simple setup with default configurations:
|
|
171
|
+
|
|
172
|
+
```typescript linenums="1" title=".projenrc.ts - Basic Setup"
|
|
173
|
+
import { Cdk8sLibrary } from '@jttc/projen-project-types';
|
|
174
|
+
|
|
175
|
+
const project = new Cdk8sLibrary({
|
|
176
|
+
name: 'basic-cdk8s-library',
|
|
177
|
+
author: 'Jane Smith',
|
|
178
|
+
authorAddress: 'jane@company.com',
|
|
179
|
+
repositoryUrl: 'https://github.com/company/basic-cdk8s-library.git',
|
|
180
|
+
cdkVersion: '2.1.0',
|
|
181
|
+
defaultReleaseBranch: 'main',
|
|
182
|
+
});
|
|
183
|
+
|
|
184
|
+
project.synth();
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
### Advanced CDK8s Library
|
|
188
|
+
|
|
189
|
+
Customized setup with specific Kubernetes version and custom paths:
|
|
190
|
+
|
|
191
|
+
```typescript linenums="1" title=".projenrc.ts - Advanced Setup" hl_lines="10 11 12 13 14 15 16 17 18 19"
|
|
192
|
+
import { Cdk8sLibrary, K8sVersion } from '@jttc/projen-project-types';
|
|
193
|
+
|
|
194
|
+
const project = new Cdk8sLibrary({
|
|
195
|
+
name: 'advanced-cdk8s-library',
|
|
196
|
+
author: 'John Developer',
|
|
197
|
+
authorAddress: 'john@company.com',
|
|
198
|
+
repositoryUrl: 'https://github.com/company/advanced-cdk8s-library.git',
|
|
199
|
+
cdkVersion: '2.1.0',
|
|
200
|
+
defaultReleaseBranch: 'main',
|
|
201
|
+
|
|
202
|
+
// CDK8s customization
|
|
203
|
+
k8sVersion: K8sVersion.V1_31,
|
|
204
|
+
appPath: 'src/kubernetes',
|
|
205
|
+
appFile: 'main.ts',
|
|
206
|
+
outputPath: 'dist/manifests',
|
|
207
|
+
imports: [
|
|
208
|
+
'cert-manager@v1.13.0',
|
|
209
|
+
'prometheus-operator@v0.70.0',
|
|
210
|
+
],
|
|
211
|
+
|
|
212
|
+
// Standard configurations (see Default Configurations for options)
|
|
213
|
+
prettier: true,
|
|
214
|
+
vscode: true,
|
|
215
|
+
});
|
|
216
|
+
|
|
217
|
+
project.synth();
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
**Highlighted lines explanation:**
|
|
221
|
+
|
|
222
|
+
- **Line 12**: Use Kubernetes v1.31 APIs
|
|
223
|
+
- **Line 13**: Place CDK8s source files in `src/kubernetes/`
|
|
224
|
+
- **Line 14**: Main entry file for CDK8s application
|
|
225
|
+
- **Line 15**: Output generated manifests to `dist/manifests/`
|
|
226
|
+
- **Lines 16-19**: Import cert-manager and Prometheus operator CRDs
|
|
227
|
+
|
|
228
|
+
### Enterprise Setup
|
|
229
|
+
|
|
230
|
+
Example with minimal prettier configuration and disabled VSCode:
|
|
231
|
+
|
|
232
|
+
```typescript linenums="1" title=".projenrc.ts - Enterprise Setup" hl_lines="11 15 16 17 18 19 20 21"
|
|
233
|
+
import { Cdk8sLibrary, K8sVersion } from '@jttc/projen-project-types';
|
|
234
|
+
|
|
235
|
+
const project = new Cdk8sLibrary({
|
|
236
|
+
name: 'enterprise-cdk8s-library',
|
|
237
|
+
author: 'Enterprise Team',
|
|
238
|
+
authorAddress: 'team@enterprise.com',
|
|
239
|
+
repositoryUrl: 'https://github.com/enterprise/cdk8s-library.git',
|
|
240
|
+
cdkVersion: '2.1.0',
|
|
241
|
+
defaultReleaseBranch: 'main',
|
|
242
|
+
|
|
243
|
+
k8sVersion: K8sVersion.V1_32,
|
|
244
|
+
|
|
245
|
+
// Custom configurations (see Default Configurations for more options)
|
|
246
|
+
vscode: false,
|
|
247
|
+
prettierOptions: {
|
|
248
|
+
settings: {
|
|
249
|
+
printWidth: 120,
|
|
250
|
+
tabWidth: 4,
|
|
251
|
+
singleQuote: false,
|
|
252
|
+
},
|
|
253
|
+
},
|
|
254
|
+
});
|
|
255
|
+
|
|
256
|
+
project.synth();
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
**Highlighted lines explanation:**
|
|
260
|
+
|
|
261
|
+
- **Line 11**: Use latest supported Kubernetes version
|
|
262
|
+
- **Line 15**: Disable VSCode configuration for enterprise environment
|
|
263
|
+
- **Lines 16-21**: Custom prettier settings with longer lines and double quotes
|
|
264
|
+
|
|
265
|
+
## Project Structure
|
|
266
|
+
|
|
267
|
+
After running `projen synth`, your CDK8s library project will have the following structure:
|
|
268
|
+
|
|
269
|
+
```
|
|
270
|
+
my-cdk8s-library/
|
|
271
|
+
├── src/
|
|
272
|
+
│ ├── main.ts # Main CDK8s application entry point
|
|
273
|
+
│ └── index.ts # Library exports
|
|
274
|
+
├── test/ # Test files
|
|
275
|
+
├── kubernetes/ # Generated Kubernetes manifests (after synth)
|
|
276
|
+
├── cdk8s.yaml # CDK8s configuration
|
|
277
|
+
├── package.json # Dependencies including CDK8s packages
|
|
278
|
+
├── .prettierrc.json # Code formatting configuration
|
|
279
|
+
├── .vscode/ # VSCode workspace settings
|
|
280
|
+
│ ├── settings.json
|
|
281
|
+
│ └── extensions.json
|
|
282
|
+
└── .projenrc.ts # Projen configuration
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
### Generated CDK8s Files
|
|
286
|
+
|
|
287
|
+
- **`src/main.ts`**: Sample CDK8s application with basic Kubernetes resources
|
|
288
|
+
- **`cdk8s.yaml`**: CDK8s configuration specifying app entry point and output location
|
|
289
|
+
- **`kubernetes/`**: Directory where synthesized YAML manifests are generated
|
|
290
|
+
|
|
291
|
+
### CDK8s Tasks
|
|
292
|
+
|
|
293
|
+
The project includes these npm scripts for CDK8s workflows:
|
|
294
|
+
|
|
295
|
+
| Script | Command | Description |
|
|
296
|
+
|--------|---------|-------------|
|
|
297
|
+
| `cdk8s` | `cdk8s synth` | Generate Kubernetes manifests |
|
|
298
|
+
| `cdk8s:import` | `cdk8s import` | Import Kubernetes APIs and CRDs |
|
|
299
|
+
| `cdk8s:synth` | `cdk8s synth` | Alias for `cdk8s` command |
|
|
300
|
+
|
|
301
|
+
## Best Practices
|
|
302
|
+
|
|
303
|
+
### Development Workflow
|
|
304
|
+
|
|
305
|
+
1. **Define your constructs** in TypeScript using CDK8s APIs
|
|
306
|
+
2. **Import CRDs** for custom resources: `npm run cdk8s:import`
|
|
307
|
+
3. **Generate manifests** regularly: `npm run cdk8s`
|
|
308
|
+
4. **Test generated YAML** with your Kubernetes cluster
|
|
309
|
+
5. **Version your library** using standard npm/projen publishing
|
|
310
|
+
|
|
311
|
+
### Resource Organization
|
|
312
|
+
|
|
313
|
+
```typescript linenums="1" title="src/main.ts - Recommended Structure"
|
|
314
|
+
import { App, Chart } from 'cdk8s';
|
|
315
|
+
import { Deployment, Service } from 'cdk8s-plus-31';
|
|
316
|
+
|
|
317
|
+
export class MyConstruct extends Chart {
|
|
318
|
+
constructor(scope: App, id: string) {
|
|
319
|
+
super(scope, id);
|
|
320
|
+
|
|
321
|
+
// Define your Kubernetes resources here
|
|
322
|
+
const deployment = new Deployment(this, 'app-deployment', {
|
|
323
|
+
// ... configuration
|
|
324
|
+
});
|
|
325
|
+
|
|
326
|
+
const service = new Service(this, 'app-service', {
|
|
327
|
+
// ... configuration
|
|
328
|
+
});
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
// For library usage
|
|
333
|
+
const app = new App();
|
|
334
|
+
new MyConstruct(app, 'my-construct');
|
|
335
|
+
app.synth();
|
|
336
|
+
```
|
|
337
|
+
|
|
338
|
+
### Testing Strategy
|
|
339
|
+
|
|
340
|
+
- **Unit test** your CDK8s constructs with Jest
|
|
341
|
+
- **Snapshot test** generated manifests
|
|
342
|
+
- **Integration test** with real Kubernetes clusters
|
|
343
|
+
- **Validate** YAML output with kubeval or similar tools
|
|
344
|
+
|
|
345
|
+
## Troubleshooting
|
|
346
|
+
|
|
347
|
+
### Common Issues
|
|
348
|
+
|
|
349
|
+
#### Import Errors
|
|
350
|
+
|
|
351
|
+
If you encounter CDK8s import errors:
|
|
352
|
+
|
|
353
|
+
```bash
|
|
354
|
+
# Reimport Kubernetes APIs
|
|
355
|
+
npm run cdk8s:import
|
|
356
|
+
|
|
357
|
+
# Check your cdk8s.yaml configuration
|
|
358
|
+
cat cdk8s.yaml
|
|
359
|
+
```
|
|
360
|
+
|
|
361
|
+
#### Version Mismatches
|
|
362
|
+
|
|
363
|
+
Ensure your Kubernetes version matches your cluster:
|
|
364
|
+
|
|
365
|
+
```typescript
|
|
366
|
+
// Update in .projenrc.ts
|
|
367
|
+
k8sVersion: K8sVersion.V1_31, // Match your cluster version
|
|
368
|
+
```
|
|
369
|
+
|
|
370
|
+
#### Path Issues
|
|
371
|
+
|
|
372
|
+
Verify your CDK8s paths are correctly configured:
|
|
373
|
+
|
|
374
|
+
```yaml title="cdk8s.yaml"
|
|
375
|
+
language: typescript
|
|
376
|
+
app: npx ts-node src/main.ts
|
|
377
|
+
output: kubernetes
|
|
378
|
+
```
|
|
379
|
+
|
|
380
|
+
### Getting Help
|
|
381
|
+
|
|
382
|
+
- **CDK8s Documentation**: [https://cdk8s.io/](https://cdk8s.io/)
|
|
383
|
+
- **Project Issues**: [GitHub Issues](https://github.com/JumpToTheCloud/projen-project-types/issues)
|
|
384
|
+
- **AWS CDK**: [https://docs.aws.amazon.com/cdk/](https://docs.aws.amazon.com/cdk/)
|
|
385
|
+
|
|
386
|
+
## Migration Guide
|
|
387
|
+
|
|
388
|
+
### From Standard CDK Library
|
|
389
|
+
|
|
390
|
+
To migrate from a standard CDK library to CDK8s library:
|
|
391
|
+
|
|
392
|
+
1. **Update your `.projenrc.ts`**:
|
|
393
|
+
```typescript
|
|
394
|
+
// Before
|
|
395
|
+
import { CdkLibrary } from '@jttc/projen-project-types';
|
|
396
|
+
|
|
397
|
+
// After
|
|
398
|
+
import { Cdk8sLibrary } from '@jttc/projen-project-types';
|
|
399
|
+
```
|
|
400
|
+
|
|
401
|
+
2. **Add CDK8s configuration**:
|
|
402
|
+
```typescript
|
|
403
|
+
const project = new Cdk8sLibrary({
|
|
404
|
+
// ... existing options
|
|
405
|
+
k8sVersion: K8sVersion.V1_31,
|
|
406
|
+
});
|
|
407
|
+
```
|
|
408
|
+
|
|
409
|
+
3. **Run projen to regenerate**:
|
|
410
|
+
```bash
|
|
411
|
+
npx projen
|
|
412
|
+
```
|
|
413
|
+
|
|
414
|
+
### From Plain CDK8s
|
|
415
|
+
|
|
416
|
+
To adopt this project type from a plain CDK8s project:
|
|
417
|
+
|
|
418
|
+
1. **Install the package**:
|
|
419
|
+
```bash
|
|
420
|
+
npm install --save-dev @jttc/projen-project-types
|
|
421
|
+
```
|
|
422
|
+
|
|
423
|
+
2. **Create `.projenrc.ts`** with your current configuration
|
|
424
|
+
3. **Run projen** to apply the project template
|
|
425
|
+
4. **Review and commit** the generated configuration files
|
|
426
|
+
|
|
427
|
+
## Contributing
|
|
428
|
+
|
|
429
|
+
Contributions to improve the CDK8s Library project type are welcome! Please check the repository for details on:
|
|
430
|
+
|
|
431
|
+
- Reporting bugs
|
|
432
|
+
- Suggesting enhancements
|
|
433
|
+
- Submitting pull requests
|
|
434
|
+
- Development workflow
|
|
435
|
+
|
|
436
|
+
## Support
|
|
437
|
+
|
|
438
|
+
For support with the CDK8s Library project type:
|
|
439
|
+
|
|
440
|
+
- **Repository**: [GitHub Repository](https://github.com/JumpToTheCloud/projen-project-types)
|
|
441
|
+
- **Issues**: [GitHub Issues](https://github.com/JumpToTheCloud/projen-project-types/issues)
|
|
442
|
+
- **Discussions**: [GitHub Discussions](https://github.com/JumpToTheCloud/projen-project-types/discussions)
|