cdk8s

package module
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 31, 2021 License: Apache-2.0 Imports: 5 Imported by: 1

README

cdk8s

Cloud Development Kit for Kubernetes

Beta

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.

Documentation

See cdk8s.io.

License

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

This module is part of the cdk8s project.

Documentation

Overview

Cloud Development Kit for Kubernetes

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func JsonPatch_Apply

func JsonPatch_Apply(document interface{}, ops ...JsonPatch) interface{}

Applies a set of JSON-Patch (RFC-6902) operations to `document` and returns the result.

Returns: The result document

func Lazy_Any

func Lazy_Any(producer IAnyProducer) interface{}

func Names_ToDnsLabel

func Names_ToDnsLabel(scope constructs.Construct, options *NameOptions) *string

Generates a unique and stable name compatible DNS_LABEL from RFC-1123 from a path.

The generated name will:

  • contain at most 63 characters
  • contain only lowercase alphanumeric characters or ‘-’
  • start with an alphanumeric character
  • end with an alphanumeric character

The generated name will have the form:

<comp0>-<comp1>-..-<compN>-<short-hash>

Where <comp> are the path components (assuming they are is separated by "/").

Note that if the total length is longer than 63 characters, we will trim the first components since the last components usually encode more meaning.

func Names_ToLabelValue

func Names_ToLabelValue(scope constructs.Construct, options *NameOptions) *string

Generates a unique and stable name compatible label key name segment and label value from a path.

The name segment is required and must be 63 characters or less, beginning and ending with an alphanumeric character ([a-z0-9A-Z]) with dashes (-), underscores (_), dots (.), and alphanumerics between.

Valid label values must be 63 characters or less and must be empty or begin and end with an alphanumeric character ([a-z0-9A-Z]) with dashes (-), underscores (_), dots (.), and alphanumerics between.

The generated name will have the form:

<comp0><delim><comp1><delim>..<delim><compN><delim><short-hash>

Where <comp> are the path components (assuming they are is separated by "/").

Note that if the total length is longer than 63 characters, we will trim the first components since the last components usually encode more meaning.

func NewApiObjectMetadataDefinition_Override

func NewApiObjectMetadataDefinition_Override(a ApiObjectMetadataDefinition, options *ApiObjectMetadata)

func NewApiObject_Override

func NewApiObject_Override(a ApiObject, scope constructs.Construct, id *string, props *ApiObjectProps)

Defines an API object.

func NewApp_Override

func NewApp_Override(a App, props *AppProps)

Defines an app.

func NewChart_Override

func NewChart_Override(c Chart, scope constructs.Construct, id *string, props *ChartProps)

func NewDependencyGraph_Override

func NewDependencyGraph_Override(d DependencyGraph, node constructs.Node)

func NewDependencyVertex_Override

func NewDependencyVertex_Override(d DependencyVertex, value constructs.IConstruct)

func NewHelm_Override

func NewHelm_Override(h Helm, scope constructs.Construct, id *string, props *HelmProps)

func NewInclude_Override

func NewInclude_Override(i Include, scope constructs.Construct, id *string, props *IncludeProps)

func Testing_Synth

func Testing_Synth(chart Chart) *[]interface{}

Returns the Kubernetes manifest synthesized from this chart.

func Yaml_Load

func Yaml_Load(urlOrFile *string) *[]interface{}

Downloads a set of YAML documents (k8s manifest for example) from a URL or a file and returns them as javascript objects.

Empty documents are filtered out.

Returns: an array of objects, each represents a document inside the YAML

func Yaml_Save

func Yaml_Save(filePath *string, docs *[]interface{})

Saves a set of objects as a multi-document YAML file.

func Yaml_Stringify

func Yaml_Stringify(doc interface{}) *string

Stringify a document into yaml.

func Yaml_Tmp

func Yaml_Tmp(docs *[]interface{}) *string

Saves a set of YAML documents into a temp file (in /tmp).

Returns: the path to the temporary file

Types

type ApiObject

type ApiObject interface {
	constructs.Construct
	ApiGroup() *string
	ApiVersion() *string
	Chart() Chart
	Kind() *string
	Metadata() ApiObjectMetadataDefinition
	Name() *string
	AddDependency(dependencies ...constructs.IConstruct)
	AddJsonPatch(ops ...JsonPatch)
	OnPrepare()
	OnSynthesize(session constructs.ISynthesisSession)
	OnValidate() *[]*string
	ToJson() interface{}
	ToString() *string
}

func ApiObject_Of

func ApiObject_Of(c constructs.IConstruct) ApiObject

Returns the `ApiObject` named `Resource` which is a child of the given construct.

