Documentation ¶
Overview ¶
This is the core library of Cloud Development Kit (CDK) for Kubernetes (cdk8s). cdk8s apps synthesize into standard Kubernetes manifests which can be applied to any Kubernetes cluster.
Index ¶
- func JsonPatch_Apply(document interface{}, ops ...JsonPatch) interface{}
- func Lazy_Any(producer IAnyProducer) interface{}
- func Names_ToDnsLabel(scope constructs.Construct, options *NameOptions) *string
- func Names_ToLabelValue(scope constructs.Construct, options *NameOptions) *string
- func NewApiObjectMetadataDefinition_Override(a ApiObjectMetadataDefinition, options *ApiObjectMetadata)
- func NewApiObject_Override(a ApiObject, scope constructs.Construct, id *string, props *ApiObjectProps)
- func NewApp_Override(a App, props *AppProps)
- func NewChart_Override(c Chart, scope constructs.Construct, id *string, props *ChartProps)
- func NewDependencyGraph_Override(d DependencyGraph, node constructs.Node)
- func NewDependencyVertex_Override(d DependencyVertex, value constructs.IConstruct)
- func NewHelm_Override(h Helm, scope constructs.Construct, id *string, props *HelmProps)
- func NewInclude_Override(i Include, scope constructs.Construct, id *string, props *IncludeProps)
- func Testing_Synth(chart Chart) *[]interface{}
- func Yaml_FormatObjects(docs *[]interface{}) *stringdeprecated
- func Yaml_Load(urlOrFile *string) *[]interface{}
- func Yaml_Save(filePath *string, docs *[]interface{})
- func Yaml_Stringify(docs ...interface{}) *string
- func Yaml_Tmp(docs *[]interface{}) *string
- type ApiObject
- type ApiObjectMetadata
- type ApiObjectMetadataDefinition
- type ApiObjectProps
- type App
- type AppProps
- type Chart
- type ChartProps
- type DependencyGraph
- type DependencyVertex
- type Duration
- type GroupVersionKind
- type Helm
- type HelmProps
- type IAnyProducer
- type Include
- type IncludeProps
- type JsonPatch
- func JsonPatch_Add(path *string, value interface{}) JsonPatch
- func JsonPatch_Copy(from *string, path *string) JsonPatch
- func JsonPatch_Move(from *string, path *string) JsonPatch
- func JsonPatch_Remove(path *string) JsonPatch
- func JsonPatch_Replace(path *string, value interface{}) JsonPatch
- func JsonPatch_Test(path *string, value interface{}) JsonPatch
- type Lazy
- type NameOptions
- type Names
- type OwnerReference
- type Size
- type SizeConversionOptions
- type SizeRoundingBehavior
- type Testing
- type TimeConversionOptions
- type Yaml
- type YamlOutputType
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 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 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_FormatObjects
deprecated
added in
v1.2.0
func Yaml_FormatObjects(docs *[]interface{}) *string
Deprecated: use `stringify(doc[, doc, ...])`
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(docs ...interface{}) *string
Stringify a document (or multiple documents) into YAML.
We convert undefined values to null, but ignore any documents that are undefined.
Returns: a YAML string. Multiple docs are separated by `---`.
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"` // Namespaced keys that tell Kubernetes to wait until specific conditions are met before it fully deletes resources marked for deletion. // // Must be empty before the object is deleted from the registry. Each entry is // an identifier for the responsible component that will remove the entry from // the list. If the deletionTimestamp of the object is non-nil, entries in // this list can only be removed. Finalizers may be processed and removed in // any order. Order is NOT enforced because it introduces significant risk of // stuck finalizers. finalizers is a shared field, any actor with permission // can reorder it. If the finalizer list is processed in order, then this can // lead to a situation in which the component responsible for the first // finalizer in the list is waiting for a signal (field value, external // system, or other) produced by a component responsible for a finalizer later // in the list, resulting in a deadlock. Without enforced ordering finalizers // are free to order amongst themselves and are not vulnerable to ordering // changes in the list. // See: https://kubernetes.io/docs/concepts/overview/working-with-objects/finalizers/ // Finalizers *[]*string `json:"finalizers"` // 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"` // List of objects depended by this object. // // If ALL objects in the list have // been deleted, this object will be garbage collected. If this object is // managed by a controller, then an entry in this list will point to this // controller, with the controller field set to true. There cannot be more // than one managing controller. // // Kubernetes sets the value of this field automatically for objects that are // dependents of other objects like ReplicaSets, DaemonSets, Deployments, Jobs // and CronJobs, and ReplicationControllers. You can also configure these // relationships manually by changing the value of this field. However, you // usually don't need to and can allow Kubernetes to automatically manage the // relationships. // See: https://kubernetes.io/docs/concepts/overview/working-with-objects/owners-dependents/ // OwnerReferences *[]*OwnerReference `json:"ownerReferences"` }
Metadata associated with this object.
type ApiObjectMetadataDefinition ¶
type ApiObjectMetadataDefinition interface { Name() *string Namespace() *string Add(key *string, value interface{}) AddAnnotation(key *string, value *string) AddFinalizers(finalizers ...*string) AddLabel(key *string, value *string) AddOwnerReference(owner *OwnerReference) 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 Charts() *[]Chart Outdir() *string YamlOutputType() YamlOutputType OnPrepare() OnSynthesize(session constructs.ISynthesisSession) OnValidate() *[]*string Synth() SynthYaml() interface{} ToString() *string }
Represents a cdk8s application.
func Testing_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"` // How to divide the YAML output into files. YamlOutputType YamlOutputType `json:"yamlOutputType"` }
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
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 ¶
Create a Duration representing an amount of days.
Returns: a new `Duration` representing `amount` Days.
func Duration_Hours ¶
Create a Duration representing an amount of hours.
Returns: a new `Duration` representing `amount` Hours.
func Duration_Millis ¶
Create a Duration representing an amount of milliseconds.
Returns: a new `Duration` representing `amount` ms.
func Duration_Minutes ¶
Create a Duration representing an amount of minutes.
Returns: a new `Duration` representing `amount` Minutes.
func Duration_Parse ¶
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 ¶
Create a Duration representing an amount of seconds.
Returns: a new `Duration` representing `amount` Seconds.
type GroupVersionKind ¶
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.
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 ¶
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 ¶
Copies a value from one location to another within the JSON document.
Both from and path are JSON Pointers.
TODO: EXAMPLE
func JsonPatch_Move ¶
Moves a value from one location to the other.
Both from and path are JSON Pointers.
TODO: EXAMPLE
func JsonPatch_Replace ¶
Replaces a value.
Equivalent to a “remove” followed by an “add”.
TODO: EXAMPLE
func JsonPatch_Test ¶
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 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 OwnerReference ¶ added in v1.1.0
type OwnerReference struct { // API version of the referent. ApiVersion *string `json:"apiVersion"` // Kind of the referent. // See: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds // Kind *string `json:"kind"` // Name of the referent. // See: http://kubernetes.io/docs/user-guide/identifiers#names // Name *string `json:"name"` // UID of the referent. // See: http://kubernetes.io/docs/user-guide/identifiers#uids // Uid *string `json:"uid"` // If true, AND if the owner has the "foregroundDeletion" finalizer, then the owner cannot be deleted from the key-value store until this reference is removed. // // Defaults to false. To set this field, a user needs "delete" // permission of the owner, otherwise 422 (Unprocessable Entity) will be // returned. BlockOwnerDeletion *bool `json:"blockOwnerDeletion"` // If true, this reference points to the managing controller. Controller *bool `json:"controller"` }
OwnerReference contains enough information to let you identify an owning object.
An owning object must be in the same namespace as the dependent, or be cluster-scoped, so there is no namespace field.
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.
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 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 YamlOutputType ¶
type YamlOutputType string
The method to divide YAML output into files.
const ( YamlOutputType_FILE_PER_APP YamlOutputType = "FILE_PER_APP" YamlOutputType_FILE_PER_CHART YamlOutputType = "FILE_PER_CHART" YamlOutputType_FILE_PER_RESOURCE YamlOutputType = "FILE_PER_RESOURCE" )