@kumori/kumori-module-generator
TypeScript icon, indicating that this package has built-in type declarations

1.1.0 • Public • Published

Kumori Module Generator

Build Component Module

const component: ComponentSpec = {
  type: "component",
  tenantId: "",
  accountId: "",
  environmentId: "",
  deploymentId: "",
  moduleDomain: "kumori.systems",
  moduleId: "http-echo",
  moduleVersion: [0, 0, 1],
  labels: {},
  bundleTargetDir: "",
  bundleTargetKind: "",
  channels: {
    client: ["client_channel1", "client_channel2", "client_channel3"],
    server: [
      { name: "server_channel1", port: 1234 },
      { name: "server_channel2", port: 4321 },
      { name: "server_channel3", port: 5432 },
    ]
  },
  cpuRequirements: 1234,
  memoryRequirements: 4321,
  registryUrl: "docker.io",
  imageTag: "mendhak/http-https-echo:31",
  registrySecret: "",
  defaultExecutable: {
    cmd: "test test1 test2 test3",
    entrypoint: "test test1 test2 test3"
  },
  config: {
    parameters: [
      { name: "EXAMPLE_ENV_VAR_1", defaultValue: "value1", type: "string" },
      {
        name: "my_file_content", defaultValue: `My value for the file 2. \\Testing \\text \\scape
My value for the file 2. \\Testing \\text \\scape
My value for the file 2. \\Testing \\text \\scape
My value for the file 2. \\Testing \\text \\scape
My value for the file 2. \\Testing \\text \\scape
My value for the file 2. \\Testing \\text \\scape
My value for the file 2. \\Testing \\text \\scape`, type: "string"
      },
      { name: "param3", defaultValue: "3", type: "number" },
      { name: "param4", defaultValue: "true", type: "bool" },
    ],
    resources: [
      { secret: { name: "my_secret1" } },
      { secret: { name: "my_secret2" } },
      { secret: { name: "my_secret3" } },
      { ca: { name: "my_ca" } },
      { volume: { name: "my_volume" } },
      { domain: { name: "my_domain" } },
      { port: { name: "my_port" } },
      { certificate: { name: "my_certificate" } },
    ]
  },
  environment: [
    { varName: "EXAMPLE_ENV_VAR_1", param: "EXAMPLE_ENV_VAR_1" },
    { varName: "EXAMPLE_ENV_VAR_2", param: "param2" },
    { varName: "EXAMPLE_ENV_VAR_3", param: "param3" },
    { varName: "EXAMPLE_ENV_VAR_4", param: "param4" },
    { varName: "SUPERSECRET", secret: "my_secret1" },
  ],
  filesystem: [
    { path: "/test/mount/volume", resourceVolume: "my_volume" },
    { path: "/test/mount/file", param: "my_file_content" }
  ]
}

await buildComponentModule(component)

Build Service Module

const service: ServiceSpec = {
  type: "service",
  tenantId: "",
  accountId: "",
  environmentId: "",
  deploymentId: "",
  moduleDomain: "kumori.systems",
  moduleId: "codeserver-service",
  moduleVersion: [0, 0, 1],
  labels: {},
  bundleTargetDir: "",
  bundleTargetKind: "",
  channels: {
    client: ["client_channel1"],
    server: [
      { name: "server_channel1" },
    ]
  },
  config: {
    parameters: [
      { name: "vscode_size", defaultValue: "5", type: "number" },
      { name: "vscode_data", defaultValue: "XYZ", type: "string" },
      { name: "vscode_userid", defaultValue: "ZYX", type: "string" },
    ],
    resources: [
      { certificate: { name: "main_inbound_servercert" } },
      { domain: { name: "main_inbound_serverdomain" } },
      { ca: { name: "main_inbound_clientcertca" } },
    ],
  },
  roles: [
    {
      name: "vscode",
      artifact: {
        artifactKind: "component",
        moduleDomain: "kumori.systems",
        moduleName: "porting/codeserver",
        moduleVersion: [1, 0, 4],
        artifactName: "./base",
        config: {
          parameters: [
            { name: "size", configParam: "vscode_size", type: "number" },
            { name: "protect", value: "false", type: "bool" },
            { name: "data", configParam: "vscode_data", type: "string" },
            { name: "userid", configParam: "vscode_userid", type: "string", },
          ],
          resources: [],
        }
      }
    },
    {
      name: "inbound",
      artifact: {
        artifactKind: "service",
        moduleDomain: "kumori.systems",
        moduleName: "builtins/inbound",
        moduleVersion: [1, 3, 0],
        artifactName: "./",
        config: {
          parameters: [
            { name: "type", value: "https", type: "string" },
            { name: "websocket", value: "true", type: "bool" },
            { name: "clientcert", value: "true", type: "bool" },
            { name: "certrequired", value: "false", type: "bool" },
          ],
          resources: [
            { certificate: { name: "servercert", configResource: "main_inbound_servercert" } },
            { domain: { name: "serverdomain", configResource: "main_inbound_serverdomain" } },
            { ca: { name: "clientcertca", configResource: "main_inbound_clientcertca" } },
          ],
        }
      }
    }
  ],
  topology: [
    {
      clientRole: "self",
      clientChannel: "server_channel1",
      serverRole: "vscode",
      serverChannel: "main",
    },
    {
      clientRole: "vscode",
      clientChannel: "psql",
      serverRole: "self",
      serverChannel: "client_channel1",
    },
    {
      clientRole: "inbound",
      clientChannel: "inbound",
      serverRole: "vscode",
      serverChannel: "main",
    }
  ],
}

await buildServiceModule(service)

Build Component Deployment Module

await buildComponentDeploymentModule({
  ...component,
  deploymentConfig: {
    parameters: [
      { name: "param1", value: "value1", type: "string" },
      { name: "param2", value: "value2", type: "string" },
      { name: "param3", value: "3", type: "number" },
      { name: "param4", value: "true", type: "bool" },
    ],
    resources: [
      { secret: { name: "my_secret1", resource: "real_secret1" } },
      { secret: { name: "my_secret2", resource: "real_secret2" } },
      { secret: { name: "my_secret3", resource: "real_secret3" } },
      { ca: { name: "my_ca", resource: "real_ca" } },
      { volume: { name: "my_volume", resource: "real_volume" } },
      { volume: { name: "my_volume2", volume: { size: 5, unit: "M" } } },
      { domain: { name: "my_domain", resource: "real_domain" } },
      { port: { name: "my_port", resource: "real_port" } },
      { certificate: { name: "my_certificate", resource: "real_certificate" } },
    ],
    scale: 3
  },
})

Build Service Deployment Module

await buildServiceDeploymentModule({
  ...service,
  deploymentConfig: {
    parameters: [
      { name: "vscode_size", value: "1", type: "number" },
      { name: "vscode_data", value: "Test_generator", type: "string" },
      { name: "vscode_userid", value: "Generator_test", type: "string" },
    ],
    resources: [
      { certificate: { name: "main_inbound_servercert", resource: "cluster.core/wildcard-vera-kumori-cloud" } },
      { domain: { name: "main_inbound_serverdomain", resource: "test_serverdomain" } },
      { ca: { name: "main_inbound_clientcertca", resource: "cluster.core/rootca" } },
    ],
    scale: {
      detail: {
        "vscode": 1
      }
    }
  },
})

Readme

Keywords

none

Package Sidebar

Install

npm i @kumori/kumori-module-generator

Weekly Downloads

21

Version

1.1.0

License

ISC

Unpacked Size

46.5 kB

Total Files

32

Last publish

Collaborators

  • schinesta
  • juavabar
  • jbgisbert
  • javiku
  • josepba