If `c` is an `ApiObject`, it is returned directly. Throws an exception if the construct does not have a child named `Default` _or_ if this child is not an `ApiObject`.

func NewApiObject

func NewApiObject(scope constructs.Construct, id *string, props *ApiObjectProps) ApiObject

Defines an API object.

type ApiObjectMetadata

type ApiObjectMetadata struct {
	// Annotations is an unstructured key value map stored with a resource that may be set by external tools to store and retrieve arbitrary metadata.
	//
	// They are not queryable and should be
	// preserved when modifying objects.
	// See: http://kubernetes.io/docs/user-guide/annotations
	//
	Annotations *map[string]*string `json:"annotations"`
	// Map of string keys and values that can be used to organize and categorize (scope and select) objects.
	//
	// May match selectors of replication controllers and services.
	// See: http://kubernetes.io/docs/user-guide/labels
	//
	Labels *map[string]*string `json:"labels"`
	// The unique, namespace-global, name of this object inside the Kubernetes cluster.
	//
	// Normally, you shouldn't specify names for objects and let the CDK generate
	// a name for you that is application-unique. The names CDK generates are
	// composed from the construct path components, separated by dots and a suffix
	// that is based on a hash of the entire path, to ensure uniqueness.
	//
	// You can supply custom name allocation logic by overriding the
	// `chart.generateObjectName` method.
	//
	// If you use an explicit name here, bear in mind that this reduces the
	// composability of your construct because it won't be possible to include
	// more than one instance in any app. Therefore it is highly recommended to
	// leave this unspecified.
	Name *string `json:"name"`
	// Namespace defines the space within each name must be unique.
	//
	// An empty namespace is equivalent to the "default" namespace, but "default" is the canonical representation.
	// Not all objects are required to be scoped to a namespace - the value of this field for those objects will be empty. Must be a DNS_LABEL. Cannot be updated. More info: http://kubernetes.io/docs/user-guide/namespaces
	Namespace *string `json:"namespace"`
}

Metadata associated with this object.

type ApiObjectMetadataDefinition

type ApiObjectMetadataDefinition interface {
	Name() *string
	Namespace() *string
	Add(key *string, value interface{})
	AddAnnotation(key *string, value *string)
	AddLabel(key *string, value *string)
	GetLabel(key *string) *string
	ToJson() interface{}
}

Object metadata.

func NewApiObjectMetadataDefinition

func NewApiObjectMetadataDefinition(options *ApiObjectMetadata) ApiObjectMetadataDefinition

type ApiObjectProps

type ApiObjectProps struct {
	// API version.
	ApiVersion *string `json:"apiVersion"`
	// Resource kind.
	Kind *string `json:"kind"`
	// Object metadata.
	//
	// If `name` is not specified, an app-unique name will be allocated by the
	// framework based on the path of the construct within thes construct tree.
	Metadata *ApiObjectMetadata `json:"metadata"`
}

Options for defining API objects.

type App

type App interface {
	constructs.Construct
	Outdir() *string
	OnPrepare()
	OnSynthesize(session constructs.ISynthesisSession)
	OnValidate() *[]*string
	Synth()
	ToString() *string
}

Represents a cdk8s application.

func NewApp

func NewApp(props *AppProps) App

Defines an app.

func Testing_App

func Testing_App() App

Returns an app for testing with the following properties: - Output directory is a temp dir.

type AppProps

type AppProps struct {
	// The directory to output Kubernetes manifests.
	Outdir *string `json:"outdir"`
}

type Chart

type Chart interface {
	constructs.Construct
	Labels() *map[string]*string
	Namespace() *string
	AddDependency(dependencies ...constructs.IConstruct)
	GenerateObjectName(apiObject ApiObject) *string
	OnPrepare()
	OnSynthesize(session constructs.ISynthesisSession)
	OnValidate() *[]*string
	ToJson() *[]interface{}
	ToString() *string
}

func Chart_Of

func Chart_Of(c constructs.IConstruct) Chart

Finds the chart in which a node is defined.

func NewChart

func NewChart(scope constructs.Construct, id *string, props *ChartProps) Chart

func Testing_Chart

func Testing_Chart() Chart

Returns: a Chart that can be used for tests

type ChartProps

type ChartProps struct {
	// Labels to apply to all resources in this chart.
	Labels *map[string]*string `json:"labels"`
	// The default namespace for all objects defined in this chart (directly or indirectly).
	//
	// This namespace will only apply to objects that don't have a
	// `namespace` explicitly defined for them.
	Namespace *string `json:"namespace"`
}

type DependencyGraph

type DependencyGraph interface {
	Root() DependencyVertex
	Topology() *[]constructs.IConstruct
}

Represents the dependency graph for a given Node.

This graph includes the dependency relationships between all nodes in the node (construct) sub-tree who's root is this Node.

