Reference

Project Structure

CDK8S project structure for CNPG deployment.

Directory Layout

dp-infra/cnpg/
├── charts/
│   ├── constructs/
│   │   ├── namespace.ts        # Namespace construct
│   │   ├── operator.ts         # CNPG operator HelmChart
│   │   └── barman-plugin.ts    # Barman plugin HelmChart
│   ├── cnpg-chart.ts           # Main chart orchestration
│   └── types.ts                # TypeScript interfaces
├── config.yaml                 # Configuration (versions, settings)
├── main.ts                     # Entry point
├── package.json                # Dependencies and scripts
├── tsconfig.json               # TypeScript configuration
├── cdk8s.yaml                  # CDK8S configuration
├── jest.config.js              # Test configuration
├── manifests/
│   └── cnpg.k8s.yaml          # Generated manifests (committed to git)
└── README.md                   # Project documentation

Key Files

config.yaml

Central configuration for operator and plugin versions. See Configuration Options.

charts/constructs/

TypeScript constructs that generate Kubernetes resources:

  • namespace.ts - Creates cnpg-system namespace (sync-wave 0)

  • operator.ts - Creates CNPG operator HelmChart (sync-wave 1)

  • barman-plugin.ts - Creates barman plugin HelmChart (sync-wave 2)

charts/cnpg-chart.ts

Main chart that orchestrates all constructs:

export class CnpgChart extends Chart {
  constructor(scope: Construct, id: string, config: CnpgConfig) {
    // Wave 0: Namespace
    new NamespaceConstruct(this, 'namespace', { ... });

    // Wave 1: Operator
    new OperatorConstruct(this, 'operator', { ... });

    // Wave 2: Barman Plugin
    new BarmanPluginConstruct(this, 'barman-plugin', { ... });
  }
}

main.ts

Entry point that loads config.yaml and synthesizes manifests:

const config = yaml.load(configFile) as CnpgConfig;
const app = new App();
new CnpgChart(app, 'cnpg', config);
app.synth();

manifests/cnpg.k8s.yaml

Generated Kubernetes manifests. Committed to git for ArgoCD to deploy.

Build Workflow

# Install dependencies
npm install

# Compile TypeScript
npm run compile

# Generate manifests
npm run synth

# Full build (compile + synth)
npm run build

ArgoCD Integration

ArgoCD Application points to the manifests directory:

source:
  repoURL: https://git.bluedynamics.eu/kup6s/dp/dp-infra.git
  path: cnpg/manifests
  targetRevision: main

Sync Waves

Resources deployed in order via sync-wave annotations:

  1. Wave 0: Namespace

  2. Wave 1: CNPG Operator (installs CRDs)

  3. Wave 2: Barman Plugin (requires operator CRDs)