Skip to main content

Cloud Development Kit for Kubernetes

Project description

cdk8s

Cloud Development Kit for Kubernetes

cdk8s is a software development framework for defining Kubernetes applications using rich object-oriented APIs. It allows developers to leverage the full power of software in order to define abstract components called "constructs" which compose Kubernetes resources or other constructs into higher-level abstractions.

This library is the foundation of cdk8s. It includes base types that are used to define cdk8s applications.

Chart

The Chart is a container that synthesizes a single Kubernetes manifest.

# Example automatically generated without compilation. See https://github.com/aws/jsii/issues/826
class MyChart(Chart):
    def __init__(self, scope, ns):
        super().__init__(scope, ns)

During synthesis, charts collect all the ApiObject nodes (recursively) and emit a single YAML manifest that includes all these objects.

ApiObject

An ApiObject is a construct that represents an entry in a Kubernetes manifest. In most cases, you won't use ApiObject directly but rather use classes that are generated by the cdk8s CLI and extend this base class.

Include

The Include construct can be used to include an existing manifest in a chart.

The following example will include the Kubernetes Dashboard in MyChart:

# Example automatically generated without compilation. See https://github.com/aws/jsii/issues/826
from cdk8s import Include

class MyChart(Chart):
    def __init__(self, scope, id):
        super().__init__(scope, id)

        dashboard = Include(self, "dashboard", {
            "url": "https://raw.githubusercontent.com/kubernetes/dashboard/v2.0.0/aio/deploy/recommended.yaml",
            # or
            "url": "dashboard.yaml"
        })

All API objects defined in the included manifest will be added as children ApiObjects under the Include construct's scope. This implies that you can use Node.of(include).children to inspect them.

The following example queries for all the Deployment resources in the dashboard:

# Example automatically generated without compilation. See https://github.com/aws/jsii/issues/826
deps = Node.of(dashboard).children.filter((c: ApiObject) => c.kind === 'Deployment')

NOTE: names of included objects (metadata.name) are preserved. This means that if you try to include the same manifest twice into the same chart, your manifest will have duplicate definitions of the same objects.

Testing

cdk8s bundles a set of test utilities under the Testing class:

  • Testing.app() returns an App object bound to a temporary output directory.
  • Testing.synth(chart) returns the Kubernetes manifest synthesized from a chart.

License

This project is distributed under the Apache License, Version 2.0.

This module is part of the cdk8s project.

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cdk8s-0.24.0.tar.gz (199.6 kB view details)

Uploaded Source

Built Distribution

cdk8s-0.24.0-py3-none-any.whl (197.8 kB view details)

Uploaded Python 3

File details

Details for the file cdk8s-0.24.0.tar.gz.

File metadata

  • Download URL: cdk8s-0.24.0.tar.gz
  • Upload date:
  • Size: 199.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.7.6

File hashes

Hashes for cdk8s-0.24.0.tar.gz
Algorithm Hash digest
SHA256 b395e1526b70b84445c20c111dcb6817d898b02d333a13de7eea90a738b416a1
MD5 5b4f97bba593a58f0c3cfed0795a43a4
BLAKE2b-256 d4f45e8918ed386718a101bb32cacaa733a17249f2f6fe871674bccd5c9cace3

See more details on using hashes here.

File details

Details for the file cdk8s-0.24.0-py3-none-any.whl.

File metadata

  • Download URL: cdk8s-0.24.0-py3-none-any.whl
  • Upload date:
  • Size: 197.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.7.6

File hashes

Hashes for cdk8s-0.24.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5e80dc56f682737a4d01be6856c31911057ffcd8e0f2d79acf2004a7089ea824
MD5 0fd06cd62f5eca79b5f3babc951a2e34
BLAKE2b-256 cc101eb10ad5ede638001cbb6a267aa7d25b413c0618ebac01df12df2ec97014

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page