Note that this means that lonely nodes (no dependencies and no dependants) are also included in this graph as childless children of the root node of the graph.

The graph does not include cross-scope dependencies. That is, if a child on the current scope depends on a node from a different scope, that relationship is not represented in this graph.

func NewDependencyGraph

func NewDependencyGraph(node constructs.Node) DependencyGraph

type DependencyVertex

type DependencyVertex interface {
	Inbound() *[]DependencyVertex
	Outbound() *[]DependencyVertex
	Value() constructs.IConstruct
	AddChild(dep DependencyVertex)
	Topology() *[]constructs.IConstruct
}

Represents a vertex in the graph.

The value of each vertex is an `IConstruct` that is accessible via the `.value` getter.

func NewDependencyVertex

func NewDependencyVertex(value constructs.IConstruct) DependencyVertex

type Duration

type Duration interface {
	ToDays(opts *TimeConversionOptions) *float64
	ToHours(opts *TimeConversionOptions) *float64
	ToHumanString() *string
	ToIsoString() *string
	ToMilliseconds(opts *TimeConversionOptions) *float64
	ToMinutes(opts *TimeConversionOptions) *float64
	ToSeconds(opts *TimeConversionOptions) *float64
}

Represents a length of time.

The amount can be specified either as a literal value (e.g: `10`) which cannot be negative.

func Duration_Days

func Duration_Days(amount *float64) Duration

Create a Duration representing an amount of days.

Returns: a new `Duration` representing `amount` Days.

func Duration_Hours

func Duration_Hours(amount *float64) Duration

Create a Duration representing an amount of hours.

Returns: a new `Duration` representing `amount` Hours.

func Duration_Millis

func Duration_Millis(amount *float64) Duration

Create a Duration representing an amount of milliseconds.

Returns: a new `Duration` representing `amount` ms.

func Duration_Minutes

func Duration_Minutes(amount *float64) Duration

Create a Duration representing an amount of minutes.

Returns: a new `Duration` representing `amount` Minutes.

func Duration_Parse

func Duration_Parse(duration *string) Duration

Parse a period formatted according to the ISO 8601 standard.

Returns: the parsed `Duration`. See: https://www.iso.org/fr/standard/70907.html

func Duration_Seconds

func Duration_Seconds(amount *float64) Duration

Create a Duration representing an amount of seconds.

Returns: a new `Duration` representing `amount` Seconds.

type GroupVersionKind

type GroupVersionKind struct {
	// The object's API version (e.g. `authorization.k8s.io/v1`).
	ApiVersion *string `json:"apiVersion"`
	// The object kind.
	Kind *string `json:"kind"`
}

type Helm

type Helm interface {
	Include
	ApiObjects() *[]ApiObject
	ReleaseName() *string
	OnPrepare()
	OnSynthesize(session constructs.ISynthesisSession)
	OnValidate() *[]*string
	ToString() *string
}

Represents a Helm deployment.

Use this construct to import an existing Helm chart and incorporate it into your constructs.

func NewHelm

func NewHelm(scope constructs.Construct, id *string, props *HelmProps) Helm

type HelmProps

type HelmProps struct {
	// The chart name to use. It can be a chart from a helm repository or a local directory.
	//
	// This name is passed to `helm template` and has all the relevant semantics.
	//
	// TODO: EXAMPLE
	//
	Chart *string `json:"chart"`
	// The local helm executable to use in order to create the manifest the chart.
	HelmExecutable *string `json:"helmExecutable"`
	// Additional flags to add to the `helm` execution.
	HelmFlags *[]*string `json:"helmFlags"`
	// The release name.
	// See: https://helm.sh/docs/intro/using_helm/#three-big-concepts
	//
	ReleaseName *string `json:"releaseName"`
	// Values to pass to the chart.
	Values *map[string]interface{} `json:"values"`
}

Options for `Helm`.

type IAnyProducer

type IAnyProducer interface {
	Produce() interface{}
}

type Include

type Include interface {
	constructs.Construct
	ApiObjects() *[]ApiObject
	OnPrepare()
	OnSynthesize(session constructs.ISynthesisSession)
	OnValidate() *[]*string
	ToString() *string
}

Reads a YAML manifest from a file or a URL and defines all resources as API objects within the defined scope.

The names (`metadata.name`) of imported resources will be preserved as-is from the manifest.

func NewInclude

func NewInclude(scope constructs.Construct, id *string, props *IncludeProps) Include

type IncludeProps

type IncludeProps struct {
	// Local file path or URL which includes a Kubernetes YAML manifest.
	//
	// TODO: EXAMPLE
	//
	Url *string `json:"url"`
}

type JsonPatch

