Documentation
¶
Overview ¶
cdk8s+ is a software development framework that provides high level abstractions for authoring Kubernetes applications. cdk8s-plus-22 synthesizes Kubernetes manifests for Kubernetes 1.22.0
Index ¶
- func NewConfigMap_Override(c ConfigMap, scope constructs.Construct, id *string, props *ConfigMapProps)
- func NewContainer_Override(c Container, props *ContainerProps)
- func NewDeployment_Override(d Deployment, scope constructs.Construct, id *string, props *DeploymentProps)
- func NewIngress_Override(i Ingress, scope constructs.Construct, id *string, props *IngressProps)
- func NewJob_Override(j Job, scope constructs.Construct, id *string, props *JobProps)
- func NewPodSpec_Override(p PodSpec, props *PodSpecProps)
- func NewPodTemplate_Override(p PodTemplate, props *PodTemplateProps)
- func NewPod_Override(p Pod, scope constructs.Construct, id *string, props *PodProps)
- func NewProbe_Override(p Probe)
- func NewResource_Override(r Resource, scope constructs.Construct, id *string, ...)
- func NewSecret_Override(s Secret, scope constructs.Construct, id *string, props *SecretProps)
- func NewServiceAccount_Override(s ServiceAccount, scope constructs.Construct, id *string, ...)
- func NewService_Override(s Service, scope constructs.Construct, id *string, props *ServiceProps)
- func NewStatefulSet_Override(s StatefulSet, scope constructs.Construct, id *string, props *StatefulSetProps)
- func NewVolume_Override(v Volume, name *string, config interface{})
- type AddDeploymentOptions
- type AddDirectoryOptions
- type CommandProbeOptions
- type ConfigMap
- type ConfigMapProps
- type ConfigMapVolumeOptions
- type Container
- type ContainerProps
- type Deployment
- type DeploymentProps
- type EmptyDirMedium
- type EmptyDirVolumeOptions
- type EnvFieldPaths
- type EnvValue
- func EnvValue_FromConfigMap(configMap IConfigMap, key *string, options *EnvValueFromConfigMapOptions) EnvValue
- func EnvValue_FromFieldRef(fieldPath EnvFieldPaths, options *EnvValueFromFieldRefOptions) EnvValue
- func EnvValue_FromProcess(key *string, options *EnvValueFromProcessOptions) EnvValue
- func EnvValue_FromResource(resource ResourceFieldPaths, options *EnvValueFromResourceOptions) EnvValue
- func EnvValue_FromSecretValue(secretValue *SecretValue, options *EnvValueFromSecretOptions) EnvValue
- func EnvValue_FromValue(value *string) EnvValue
- type EnvValueFromConfigMapOptions
- type EnvValueFromFieldRefOptions
- type EnvValueFromProcessOptions
- type EnvValueFromResourceOptions
- type EnvValueFromSecretOptions
- type ExposeDeploymentViaIngressOptions
- type ExposeDeploymentViaServiceOptions
- type ExposeServiceViaIngressOptions
- type HttpGetProbeOptions
- type HttpIngressPathType
- type IConfigMap
- type IPodSpec
- type IPodTemplate
- type IResource
- type ISecret
- type IServiceAccount
- type ImagePullPolicy
- type Ingress
- type IngressBackend
- type IngressProps
- type IngressRule
- type IngressTls
- type Job
- type JobProps
- type MountOptions
- type MountPropagation
- type PathMapping
- type Pod
- type PodManagementPolicy
- type PodProps
- type PodSpec
- type PodSpecProps
- type PodTemplate
- type PodTemplateProps
- type Probe
- type ProbeOptions
- type Protocol
- type Resource
- type ResourceFieldPaths
- type ResourceProps
- type RestartPolicy
- type Secret
- type SecretProps
- type SecretValue
- type SecretVolumeOptions
- type Service
- type ServiceAccount
- type ServiceAccountProps
- type ServiceIngressBackendOptions
- type ServicePort
- type ServicePortOptions
- type ServiceProps
- type ServiceType
- type StatefulSet
- type StatefulSetProps
- type Volume
- type VolumeMount
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewConfigMap_Override ¶
func NewConfigMap_Override(c ConfigMap, scope constructs.Construct, id *string, props *ConfigMapProps)
func NewContainer_Override ¶
func NewContainer_Override(c Container, props *ContainerProps)
func NewDeployment_Override ¶
func NewDeployment_Override(d Deployment, scope constructs.Construct, id *string, props *DeploymentProps)
func NewIngress_Override ¶
func NewIngress_Override(i Ingress, scope constructs.Construct, id *string, props *IngressProps)
func NewJob_Override ¶
func NewPodSpec_Override ¶
func NewPodSpec_Override(p PodSpec, props *PodSpecProps)
func NewPodTemplate_Override ¶
func NewPodTemplate_Override(p PodTemplate, props *PodTemplateProps)
func NewPod_Override ¶
func NewProbe_Override ¶
func NewProbe_Override(p Probe)
func NewResource_Override ¶
func NewResource_Override(r Resource, scope constructs.Construct, id *string, options *constructs.ConstructOptions)
Creates a new construct node.
func NewSecret_Override ¶
func NewSecret_Override(s Secret, scope constructs.Construct, id *string, props *SecretProps)
func NewServiceAccount_Override ¶
func NewServiceAccount_Override(s ServiceAccount, scope constructs.Construct, id *string, props *ServiceAccountProps)
func NewService_Override ¶
func NewService_Override(s Service, scope constructs.Construct, id *string, props *ServiceProps)
func NewStatefulSet_Override ¶
func NewStatefulSet_Override(s StatefulSet, scope constructs.Construct, id *string, props *StatefulSetProps)
func NewVolume_Override ¶
Types ¶
type AddDeploymentOptions ¶
type AddDeploymentOptions struct { // The name of this port within the service. // // This must be a DNS_LABEL. All // ports within a ServiceSpec must have unique names. This maps to the 'Name' // field in EndpointPort objects. Optional if only one ServicePort is defined // on this service. Name *string `json:"name" yaml:"name"` // The port on each node on which this service is exposed when type=NodePort or LoadBalancer. // // Usually assigned by the system. If specified, it will be // allocated to the service if unused or else creation of the service will // fail. Default is to auto-allocate a port if the ServiceType of this Service // requires one. // See: https://kubernetes.io/docs/concepts/services-networking/service/#type-nodeport // NodePort *float64 `json:"nodePort" yaml:"nodePort"` // The IP protocol for this port. // // Supports "TCP", "UDP", and "SCTP". Default is TCP. Protocol Protocol `json:"protocol" yaml:"protocol"` // The port number the service will redirect to. TargetPort *float64 `json:"targetPort" yaml:"targetPort"` // The port number the service will bind to. Port *float64 `json:"port" yaml:"port"` }
Options to add a deployment to a service.
type AddDirectoryOptions ¶
type AddDirectoryOptions struct { // Glob patterns to exclude when adding files. Exclude *[]*string `json:"exclude" yaml:"exclude"` // A prefix to add to all keys in the config map. KeyPrefix *string `json:"keyPrefix" yaml:"keyPrefix"` }
Options for `configmap.addDirectory()`.
type CommandProbeOptions ¶
type CommandProbeOptions struct { // Minimum consecutive failures for the probe to be considered failed after having succeeded. // // Defaults to 3. Minimum value is 1. FailureThreshold *float64 `json:"failureThreshold" yaml:"failureThreshold"` // Number of seconds after the container has started before liveness probes are initiated. // See: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes // InitialDelaySeconds cdk8s.Duration `json:"initialDelaySeconds" yaml:"initialDelaySeconds"` // How often (in seconds) to perform the probe. // // Default to 10 seconds. Minimum value is 1. PeriodSeconds cdk8s.Duration `json:"periodSeconds" yaml:"periodSeconds"` // Minimum consecutive successes for the probe to be considered successful after having failed. Defaults to 1. // // Must be 1 for liveness and startup. Minimum value is 1. SuccessThreshold *float64 `json:"successThreshold" yaml:"successThreshold"` // Number of seconds after which the probe times out. // // Defaults to 1 second. Minimum value is 1. // See: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes // TimeoutSeconds cdk8s.Duration `json:"timeoutSeconds" yaml:"timeoutSeconds"` }
Options for `Probe.fromCommand()`.
type ConfigMap ¶
type ConfigMap interface { Resource IConfigMap ApiObject() cdk8s.ApiObject BinaryData() *map[string]*string Data() *map[string]*string Metadata() cdk8s.ApiObjectMetadataDefinition Name() *string AddBinaryData(key *string, value *string) AddData(key *string, value *string) AddDirectory(localDir *string, options *AddDirectoryOptions) AddFile(localFile *string, key *string) OnPrepare() OnSynthesize(session constructs.ISynthesisSession) OnValidate() *[]*string ToString() *string }
ConfigMap holds configuration data for pods to consume.
func NewConfigMap ¶
func NewConfigMap(scope constructs.Construct, id *string, props *ConfigMapProps) ConfigMap
type ConfigMapProps ¶
type ConfigMapProps struct { // Metadata that all persisted resources must have, which includes all objects users must create. Metadata *cdk8s.ApiObjectMetadata `json:"metadata" yaml:"metadata"` // BinaryData contains the binary data. // // Each key must consist of alphanumeric characters, '-', '_' or '.'. // BinaryData can contain byte sequences that are not in the UTF-8 range. The // keys stored in BinaryData must not overlap with the ones in the Data field, // this is enforced during validation process. Using this field will require // 1.10+ apiserver and kubelet. // // You can also add binary data using `configMap.addBinaryData()`. BinaryData *map[string]*string `json:"binaryData" yaml:"binaryData"` // Data contains the configuration data. // // Each key must consist of alphanumeric characters, '-', '_' or '.'. Values // with non-UTF-8 byte sequences must use the BinaryData field. The keys // stored in Data must not overlap with the keys in the BinaryData field, this // is enforced during validation process. // // You can also add data using `configMap.addData()`. Data *map[string]*string `json:"data" yaml:"data"` }
Properties for initialization of `ConfigMap`.
type ConfigMapVolumeOptions ¶
type ConfigMapVolumeOptions struct { // Mode bits to use on created files by default. // // Must be a value between 0 and // 0777. Defaults to 0644. Directories within the path are not affected by // this setting. This might be in conflict with other options that affect the // file mode, like fsGroup, and the result can be other mode bits set. DefaultMode *float64 `json:"defaultMode" yaml:"defaultMode"` // If unspecified, each key-value pair in the Data field of the referenced ConfigMap will be projected into the volume as a file whose name is the key and content is the value. // // If specified, the listed keys will be projected // into the specified paths, and unlisted keys will not be present. If a key // is specified which is not present in the ConfigMap, the volume setup will // error unless it is marked optional. Paths must be relative and may not // contain the '..' path or start with '..'. Items *map[string]*PathMapping `json:"items" yaml:"items"` // The volume name. Name *string `json:"name" yaml:"name"` // Specify whether the ConfigMap or its keys must be defined. Optional *bool `json:"optional" yaml:"optional"` }
Options for the ConfigMap-based volume.
type Container ¶
type Container interface { Args() *[]*string Command() *[]*string Env() *map[string]EnvValue Image() *string ImagePullPolicy() ImagePullPolicy Mounts() *[]*VolumeMount Name() *string Port() *float64 WorkingDir() *string AddEnv(name *string, value EnvValue) Mount(path *string, volume Volume, options *MountOptions) }
A single application container that you want to run within a pod.
func NewContainer ¶
func NewContainer(props *ContainerProps) Container
type ContainerProps ¶
type ContainerProps struct { // Docker image name. Image *string `json:"image" yaml:"image"` // Arguments to the entrypoint. The docker image's CMD is used if `command` is not provided. // // Variable references $(VAR_NAME) are expanded using the container's // environment. If a variable cannot be resolved, the reference in the input // string will be unchanged. The $(VAR_NAME) syntax can be escaped with a // double $$, ie: $$(VAR_NAME). Escaped references will never be expanded, // regardless of whether the variable exists or not. // // Cannot be updated. // See: https://kubernetes.io/docs/tasks/inject-data-application/define-command-argument-container/#running-a-command-in-a-shell // Args *[]*string `json:"args" yaml:"args"` // Entrypoint array. // // Not executed within a shell. The docker image's ENTRYPOINT is used if this is not provided. Variable references $(VAR_NAME) are expanded using the container's environment. // If a variable cannot be resolved, the reference in the input string will be unchanged. The $(VAR_NAME) syntax can be escaped with a double $$, ie: $$(VAR_NAME). // Escaped references will never be expanded, regardless of whether the variable exists or not. Cannot be updated. // More info: https://kubernetes.io/docs/tasks/inject-data-application/define-command-argument-container/#running-a-command-in-a-shell Command *[]*string `json:"command" yaml:"command"` // List of environment variables to set in the container. // // Cannot be updated. Env *map[string]EnvValue `json:"env" yaml:"env"` // Image pull policy for this container. ImagePullPolicy ImagePullPolicy `json:"imagePullPolicy" yaml:"imagePullPolicy"` // Periodic probe of container liveness. // // Container will be restarted if the probe fails. Liveness Probe `json:"liveness" yaml:"liveness"` // Name of the container specified as a DNS_LABEL. // // Each container in a pod must have a unique name (DNS_LABEL). Cannot be updated. Name *string `json:"name" yaml:"name"` // Number of port to expose on the pod's IP address. // // This must be a valid port number, 0 < x < 65536. Port *float64 `json:"port" yaml:"port"` // Determines when the container is ready to serve traffic. Readiness Probe `json:"readiness" yaml:"readiness"` // StartupProbe indicates that the Pod has successfully initialized. // // If specified, no other probes are executed until this completes successfully Startup Probe `json:"startup" yaml:"startup"` // Pod volumes to mount into the container's filesystem. // // Cannot be updated. VolumeMounts *[]*VolumeMount `json:"volumeMounts" yaml:"volumeMounts"` // Container's working directory. // // If not specified, the container runtime's default will be used, which might be configured in the container image. Cannot be updated. WorkingDir *string `json:"workingDir" yaml:"workingDir"` }
Properties for creating a container.
type Deployment ¶
type Deployment interface { Resource IPodTemplate ApiObject() cdk8s.ApiObject Containers() *[]Container LabelSelector() *map[string]*string Metadata() cdk8s.ApiObjectMetadataDefinition Name() *string PodMetadata() cdk8s.ApiObjectMetadataDefinition Replicas() *float64 RestartPolicy() RestartPolicy ServiceAccount() IServiceAccount Volumes() *[]Volume AddContainer(container *ContainerProps) Container AddVolume(volume Volume) ExposeViaIngress(path *string, options *ExposeDeploymentViaIngressOptions) Ingress ExposeViaService(options *ExposeDeploymentViaServiceOptions) Service OnPrepare() OnSynthesize(session constructs.ISynthesisSession) OnValidate() *[]*string SelectByLabel(key *string, value *string) ToString() *string }
A Deployment provides declarative updates for Pods and ReplicaSets.
You describe a desired state in a Deployment, and the Deployment Controller changes the actual state to the desired state at a controlled rate. You can define Deployments to create new ReplicaSets, or to remove existing Deployments and adopt all their resources with new Deployments.
> Note: Do not manage ReplicaSets owned by a Deployment. Consider opening an issue in the main Kubernetes repository if your use case is not covered below.
Use Case ---------
The following are typical use cases for Deployments:
- Create a Deployment to rollout a ReplicaSet. The ReplicaSet creates Pods in the background. Check the status of the rollout to see if it succeeds or not.
- Declare the new state of the Pods by updating the PodTemplateSpec of the Deployment. A new ReplicaSet is created and the Deployment manages moving the Pods from the old ReplicaSet to the new one at a controlled rate. Each new ReplicaSet updates the revision of the Deployment.
- Rollback to an earlier Deployment revision if the current state of the Deployment is not stable. Each rollback updates the revision of the Deployment.
- Scale up the Deployment to facilitate more load.
- Pause the Deployment to apply multiple fixes to its PodTemplateSpec and then resume it to start a new rollout.
- Use the status of the Deployment as an indicator that a rollout has stuck.
- Clean up older ReplicaSets that you don't need anymore.
func NewDeployment ¶
func NewDeployment(scope constructs.Construct, id *string, props *DeploymentProps) Deployment
type DeploymentProps ¶
type DeploymentProps struct { // Metadata that all persisted resources must have, which includes all objects users must create. Metadata *cdk8s.ApiObjectMetadata `json:"metadata" yaml:"metadata"` // List of containers belonging to the pod. // // Containers cannot currently be // added or removed. There must be at least one container in a Pod. // // You can add additionnal containers using `podSpec.addContainer()` Containers *[]*ContainerProps `json:"containers" yaml:"containers"` // Restart policy for all containers within the pod. // See: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle/#restart-policy // RestartPolicy RestartPolicy `json:"restartPolicy" yaml:"restartPolicy"` // A service account provides an identity for processes that run in a Pod. // // When you (a human) access the cluster (for example, using kubectl), you are // authenticated by the apiserver as a particular User Account (currently this // is usually admin, unless your cluster administrator has customized your // cluster). Processes in containers inside pods can also contact the // apiserver. When they do, they are authenticated as a particular Service // Account (for example, default). // See: https://kubernetes.io/docs/tasks/configure-pod-container/configure-service-account/ // ServiceAccount IServiceAccount `json:"serviceAccount" yaml:"serviceAccount"` // List of volumes that can be mounted by containers belonging to the pod. // // You can also add volumes later using `podSpec.addVolume()` // See: https://kubernetes.io/docs/concepts/storage/volumes // Volumes *[]Volume `json:"volumes" yaml:"volumes"` // The pod metadata. PodMetadata *cdk8s.ApiObjectMetadata `json:"podMetadata" yaml:"podMetadata"` // Automatically allocates a pod selector for this deployment. // // If this is set to `false` you must define your selector through // `deployment.podMetadata.addLabel()` and `deployment.selectByLabel()`. DefaultSelector *bool `json:"defaultSelector" yaml:"defaultSelector"` // Number of desired pods. Replicas *float64 `json:"replicas" yaml:"replicas"` }
Properties for initialization of `Deployment`.
type EmptyDirMedium ¶
type EmptyDirMedium string
The medium on which to store the volume.
const ( EmptyDirMedium_DEFAULT EmptyDirMedium = "DEFAULT" EmptyDirMedium_MEMORY EmptyDirMedium = "MEMORY" )
type EmptyDirVolumeOptions ¶
type EmptyDirVolumeOptions struct { // By default, emptyDir volumes are stored on whatever medium is backing the node - that might be disk or SSD or network storage, depending on your environment. // // However, you can set the emptyDir.medium field to // `EmptyDirMedium.MEMORY` to tell Kubernetes to mount a tmpfs (RAM-backed // filesystem) for you instead. While tmpfs is very fast, be aware that unlike // disks, tmpfs is cleared on node reboot and any files you write will count // against your Container's memory limit. Medium EmptyDirMedium `json:"medium" yaml:"medium"` // Total amount of local storage required for this EmptyDir volume. // // The size // limit is also applicable for memory medium. The maximum usage on memory // medium EmptyDir would be the minimum value between the SizeLimit specified // here and the sum of memory limits of all containers in a pod. SizeLimit cdk8s.Size `json:"sizeLimit" yaml:"sizeLimit"` }
Options for volumes populated with an empty directory.
type EnvFieldPaths ¶
type EnvFieldPaths string
const ( EnvFieldPaths_POD_NAME EnvFieldPaths = "POD_NAME" EnvFieldPaths_POD_NAMESPACE EnvFieldPaths = "POD_NAMESPACE" EnvFieldPaths_POD_UID EnvFieldPaths = "POD_UID" EnvFieldPaths_POD_LABEL EnvFieldPaths = "POD_LABEL" EnvFieldPaths_POD_ANNOTATION EnvFieldPaths = "POD_ANNOTATION" EnvFieldPaths_POD_IP EnvFieldPaths = "POD_IP" EnvFieldPaths_SERVICE_ACCOUNT_NAME EnvFieldPaths = "SERVICE_ACCOUNT_NAME" EnvFieldPaths_NODE_NAME EnvFieldPaths = "NODE_NAME" EnvFieldPaths_NODE_IP EnvFieldPaths = "NODE_IP" EnvFieldPaths_POD_IPS EnvFieldPaths = "POD_IPS" )
type EnvValue ¶
type EnvValue interface { Value() interface{} ValueFrom() interface{} }
Utility class for creating reading env values from various sources.
func EnvValue_FromConfigMap ¶
func EnvValue_FromConfigMap(configMap IConfigMap, key *string, options *EnvValueFromConfigMapOptions) EnvValue
Create a value by reading a specific key inside a config map.
func EnvValue_FromFieldRef ¶
func EnvValue_FromFieldRef(fieldPath EnvFieldPaths, options *EnvValueFromFieldRefOptions) EnvValue
Create a value from a field reference.
func EnvValue_FromProcess ¶
func EnvValue_FromProcess(key *string, options *EnvValueFromProcessOptions) EnvValue
Create a value from a key in the current process environment.
func EnvValue_FromResource ¶
func EnvValue_FromResource(resource ResourceFieldPaths, options *EnvValueFromResourceOptions) EnvValue
Create a value from a resource.
func EnvValue_FromSecretValue ¶
func EnvValue_FromSecretValue(secretValue *SecretValue, options *EnvValueFromSecretOptions) EnvValue
Defines an environment value from a secret JSON value.
func EnvValue_FromValue ¶
Create a value from the given argument.
type EnvValueFromConfigMapOptions ¶
type EnvValueFromConfigMapOptions struct { // Specify whether the ConfigMap or its key must be defined. Optional *bool `json:"optional" yaml:"optional"` }
Options to specify an envionment variable value from a ConfigMap key.
type EnvValueFromFieldRefOptions ¶
type EnvValueFromFieldRefOptions struct { // Version of the schema the FieldPath is written in terms of. ApiVersion *string `json:"apiVersion" yaml:"apiVersion"` // The key to select the pod label or annotation. Key *string `json:"key" yaml:"key"` }
Options to specify an environment variable value from a field reference.
type EnvValueFromProcessOptions ¶
type EnvValueFromProcessOptions struct { // Specify whether the key must exist in the environment. // // If this is set to true, and the key does not exist, an error will thrown. Required *bool `json:"required" yaml:"required"` }
Options to specify an environment variable value from the process environment.
type EnvValueFromResourceOptions ¶
type EnvValueFromResourceOptions struct { // The container to select the value from. Container Container `json:"container" yaml:"container"` // The output format of the exposed resource. Divisor *string `json:"divisor" yaml:"divisor"` }
Options to specify an environment variable value from a resource.
type EnvValueFromSecretOptions ¶
type EnvValueFromSecretOptions struct { // Specify whether the Secret or its key must be defined. Optional *bool `json:"optional" yaml:"optional"` }
Options to specify an environment variable value from a Secret.
type ExposeDeploymentViaIngressOptions ¶
type ExposeDeploymentViaIngressOptions struct { // The name of the service to expose. // // This will be set on the Service.metadata and must be a DNS_LABEL Name *string `json:"name" yaml:"name"` // The port that the service should serve on. Port *float64 `json:"port" yaml:"port"` // The IP protocol for this port. // // Supports "TCP", "UDP", and "SCTP". Default is TCP. Protocol Protocol `json:"protocol" yaml:"protocol"` // The type of the exposed service. ServiceType ServiceType `json:"serviceType" yaml:"serviceType"` // The port number the service will redirect to. TargetPort *float64 `json:"targetPort" yaml:"targetPort"` // The ingress to add rules to. Ingress Ingress `json:"ingress" yaml:"ingress"` // The type of the path. PathType HttpIngressPathType `json:"pathType" yaml:"pathType"` }
Options for exposing a deployment via an ingress.
type ExposeDeploymentViaServiceOptions ¶
type ExposeDeploymentViaServiceOptions struct { // The name of the service to expose. // // This will be set on the Service.metadata and must be a DNS_LABEL Name *string `json:"name" yaml:"name"` // The port that the service should serve on. Port *float64 `json:"port" yaml:"port"` // The IP protocol for this port. // // Supports "TCP", "UDP", and "SCTP". Default is TCP. Protocol Protocol `json:"protocol" yaml:"protocol"` // The type of the exposed service. ServiceType ServiceType `json:"serviceType" yaml:"serviceType"` // The port number the service will redirect to. TargetPort *float64 `json:"targetPort" yaml:"targetPort"` }
Options for exposing a deployment via a service.
type ExposeServiceViaIngressOptions ¶
type ExposeServiceViaIngressOptions struct { // The ingress to add rules to. Ingress Ingress `json:"ingress" yaml:"ingress"` // The type of the path. PathType HttpIngressPathType `json:"pathType" yaml:"pathType"` }
Options for exposing a service using an ingress.
type HttpGetProbeOptions ¶
type HttpGetProbeOptions struct { // Minimum consecutive failures for the probe to be considered failed after having succeeded. // // Defaults to 3. Minimum value is 1. FailureThreshold *float64 `json:"failureThreshold" yaml:"failureThreshold"` // Number of seconds after the container has started before liveness probes are initiated. // See: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes // InitialDelaySeconds cdk8s.Duration `json:"initialDelaySeconds" yaml:"initialDelaySeconds"` // How often (in seconds) to perform the probe. // // Default to 10 seconds. Minimum value is 1. PeriodSeconds cdk8s.Duration `json:"periodSeconds" yaml:"periodSeconds"` // Minimum consecutive successes for the probe to be considered successful after having failed. Defaults to 1. // // Must be 1 for liveness and startup. Minimum value is 1. SuccessThreshold *float64 `json:"successThreshold" yaml:"successThreshold"` // Number of seconds after which the probe times out. // // Defaults to 1 second. Minimum value is 1. // See: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes // TimeoutSeconds cdk8s.Duration `json:"timeoutSeconds" yaml:"timeoutSeconds"` // The TCP port to use when sending the GET request. Port *float64 `json:"port" yaml:"port"` }
Options for `Probe.fromHttpGet()`.
type HttpIngressPathType ¶
type HttpIngressPathType string
Specify how the path is matched against request paths. See: https://kubernetes.io/docs/concepts/services-networking/ingress/#path-types
const ( HttpIngressPathType_PREFIX HttpIngressPathType = "PREFIX" HttpIngressPathType_EXACT HttpIngressPathType = "EXACT" HttpIngressPathType_IMPLEMENTATION_SPECIFIC HttpIngressPathType = "IMPLEMENTATION_SPECIFIC" )
type IConfigMap ¶
type IConfigMap interface { IResource }
Represents a config map.
func ConfigMap_FromConfigMapName ¶
func ConfigMap_FromConfigMapName(name *string) IConfigMap
Represents a ConfigMap created elsewhere.
type IPodSpec ¶
type IPodSpec interface { // Add a container to the pod. AddContainer(container *ContainerProps) Container // Add a volume to the pod. AddVolume(volume Volume) // The containers belonging to the pod. // // Use `addContainer` to add containers. Containers() *[]Container // Restart policy for all containers within the pod. RestartPolicy() RestartPolicy // The service account used to run this pod. ServiceAccount() IServiceAccount // The volumes associated with this pod. // // Use `addVolume` to add volumes. Volumes() *[]Volume }
Represents a resource that can be configured with a kuberenets pod spec. (e.g `Deployment`, `Job`, `Pod`, ...).
Use the `PodSpec` class as an implementation helper.
type IPodTemplate ¶
type IPodTemplate interface { IPodSpec // Provides read/write access to the underlying pod metadata of the resource. PodMetadata() cdk8s.ApiObjectMetadataDefinition }
Represents a resource that can be configured with a kuberenets pod template. (e.g `Deployment`, `Job`, ...).
Use the `PodTemplate` class as an implementation helper.
type IResource ¶
type IResource interface { // The Kubernetes name of this resource. Name() *string }
Represents a resource.
type ISecret ¶
type ISecret interface { IResource }
func Secret_FromSecretName ¶
Imports a secret from the cluster as a reference.
type IServiceAccount ¶
type IServiceAccount interface { IResource }
func ServiceAccount_FromServiceAccountName ¶
func ServiceAccount_FromServiceAccountName(name *string) IServiceAccount
Imports a service account from the cluster as a reference.
type ImagePullPolicy ¶
type ImagePullPolicy string
const ( ImagePullPolicy_ALWAYS ImagePullPolicy = "ALWAYS" ImagePullPolicy_IF_NOT_PRESENT ImagePullPolicy = "IF_NOT_PRESENT" ImagePullPolicy_NEVER ImagePullPolicy = "NEVER" )
type Ingress ¶
type Ingress interface { Resource ApiObject() cdk8s.ApiObject Metadata() cdk8s.ApiObjectMetadataDefinition Name() *string AddDefaultBackend(backend IngressBackend) AddHostDefaultBackend(host *string, backend IngressBackend) AddHostRule(host *string, path *string, backend IngressBackend, pathType HttpIngressPathType) AddRule(path *string, backend IngressBackend, pathType HttpIngressPathType) AddRules(rules ...*IngressRule) AddTls(tls *[]*IngressTls) OnPrepare() OnSynthesize(session constructs.ISynthesisSession) OnValidate() *[]*string ToString() *string }
Ingress is a collection of rules that allow inbound connections to reach the endpoints defined by a backend.
An Ingress can be configured to give services externally-reachable urls, load balance traffic, terminate SSL, offer name based virtual hosting etc.
func NewIngress ¶
func NewIngress(scope constructs.Construct, id *string, props *IngressProps) Ingress
type IngressBackend ¶
type IngressBackend interface { }
The backend for an ingress path.
func IngressBackend_FromService ¶
func IngressBackend_FromService(service Service, options *ServiceIngressBackendOptions) IngressBackend
A Kubernetes `Service` to use as the backend for this path.
type IngressProps ¶
type IngressProps struct { // Metadata that all persisted resources must have, which includes all objects users must create. Metadata *cdk8s.ApiObjectMetadata `json:"metadata" yaml:"metadata"` // The default backend services requests that do not match any rule. // // Using this option or the `addDefaultBackend()` method is equivalent to // adding a rule with both `path` and `host` undefined. DefaultBackend IngressBackend `json:"defaultBackend" yaml:"defaultBackend"` // Routing rules for this ingress. // // Each rule must define an `IngressBackend` that will receive the requests // that match this rule. If both `host` and `path` are not specifiec, this // backend will be used as the default backend of the ingress. // // You can also add rules later using `addRule()`, `addHostRule()`, // `addDefaultBackend()` and `addHostDefaultBackend()`. Rules *[]*IngressRule `json:"rules" yaml:"rules"` // TLS settings for this ingress. // // Using this option tells the ingress controller to expose a TLS endpoint. // Currently the Ingress only supports a single TLS port, 443. If multiple // members of this list specify different hosts, they will be multiplexed on // the same port according to the hostname specified through the SNI TLS // extension, if the ingress controller fulfilling the ingress supports SNI. Tls *[]*IngressTls `json:"tls" yaml:"tls"` }
Properties for `Ingress`.
type IngressRule ¶
type IngressRule struct { // Backend defines the referenced service endpoint to which the traffic will be forwarded to. Backend IngressBackend `json:"backend" yaml:"backend"` // Host is the fully qualified domain name of a network host, as defined by RFC 3986. // // Note the following deviations from the "host" part of the URI as // defined in the RFC: 1. IPs are not allowed. Currently an IngressRuleValue // can only apply to the IP in the Spec of the parent Ingress. 2. The `:` // delimiter is not respected because ports are not allowed. Currently the // port of an Ingress is implicitly :80 for http and :443 for https. Both // these may change in the future. Incoming requests are matched against the // host before the IngressRuleValue. Host *string `json:"host" yaml:"host"` // Path is an extended POSIX regex as defined by IEEE Std 1003.1, (i.e this follows the egrep/unix syntax, not the perl syntax) matched against the path of an incoming request. Currently it can contain characters disallowed from the conventional "path" part of a URL as defined by RFC 3986. Paths must begin with a '/'. Path *string `json:"path" yaml:"path"` // Specify how the path is matched against request paths. // // By default, path // types will be matched by prefix. // See: https://kubernetes.io/docs/concepts/services-networking/ingress/#path-types // PathType HttpIngressPathType `json:"pathType" yaml:"pathType"` }
Represents the rules mapping the paths under a specified host to the related backend services.
Incoming requests are first evaluated for a host match, then routed to the backend associated with the matching path.
type IngressTls ¶
type IngressTls struct { // Hosts are a list of hosts included in the TLS certificate. // // The values in // this list must match the name/s used in the TLS Secret. Hosts *[]*string `json:"hosts" yaml:"hosts"` // Secret is the secret that contains the certificate and key used to terminate SSL traffic on 443. // // If the SNI host in a listener conflicts with // the "Host" header field used by an IngressRule, the SNI host is used for // termination and value of the Host header is used for routing. Secret ISecret `json:"secret" yaml:"secret"` }
Represents the TLS configuration mapping that is passed to the ingress controller for SSL termination.
type Job ¶
type Job interface { Resource IPodTemplate ActiveDeadline() cdk8s.Duration ApiObject() cdk8s.ApiObject BackoffLimit() *float64 Containers() *[]Container Metadata() cdk8s.ApiObjectMetadataDefinition Name() *string PodMetadata() cdk8s.ApiObjectMetadataDefinition RestartPolicy() RestartPolicy ServiceAccount() IServiceAccount TtlAfterFinished() cdk8s.Duration Volumes() *[]Volume AddContainer(container *ContainerProps) Container AddVolume(volume Volume) OnPrepare() OnSynthesize(session constructs.ISynthesisSession) OnValidate() *[]*string ToString() *string }
A Job creates one or more Pods and ensures that a specified number of them successfully terminate.
As pods successfully complete, the Job tracks the successful completions. When a specified number of successful completions is reached, the task (ie, Job) is complete. Deleting a Job will clean up the Pods it created. A simple case is to create one Job object in order to reliably run one Pod to completion. The Job object will start a new Pod if the first Pod fails or is deleted (for example due to a node hardware failure or a node reboot). You can also use a Job to run multiple Pods in parallel.
type JobProps ¶
type JobProps struct { // Metadata that all persisted resources must have, which includes all objects users must create. Metadata *cdk8s.ApiObjectMetadata `json:"metadata" yaml:"metadata"` // List of containers belonging to the pod. // // Containers cannot currently be // added or removed. There must be at least one container in a Pod. // // You can add additionnal containers using `podSpec.addContainer()` Containers *[]*ContainerProps `json:"containers" yaml:"containers"` // Restart policy for all containers within the pod. // See: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle/#restart-policy // RestartPolicy RestartPolicy `json:"restartPolicy" yaml:"restartPolicy"` // A service account provides an identity for processes that run in a Pod. // // When you (a human) access the cluster (for example, using kubectl), you are // authenticated by the apiserver as a particular User Account (currently this // is usually admin, unless your cluster administrator has customized your // cluster). Processes in containers inside pods can also contact the // apiserver. When they do, they are authenticated as a particular Service // Account (for example, default). // See: https://kubernetes.io/docs/tasks/configure-pod-container/configure-service-account/ // ServiceAccount IServiceAccount `json:"serviceAccount" yaml:"serviceAccount"` // List of volumes that can be mounted by containers belonging to the pod. // // You can also add volumes later using `podSpec.addVolume()` // See: https://kubernetes.io/docs/concepts/storage/volumes // Volumes *[]Volume `json:"volumes" yaml:"volumes"` // The pod metadata. PodMetadata *cdk8s.ApiObjectMetadata `json:"podMetadata" yaml:"podMetadata"` // Specifies the duration the job may be active before the system tries to terminate it. ActiveDeadline cdk8s.Duration `json:"activeDeadline" yaml:"activeDeadline"` // Specifies the number of retries before marking this job failed. BackoffLimit *float64 `json:"backoffLimit" yaml:"backoffLimit"` // Limits the lifetime of a Job that has finished execution (either Complete or Failed). // // If this field is set, after the Job finishes, it is eligible to // be automatically deleted. When the Job is being deleted, its lifecycle // guarantees (e.g. finalizers) will be honored. If this field is set to zero, // the Job becomes eligible to be deleted immediately after it finishes. This // field is alpha-level and is only honored by servers that enable the // `TTLAfterFinished` feature. TtlAfterFinished cdk8s.Duration `json:"ttlAfterFinished" yaml:"ttlAfterFinished"` }
Properties for initialization of `Job`.
type MountOptions ¶
type MountOptions struct { // Determines how mounts are propagated from the host to container and the other way around. // // When not set, MountPropagationNone is used. // // Mount propagation allows for sharing volumes mounted by a Container to // other Containers in the same Pod, or even to other Pods on the same node. // // This field is beta in 1.10. Propagation MountPropagation `json:"propagation" yaml:"propagation"` // Mounted read-only if true, read-write otherwise (false or unspecified). // // Defaults to false. ReadOnly *bool `json:"readOnly" yaml:"readOnly"` // Path within the volume from which the container's volume should be mounted.). SubPath *string `json:"subPath" yaml:"subPath"` // Expanded path within the volume from which the container's volume should be mounted. // // Behaves similarly to SubPath but environment variable references // $(VAR_NAME) are expanded using the container's environment. Defaults to "" // (volume's root). SubPathExpr and SubPath are mutually exclusive. This field // is beta in 1.15. // // `subPathExpr` and `subPath` are mutually exclusive. This field is beta in // 1.15. SubPathExpr *string `json:"subPathExpr" yaml:"subPathExpr"` }
Options for mounts.
type MountPropagation ¶
type MountPropagation string
const ( MountPropagation_NONE MountPropagation = "NONE" MountPropagation_HOST_TO_CONTAINER MountPropagation = "HOST_TO_CONTAINER" MountPropagation_BIDIRECTIONAL MountPropagation = "BIDIRECTIONAL" )
type PathMapping ¶
type PathMapping struct { // The relative path of the file to map the key to. // // May not be an absolute // path. May not contain the path element '..'. May not start with the string // '..'. Path *string `json:"path" yaml:"path"` // Optional: mode bits to use on this file, must be a value between 0 and 0777. // // If not specified, the volume defaultMode will be used. This might be // in conflict with other options that affect the file mode, like fsGroup, and // the result can be other mode bits set. Mode *float64 `json:"mode" yaml:"mode"` }
Maps a string key to a path within a volume.
type Pod ¶
type Pod interface { Resource IPodSpec ApiObject() cdk8s.ApiObject Containers() *[]Container Metadata() cdk8s.ApiObjectMetadataDefinition Name() *string RestartPolicy() RestartPolicy ServiceAccount() IServiceAccount Volumes() *[]Volume AddContainer(container *ContainerProps) Container AddVolume(volume Volume) OnPrepare() OnSynthesize(session constructs.ISynthesisSession) OnValidate() *[]*string ToString() *string }
Pod is a collection of containers that can run on a host.
This resource is created by clients and scheduled onto hosts.
type PodManagementPolicy ¶
type PodManagementPolicy string
Controls how pods are created during initial scale up, when replacing pods on nodes, or when scaling down.
The default policy is `OrderedReady`, where pods are created in increasing order (pod-0, then pod-1, etc) and the controller will wait until each pod is ready before continuing. When scaling down, the pods are removed in the opposite order.
The alternative policy is `Parallel` which will create pods in parallel to match the desired scale without waiting, and on scale down will delete all pods at once.
const ( PodManagementPolicy_ORDERED_READY PodManagementPolicy = "ORDERED_READY" PodManagementPolicy_PARALLEL PodManagementPolicy = "PARALLEL" )
type PodProps ¶
type PodProps struct { // Metadata that all persisted resources must have, which includes all objects users must create. Metadata *cdk8s.ApiObjectMetadata `json:"metadata" yaml:"metadata"` // List of containers belonging to the pod. // // Containers cannot currently be // added or removed. There must be at least one container in a Pod. // // You can add additionnal containers using `podSpec.addContainer()` Containers *[]*ContainerProps `json:"containers" yaml:"containers"` // Restart policy for all containers within the pod. // See: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle/#restart-policy // RestartPolicy RestartPolicy `json:"restartPolicy" yaml:"restartPolicy"` // A service account provides an identity for processes that run in a Pod. // // When you (a human) access the cluster (for example, using kubectl), you are // authenticated by the apiserver as a particular User Account (currently this // is usually admin, unless your cluster administrator has customized your // cluster). Processes in containers inside pods can also contact the // apiserver. When they do, they are authenticated as a particular Service // Account (for example, default). // See: https://kubernetes.io/docs/tasks/configure-pod-container/configure-service-account/ // ServiceAccount IServiceAccount `json:"serviceAccount" yaml:"serviceAccount"` // List of volumes that can be mounted by containers belonging to the pod. // // You can also add volumes later using `podSpec.addVolume()` // See: https://kubernetes.io/docs/concepts/storage/volumes // Volumes *[]Volume `json:"volumes" yaml:"volumes"` }
Properties for initialization of `Pod`.
type PodSpec ¶
type PodSpec interface { IPodSpec Containers() *[]Container RestartPolicy() RestartPolicy ServiceAccount() IServiceAccount Volumes() *[]Volume AddContainer(container *ContainerProps) Container AddVolume(volume Volume) }
Provides read/write capabilities ontop of a `PodSpecProps`.
func NewPodSpec ¶
func NewPodSpec(props *PodSpecProps) PodSpec
type PodSpecProps ¶
type PodSpecProps struct { // List of containers belonging to the pod. // // Containers cannot currently be // added or removed. There must be at least one container in a Pod. // // You can add additionnal containers using `podSpec.addContainer()` Containers *[]*ContainerProps `json:"containers" yaml:"containers"` // Restart policy for all containers within the pod. // See: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle/#restart-policy // RestartPolicy RestartPolicy `json:"restartPolicy" yaml:"restartPolicy"` // A service account provides an identity for processes that run in a Pod. // // When you (a human) access the cluster (for example, using kubectl), you are // authenticated by the apiserver as a particular User Account (currently this // is usually admin, unless your cluster administrator has customized your // cluster). Processes in containers inside pods can also contact the // apiserver. When they do, they are authenticated as a particular Service // Account (for example, default). // See: https://kubernetes.io/docs/tasks/configure-pod-container/configure-service-account/ // ServiceAccount IServiceAccount `json:"serviceAccount" yaml:"serviceAccount"` // List of volumes that can be mounted by containers belonging to the pod. // // You can also add volumes later using `podSpec.addVolume()` // See: https://kubernetes.io/docs/concepts/storage/volumes // Volumes *[]Volume `json:"volumes" yaml:"volumes"` }
Properties of a `PodSpec`.
type PodTemplate ¶
type PodTemplate interface { PodSpec IPodTemplate Containers() *[]Container PodMetadata() cdk8s.ApiObjectMetadataDefinition RestartPolicy() RestartPolicy ServiceAccount() IServiceAccount Volumes() *[]Volume AddContainer(container *ContainerProps) Container AddVolume(volume Volume) }
Provides read/write capabilities ontop of a `PodTemplateProps`.
func NewPodTemplate ¶
func NewPodTemplate(props *PodTemplateProps) PodTemplate
type PodTemplateProps ¶
type PodTemplateProps struct { // List of containers belonging to the pod. // // Containers cannot currently be // added or removed. There must be at least one container in a Pod. // // You can add additionnal containers using `podSpec.addContainer()` Containers *[]*ContainerProps `json:"containers" yaml:"containers"` // Restart policy for all containers within the pod. // See: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle/#restart-policy // RestartPolicy RestartPolicy `json:"restartPolicy" yaml:"restartPolicy"` // A service account provides an identity for processes that run in a Pod. // // When you (a human) access the cluster (for example, using kubectl), you are // authenticated by the apiserver as a particular User Account (currently this // is usually admin, unless your cluster administrator has customized your // cluster). Processes in containers inside pods can also contact the // apiserver. When they do, they are authenticated as a particular Service // Account (for example, default). // See: https://kubernetes.io/docs/tasks/configure-pod-container/configure-service-account/ // ServiceAccount IServiceAccount `json:"serviceAccount" yaml:"serviceAccount"` // List of volumes that can be mounted by containers belonging to the pod. // // You can also add volumes later using `podSpec.addVolume()` // See: https://kubernetes.io/docs/concepts/storage/volumes // Volumes *[]Volume `json:"volumes" yaml:"volumes"` // The pod metadata. PodMetadata *cdk8s.ApiObjectMetadata `json:"podMetadata" yaml:"podMetadata"` }
Properties of a `PodTemplate`.
Adds metadata information on top of the spec.
type Probe ¶
type Probe interface { }
Probe describes a health check to be performed against a container to determine whether it is alive or ready to receive traffic.
func Probe_FromCommand ¶
func Probe_FromCommand(command *[]*string, options *CommandProbeOptions) Probe
Defines a probe based on a command which is executed within the container.
func Probe_FromHttpGet ¶
func Probe_FromHttpGet(path *string, options *HttpGetProbeOptions) Probe
Defines a probe based on an HTTP GET request to the IP address of the container.
type ProbeOptions ¶
type ProbeOptions struct { // Minimum consecutive failures for the probe to be considered failed after having succeeded. // // Defaults to 3. Minimum value is 1. FailureThreshold *float64 `json:"failureThreshold" yaml:"failureThreshold"` // Number of seconds after the container has started before liveness probes are initiated. // See: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes // InitialDelaySeconds cdk8s.Duration `json:"initialDelaySeconds" yaml:"initialDelaySeconds"` // How often (in seconds) to perform the probe. // // Default to 10 seconds. Minimum value is 1. PeriodSeconds cdk8s.Duration `json:"periodSeconds" yaml:"periodSeconds"` // Minimum consecutive successes for the probe to be considered successful after having failed. Defaults to 1. // // Must be 1 for liveness and startup. Minimum value is 1. SuccessThreshold *float64 `json:"successThreshold" yaml:"successThreshold"` // Number of seconds after which the probe times out. // // Defaults to 1 second. Minimum value is 1. // See: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes // TimeoutSeconds cdk8s.Duration `json:"timeoutSeconds" yaml:"timeoutSeconds"` }
Probe options.
type Resource ¶
type Resource interface { constructs.Construct IResource ApiObject() cdk8s.ApiObject Metadata() cdk8s.ApiObjectMetadataDefinition Name() *string OnPrepare() OnSynthesize(session constructs.ISynthesisSession) OnValidate() *[]*string ToString() *string }
Base class for all Kubernetes objects in stdk8s.
Represents a single resource.
type ResourceFieldPaths ¶
type ResourceFieldPaths string
const ( ResourceFieldPaths_CPU_LIMIT ResourceFieldPaths = "CPU_LIMIT" ResourceFieldPaths_MEMORY_LIMIT ResourceFieldPaths = "MEMORY_LIMIT" ResourceFieldPaths_CPU_REQUEST ResourceFieldPaths = "CPU_REQUEST" ResourceFieldPaths_MEMORY_REQUEST ResourceFieldPaths = "MEMORY_REQUEST" ResourceFieldPaths_STORAGE_LIMIT ResourceFieldPaths = "STORAGE_LIMIT" ResourceFieldPaths_STORAGE_REQUEST ResourceFieldPaths = "STORAGE_REQUEST" )
type ResourceProps ¶
type ResourceProps struct { // Metadata that all persisted resources must have, which includes all objects users must create. Metadata *cdk8s.ApiObjectMetadata `json:"metadata" yaml:"metadata"` }
Initialization properties for resources.
type RestartPolicy ¶
type RestartPolicy string
Restart policy for all containers within the pod.
const ( RestartPolicy_ALWAYS RestartPolicy = "ALWAYS" RestartPolicy_ON_FAILURE RestartPolicy = "ON_FAILURE" RestartPolicy_NEVER RestartPolicy = "NEVER" )
type Secret ¶
type Secret interface { Resource ISecret ApiObject() cdk8s.ApiObject Metadata() cdk8s.ApiObjectMetadataDefinition Name() *string AddStringData(key *string, value *string) GetStringData(key *string) *string OnPrepare() OnSynthesize(session constructs.ISynthesisSession) OnValidate() *[]*string ToString() *string }
Kubernetes Secrets let you store and manage sensitive information, such as passwords, OAuth tokens, and ssh keys.
Storing confidential information in a Secret is safer and more flexible than putting it verbatim in a Pod definition or in a container image. See: https://kubernetes.io/docs/concepts/configuration/secret
func NewSecret ¶
func NewSecret(scope constructs.Construct, id *string, props *SecretProps) Secret
type SecretProps ¶
type SecretProps struct { // Metadata that all persisted resources must have, which includes all objects users must create. Metadata *cdk8s.ApiObjectMetadata `json:"metadata" yaml:"metadata"` // stringData allows specifying non-binary secret data in string form. // // It is // provided as a write-only convenience method. All keys and values are merged // into the data field on write, overwriting any existing values. It is never // output when reading from the API. StringData *map[string]*string `json:"stringData" yaml:"stringData"` // Optional type associated with the secret. // // Used to facilitate programmatic // handling of secret data by various controllers. Type *string `json:"type" yaml:"type"` }
type SecretValue ¶
type SecretValue struct { // The JSON key. Key *string `json:"key" yaml:"key"` // The secret. Secret ISecret `json:"secret" yaml:"secret"` }
Represents a specific value in JSON secret.
type SecretVolumeOptions ¶
type SecretVolumeOptions struct { // Mode bits to use on created files by default. // // Must be a value between 0 and // 0777. Defaults to 0644. Directories within the path are not affected by // this setting. This might be in conflict with other options that affect the // file mode, like fsGroup, and the result can be other mode bits set. DefaultMode *float64 `json:"defaultMode" yaml:"defaultMode"` // If unspecified, each key-value pair in the Data field of the referenced secret will be projected into the volume as a file whose name is the key and content is the value. // // If specified, the listed keys will be projected // into the specified paths, and unlisted keys will not be present. If a key // is specified which is not present in the secret, the volume setup will // error unless it is marked optional. Paths must be relative and may not // contain the '..' path or start with '..'. Items *map[string]*PathMapping `json:"items" yaml:"items"` // The volume name. Name *string `json:"name" yaml:"name"` // Specify whether the secret or its keys must be defined. Optional *bool `json:"optional" yaml:"optional"` }
Options for the Secret-based volume.
type Service ¶
type Service interface { Resource ApiObject() cdk8s.ApiObject ClusterIP() *string ExternalName() *string Metadata() cdk8s.ApiObjectMetadataDefinition Name() *string Ports() *[]*ServicePort Selector() *map[string]*string Type() ServiceType AddDeployment(deployment Deployment, options *AddDeploymentOptions) AddSelector(label *string, value *string) ExposeViaIngress(path *string, options *ExposeServiceViaIngressOptions) Ingress OnPrepare() OnSynthesize(session constructs.ISynthesisSession) OnValidate() *[]*string Serve(port *float64, options *ServicePortOptions) ToString() *string }
An abstract way to expose an application running on a set of Pods as a network service.
With Kubernetes you don't need to modify your application to use an unfamiliar service discovery mechanism. Kubernetes gives Pods their own IP addresses and a single DNS name for a set of Pods, and can load-balance across them.
For example, consider a stateless image-processing backend which is running with 3 replicas. Those replicas are fungible—frontends do not care which backend they use. While the actual Pods that compose the backend set may change, the frontend clients should not need to be aware of that, nor should they need to keep track of the set of backends themselves. The Service abstraction enables this decoupling.
If you're able to use Kubernetes APIs for service discovery in your application, you can query the API server for Endpoints, that get updated whenever the set of Pods in a Service changes. For non-native applications, Kubernetes offers ways to place a network port or load balancer in between your application and the backend Pods.
func NewService ¶
func NewService(scope constructs.Construct, id *string, props *ServiceProps) Service
type ServiceAccount ¶
type ServiceAccount interface { Resource IServiceAccount ApiObject() cdk8s.ApiObject Metadata() cdk8s.ApiObjectMetadataDefinition Name() *string Secrets() *[]ISecret AddSecret(secret ISecret) OnPrepare() OnSynthesize(session constructs.ISynthesisSession) OnValidate() *[]*string ToString() *string }
A service account provides an identity for processes that run in a Pod.
When you (a human) access the cluster (for example, using kubectl), you are authenticated by the apiserver as a particular User Account (currently this is usually admin, unless your cluster administrator has customized your cluster). Processes in containers inside pods can also contact the apiserver. When they do, they are authenticated as a particular Service Account (for example, default). See: https://kubernetes.io/docs/tasks/configure-pod-container/configure-service-account
func NewServiceAccount ¶
func NewServiceAccount(scope constructs.Construct, id *string, props *ServiceAccountProps) ServiceAccount
type ServiceAccountProps ¶
type ServiceAccountProps struct { // Metadata that all persisted resources must have, which includes all objects users must create. Metadata *cdk8s.ApiObjectMetadata `json:"metadata" yaml:"metadata"` // List of secrets allowed to be used by pods running using this ServiceAccount. // See: https://kubernetes.io/docs/concepts/configuration/secret // Secrets *[]ISecret `json:"secrets" yaml:"secrets"` }
Properties for initialization of `ServiceAccount`.
Properties for initialization of `ServiceAccount`.
type ServiceIngressBackendOptions ¶
type ServiceIngressBackendOptions struct { // The port to use to access the service. // // - This option will fail if the service does not expose any ports. // - If the service exposes multiple ports, this option must be specified. // - If the service exposes a single port, this option is optional and if // specified, it must be the same port exposed by the service. Port *float64 `json:"port" yaml:"port"` }
Options for setting up backends for ingress rules.
type ServicePort ¶
type ServicePort struct { // The name of this port within the service. // // This must be a DNS_LABEL. All // ports within a ServiceSpec must have unique names. This maps to the 'Name' // field in EndpointPort objects. Optional if only one ServicePort is defined // on this service. Name *string `json:"name" yaml:"name"` // The port on each node on which this service is exposed when type=NodePort or LoadBalancer. // // Usually assigned by the system. If specified, it will be // allocated to the service if unused or else creation of the service will // fail. Default is to auto-allocate a port if the ServiceType of this Service // requires one. // See: https://kubernetes.io/docs/concepts/services-networking/service/#type-nodeport // NodePort *float64 `json:"nodePort" yaml:"nodePort"` // The IP protocol for this port. // // Supports "TCP", "UDP", and "SCTP". Default is TCP. Protocol Protocol `json:"protocol" yaml:"protocol"` // The port number the service will redirect to. TargetPort *float64 `json:"targetPort" yaml:"targetPort"` // The port number the service will bind to. Port *float64 `json:"port" yaml:"port"` }
Definition of a service port.
type ServicePortOptions ¶
type ServicePortOptions struct { // The name of this port within the service. // // This must be a DNS_LABEL. All // ports within a ServiceSpec must have unique names. This maps to the 'Name' // field in EndpointPort objects. Optional if only one ServicePort is defined // on this service. Name *string `json:"name" yaml:"name"` // The port on each node on which this service is exposed when type=NodePort or LoadBalancer. // // Usually assigned by the system. If specified, it will be // allocated to the service if unused or else creation of the service will // fail. Default is to auto-allocate a port if the ServiceType of this Service // requires one. // See: https://kubernetes.io/docs/concepts/services-networking/service/#type-nodeport // NodePort *float64 `json:"nodePort" yaml:"nodePort"` // The IP protocol for this port. // // Supports "TCP", "UDP", and "SCTP". Default is TCP. Protocol Protocol `json:"protocol" yaml:"protocol"` // The port number the service will redirect to. TargetPort *float64 `json:"targetPort" yaml:"targetPort"` }
type ServiceProps ¶
type ServiceProps struct { // Metadata that all persisted resources must have, which includes all objects users must create. Metadata *cdk8s.ApiObjectMetadata `json:"metadata" yaml:"metadata"` // The IP address of the service and is usually assigned randomly by the master. // // If an address is specified manually and is not in use by others, it // will be allocated to the service; otherwise, creation of the service will // fail. This field can not be changed through updates. Valid values are // "None", empty string (""), or a valid IP address. "None" can be specified // for headless services when proxying is not required. Only applies to types // ClusterIP, NodePort, and LoadBalancer. Ignored if type is ExternalName. // See: https://kubernetes.io/docs/concepts/services-networking/service/#virtual-ips-and-service-proxies // ClusterIP *string `json:"clusterIP" yaml:"clusterIP"` // A list of IP addresses for which nodes in the cluster will also accept traffic for this service. // // These IPs are not managed by Kubernetes. The user // is responsible for ensuring that traffic arrives at a node with this IP. A // common example is external load-balancers that are not part of the // Kubernetes system. ExternalIPs *[]*string `json:"externalIPs" yaml:"externalIPs"` // The externalName to be used when ServiceType.EXTERNAL_NAME is set. ExternalName *string `json:"externalName" yaml:"externalName"` // A list of CIDR IP addresses, if specified and supported by the platform, will restrict traffic through the cloud-provider load-balancer to the specified client IPs. // // More info: https://kubernetes.io/docs/tasks/access-application-cluster/configure-cloud-provider-firewall/ LoadBalancerSourceRanges *[]*string `json:"loadBalancerSourceRanges" yaml:"loadBalancerSourceRanges"` // The port exposed by this service. // // More info: https://kubernetes.io/docs/concepts/services-networking/service/#virtual-ips-and-service-proxies Ports *[]*ServicePort `json:"ports" yaml:"ports"` // Determines how the Service is exposed. // // More info: https://kubernetes.io/docs/concepts/services-networking/service/#publishing-services-service-types Type ServiceType `json:"type" yaml:"type"` }
Properties for initialization of `Service`.
type ServiceType ¶
type ServiceType string
For some parts of your application (for example, frontends) you may want to expose a Service onto an external IP address, that's outside of your cluster.
Kubernetes ServiceTypes allow you to specify what kind of Service you want. The default is ClusterIP.
const ( ServiceType_CLUSTER_IP ServiceType = "CLUSTER_IP" ServiceType_NODE_PORT ServiceType = "NODE_PORT" ServiceType_LOAD_BALANCER ServiceType = "LOAD_BALANCER" ServiceType_EXTERNAL_NAME ServiceType = "EXTERNAL_NAME" )
type StatefulSet ¶
type StatefulSet interface { Resource IPodTemplate ApiObject() cdk8s.ApiObject Containers() *[]Container LabelSelector() *map[string]*string Metadata() cdk8s.ApiObjectMetadataDefinition Name() *string PodManagementPolicy() PodManagementPolicy PodMetadata() cdk8s.ApiObjectMetadataDefinition Replicas() *float64 RestartPolicy() RestartPolicy ServiceAccount() IServiceAccount Volumes() *[]Volume AddContainer(container *ContainerProps) Container AddVolume(volume Volume) OnPrepare() OnSynthesize(session constructs.ISynthesisSession) OnValidate() *[]*string SelectByLabel(key *string, value *string) ToString() *string }
StatefulSet is the workload API object used to manage stateful applications.
Manages the deployment and scaling of a set of Pods, and provides guarantees about the ordering and uniqueness of these Pods.
Like a Deployment, a StatefulSet manages Pods that are based on an identical container spec. Unlike a Deployment, a StatefulSet maintains a sticky identity for each of their Pods. These pods are created from the same spec, but are not interchangeable: each has a persistent identifier that it maintains across any rescheduling.
If you want to use storage volumes to provide persistence for your workload, you can use a StatefulSet as part of the solution. Although individual Pods in a StatefulSet are susceptible to failure, the persistent Pod identifiers make it easier to match existing volumes to the new Pods that replace any that have failed.
Using StatefulSets ------------------ StatefulSets are valuable for applications that require one or more of the following.
- Stable, unique network identifiers. - Stable, persistent storage. - Ordered, graceful deployment and scaling. - Ordered, automated rolling updates.
func NewStatefulSet ¶
func NewStatefulSet(scope constructs.Construct, id *string, props *StatefulSetProps) StatefulSet
type StatefulSetProps ¶
type StatefulSetProps struct { // Metadata that all persisted resources must have, which includes all objects users must create. Metadata *cdk8s.ApiObjectMetadata `json:"metadata" yaml:"metadata"` // List of containers belonging to the pod. // // Containers cannot currently be // added or removed. There must be at least one container in a Pod. // // You can add additionnal containers using `podSpec.addContainer()` Containers *[]*ContainerProps `json:"containers" yaml:"containers"` // Restart policy for all containers within the pod. // See: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle/#restart-policy // RestartPolicy RestartPolicy `json:"restartPolicy" yaml:"restartPolicy"` // A service account provides an identity for processes that run in a Pod. // // When you (a human) access the cluster (for example, using kubectl), you are // authenticated by the apiserver as a particular User Account (currently this // is usually admin, unless your cluster administrator has customized your // cluster). Processes in containers inside pods can also contact the // apiserver. When they do, they are authenticated as a particular Service // Account (for example, default). // See: https://kubernetes.io/docs/tasks/configure-pod-container/configure-service-account/ // ServiceAccount IServiceAccount `json:"serviceAccount" yaml:"serviceAccount"` // List of volumes that can be mounted by containers belonging to the pod. // // You can also add volumes later using `podSpec.addVolume()` // See: https://kubernetes.io/docs/concepts/storage/volumes // Volumes *[]Volume `json:"volumes" yaml:"volumes"` // The pod metadata. PodMetadata *cdk8s.ApiObjectMetadata `json:"podMetadata" yaml:"podMetadata"` // Service to associate with the statefulset. Service Service `json:"service" yaml:"service"` // Automatically allocates a pod selector for this statefulset. // // If this is set to `false` you must define your selector through // `statefulset.podMetadata.addLabel()` and `statefulset.selectByLabel()`. DefaultSelector *bool `json:"defaultSelector" yaml:"defaultSelector"` // Pod management policy to use for this statefulset. PodManagementPolicy PodManagementPolicy `json:"podManagementPolicy" yaml:"podManagementPolicy"` // Number of desired pods. Replicas *float64 `json:"replicas" yaml:"replicas"` }
Properties for initialization of `StatefulSet`.
type Volume ¶
type Volume interface {
Name() *string
}
Volume represents a named volume in a pod that may be accessed by any container in the pod.
Docker also has a concept of volumes, though it is somewhat looser and less managed. In Docker, a volume is simply a directory on disk or in another Container. Lifetimes are not managed and until very recently there were only local-disk-backed volumes. Docker now provides volume drivers, but the functionality is very limited for now (e.g. as of Docker 1.7 only one volume driver is allowed per Container and there is no way to pass parameters to volumes).
A Kubernetes volume, on the other hand, has an explicit lifetime - the same as the Pod that encloses it. Consequently, a volume outlives any Containers that run within the Pod, and data is preserved across Container restarts. Of course, when a Pod ceases to exist, the volume will cease to exist, too. Perhaps more importantly than this, Kubernetes supports many types of volumes, and a Pod can use any number of them simultaneously.
At its core, a volume is just a directory, possibly with some data in it, which is accessible to the Containers in a Pod. How that directory comes to be, the medium that backs it, and the contents of it are determined by the particular volume type used.
To use a volume, a Pod specifies what volumes to provide for the Pod (the .spec.volumes field) and where to mount those into Containers (the .spec.containers[*].volumeMounts field).
A process in a container sees a filesystem view composed from their Docker image and volumes. The Docker image is at the root of the filesystem hierarchy, and any volumes are mounted at the specified paths within the image. Volumes can not mount onto other volumes
func Volume_FromConfigMap ¶
func Volume_FromConfigMap(configMap IConfigMap, options *ConfigMapVolumeOptions) Volume
Populate the volume from a ConfigMap.
The configMap resource provides a way to inject configuration data into Pods. The data stored in a ConfigMap object can be referenced in a volume of type configMap and then consumed by containerized applications running in a Pod.
When referencing a configMap object, you can simply provide its name in the volume to reference it. You can also customize the path to use for a specific entry in the ConfigMap.
func Volume_FromEmptyDir ¶
func Volume_FromEmptyDir(name *string, options *EmptyDirVolumeOptions) Volume
An emptyDir volume is first created when a Pod is assigned to a Node, and exists as long as that Pod is running on that node.
As the name says, it is initially empty. Containers in the Pod can all read and write the same files in the emptyDir volume, though that volume can be mounted at the same or different paths in each Container. When a Pod is removed from a node for any reason, the data in the emptyDir is deleted forever. See: http://kubernetes.io/docs/user-guide/volumes#emptydir
func Volume_FromSecret ¶
func Volume_FromSecret(secret ISecret, options *SecretVolumeOptions) Volume
Populate the volume from a Secret.
A secret volume is used to pass sensitive information, such as passwords, to Pods. You can store secrets in the Kubernetes API and mount them as files for use by pods without coupling to Kubernetes directly.
secret volumes are backed by tmpfs (a RAM-backed filesystem) so they are never written to non-volatile storage. See: https://kubernetes.io/docs/concepts/storage/volumes/#secret
type VolumeMount ¶
type VolumeMount struct { // Determines how mounts are propagated from the host to container and the other way around. // // When not set, MountPropagationNone is used. // // Mount propagation allows for sharing volumes mounted by a Container to // other Containers in the same Pod, or even to other Pods on the same node. // // This field is beta in 1.10. Propagation MountPropagation `json:"propagation" yaml:"propagation"` // Mounted read-only if true, read-write otherwise (false or unspecified). // // Defaults to false. ReadOnly *bool `json:"readOnly" yaml:"readOnly"` // Path within the volume from which the container's volume should be mounted.). SubPath *string `json:"subPath" yaml:"subPath"` // Expanded path within the volume from which the container's volume should be mounted. // // Behaves similarly to SubPath but environment variable references // $(VAR_NAME) are expanded using the container's environment. Defaults to "" // (volume's root). SubPathExpr and SubPath are mutually exclusive. This field // is beta in 1.15. // // `subPathExpr` and `subPath` are mutually exclusive. This field is beta in // 1.15. SubPathExpr *string `json:"subPathExpr" yaml:"subPathExpr"` // Path within the container at which the volume should be mounted. // // Must not // contain ':'. Path *string `json:"path" yaml:"path"` // The volume to mount. Volume Volume `json:"volume" yaml:"volume"` }
Mount a volume from the pod to the container.