0.0.16 • Published 7 months ago

cdk8s-pipelines v0.0.16

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
7 months ago

CDK8s Pipelines

This is a construct for creating Pipelines using cdk8s.

Examples

const pipeline = new Pipeline(this, 'my-pipeline');

Pipeline objects and builders

Tekton Pipelines, Tasks, Workspaces, Parameters, and other resources refer to one another within a pipeline. For example, a Task may have a params that a value that is $(params.foo), meaning it uses the param named foo at the pipeline level within the task.

It is a goal of the builders within this library to simplify that cross-referencing during the process of defining a Pipeline and its tasks, workspaces, and params.

Therefore, within this library there are objects that strictly define the structure of the construct itself and can be synth()'ed to create the Kubernetes resources. You are free to use the constructs and define all the cross-references yourself. For example, here is a Pipeline that defines all resources to create a Pipeline that closely matches the example here:

new Pipeline(this, 'test-pipeline', {
  metadata: {
    name: 'clone-build-push',
  },
  spec: {
    description: 'This pipeline closes a repository, builds a Docker image, etc.',
    params: [
      {
        name: 'repo-url',
        type: 'string',
      },
    ],
    workspaces: [
      {
        name: 'shared-data',
      },
    ],
    tasks: [
      {
        name: 'fetch-source',
        taskRef: {
          name: 'git-clone',
        },
        workspaces: [
          {
            name: 'output',
            workspace: 'shared-data',
          },
        ],
        params: [
          {
            name: 'url',
            value: '$(params.repo-url)',
          },
        ],
      },
    ],
  },
});

Alternatively, using the builders (e.g., PipelineBuilder) for the resources provides a fluid syntax that you can use to add the resources with cross-references made for you automatically. Here is the same construct, but defined using the PipelineBuilder.

new PipelineBuilder(this, 'my-pipeline')
    .withName('clone-build-push')
    .withDescription('This pipeline closes a repository, builds a Docker image, etc.')
    .withTask(new PipelineTaskBuilder()
            .withName('fetch-source')
            .withTaskReference('git-clone')
            .withWorkspace('output', 'shared-data', 'The files cloned by the task')
            .withStringParam('url', 'repo-url', '$(params.repo-url)'))
    .buildPipeline();

The build method on the builders will validate the parameters and, if the object is valid, will create the construct, making sure to add workspace and param resources to the Task as well as the

Any resources that the task requires that needs to be defined at the pipeline

Related projects

This is the core project with the basic Pipeline constructs. There are other constructs that use this construct to develop richer pipelines and tasks that are based on tasks available in Tekton Hub.

  • cdk8s-pipelines-lib - A library of constructs that allows you to easily create Tekton pipelines that use tasks from Tekton Hub and also provides some basic, reusable pipelines.
0.0.16

7 months ago

0.0.15

7 months ago

0.0.14

7 months ago

0.0.13

7 months ago

0.0.12

8 months ago

0.0.11

8 months ago

0.0.10

8 months ago

0.0.9

8 months ago

0.0.8

8 months ago

0.0.7

8 months ago

0.0.6

8 months ago

0.0.5

8 months ago

0.0.4

9 months ago

0.0.3

9 months ago

0.0.2

9 months ago