type JsonPatch interface {
}

Utility for applying RFC-6902 JSON-Patch to a document.

Use the the `JsonPatch.apply(doc, ...ops)` function to apply a set of operations to a JSON document and return the result.

Operations can be created using the factory methods `JsonPatch.add()`, `JsonPatch.remove()`, etc.

TODO: EXAMPLE

func JsonPatch_Add

func JsonPatch_Add(path *string, value interface{}) JsonPatch

Adds a value to an object or inserts it into an array.

In the case of an array, the value is inserted before the given index. The - character can be used instead of an index to insert at the end of an array.

TODO: EXAMPLE

func JsonPatch_Copy

func JsonPatch_Copy(from *string, path *string) JsonPatch

Copies a value from one location to another within the JSON document.

Both from and path are JSON Pointers.

TODO: EXAMPLE

func JsonPatch_Move

func JsonPatch_Move(from *string, path *string) JsonPatch

Moves a value from one location to the other.

Both from and path are JSON Pointers.

TODO: EXAMPLE

func JsonPatch_Remove

func JsonPatch_Remove(path *string) JsonPatch

Removes a value from an object or array.

TODO: EXAMPLE

func JsonPatch_Replace

func JsonPatch_Replace(path *string, value interface{}) JsonPatch

Replaces a value.

Equivalent to a “remove” followed by an “add”.

TODO: EXAMPLE

func JsonPatch_Test

func JsonPatch_Test(path *string, value interface{}) JsonPatch

Tests that the specified value is set in the document.

If the test fails, then the patch as a whole should not apply.

TODO: EXAMPLE

type Lazy

type Lazy interface {
	Produce() interface{}
}

type NameOptions

type NameOptions struct {
	// Delimiter to use between components.
	Delimiter *string `json:"delimiter"`
	// Extra components to include in the name.
	Extra *[]*string `json:"extra"`
	// Include a short hash as last part of the name.
	IncludeHash *bool `json:"includeHash"`
	// Maximum allowed length for the name.
	MaxLen *float64 `json:"maxLen"`
}

Options for name generation.

type Names

type Names interface {
}

Utilities for generating unique and stable names.

type Size

type Size interface {
	ToGibibytes(opts *SizeConversionOptions) *float64
	ToKibibytes(opts *SizeConversionOptions) *float64
	ToMebibytes(opts *SizeConversionOptions) *float64
	ToPebibytes(opts *SizeConversionOptions) *float64
	ToTebibytes(opts *SizeConversionOptions) *float64
}

Represents the amount of digital storage.

The amount can be specified either as a literal value (e.g: `10`) which cannot be negative.

When the amount is passed as a token, unit conversion is not possible.

func Size_Gibibytes

func Size_Gibibytes(amount *float64) Size

Create a Storage representing an amount gibibytes.

1 GiB = 1024 MiB

func Size_Kibibytes

func Size_Kibibytes(amount *float64) Size

Create a Storage representing an amount kibibytes.

1 KiB = 1024 bytes

func Size_Mebibytes

func Size_Mebibytes(amount *float64) Size

Create a Storage representing an amount mebibytes.

1 MiB = 1024 KiB

func Size_Pebibyte

func Size_Pebibyte(amount *float64) Size

Create a Storage representing an amount pebibytes.

1 PiB = 1024 TiB

func Size_Tebibytes

func Size_Tebibytes(amount *float64) Size

Create a Storage representing an amount tebibytes.

1 TiB = 1024 GiB

type SizeConversionOptions

type SizeConversionOptions struct {
	// How conversions should behave when it encounters a non-integer result.
	Rounding SizeRoundingBehavior `json:"rounding"`
}

Options for how to convert time to a different unit.

type SizeRoundingBehavior

type SizeRoundingBehavior string

Rounding behaviour when converting between units of `Size`.

const (
	SizeRoundingBehavior_FAIL  SizeRoundingBehavior = "FAIL"
	SizeRoundingBehavior_FLOOR SizeRoundingBehavior = "FLOOR"
	SizeRoundingBehavior_NONE  SizeRoundingBehavior = "NONE"
)

type Testing

type Testing interface {
}

Testing utilities for cdk8s applications.

type TimeConversionOptions

type TimeConversionOptions struct {
	// If `true`, conversions into a larger time unit (e.g. `Seconds` to `Minutes`) will fail if the result is not an integer.
	Integral *bool `json:"integral"`
}

Options for how to convert time to a different unit.

type Yaml

type Yaml interface {
}

YAML utilities.

Directories

Path Synopsis
Package jsii contains the functionaility needed for jsii packages to initialize their dependencies and themselves.
Package jsii contains the functionaility needed for jsii packages to initialize their dependencies and themselves.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL