import { Construct } from 'constructs'; import { Service, ServiceType } from './service'; import { Resource, ResourceProps } from './base'; import * as cdk8s from 'cdk8s'; import { ApiObjectMetadataDefinition } from 'cdk8s'; import { RestartPolicy, IPodTemplate, PodTemplateProps } from './pod'; import { Volume } from './volume'; import { Container } from './container'; import { IServiceAccount } from './service-account'; /** * (experimental) Properties for initialization of `Deployment`. * * @experimental */ export interface DeploymentProps extends ResourceProps, PodTemplateProps { /** * (experimental) Number of desired pods. * * @default 1 * @experimental */ readonly replicas?: number; /** * (experimental) 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()`. * * @default true * @experimental */ readonly defaultSelector?: boolean; } /** * (experimental) Options for exposing a deployment via a service. * * @experimental */ export interface ExposeOptions { /** * (experimental) The type of the exposed service. * * @default - ClusterIP. * @experimental */ readonly serviceType?: ServiceType; } /** * (experimental) 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. * * @experimental */ export declare class Deployment extends Resource implements IPodTemplate { /** * (experimental) Number of desired pods. * * @experimental */ readonly replicas: number; /** * (experimental) The underlying cdk8s API object. * * @see base.Resource.apiObject * @experimental */ protected readonly apiObject: cdk8s.ApiObject; private readonly _podTemplate; private readonly _labelSelector; /** * @experimental */ constructor(scope: Construct, id: string, props?: DeploymentProps); /** * (experimental) Provides read/write access to the underlying pod metadata of the resource. * * @experimental */ get podMetadata(): ApiObjectMetadataDefinition; /** * (experimental) The labels this deployment will match against in order to select pods. * * Returns a a copy. Use `selectByLabel()` to add labels. * * @experimental */ get labelSelector(): Record; /** * (experimental) The containers belonging to the pod. * * Use `addContainer` to add containers. * * @experimental */ get containers(): Container[]; /** * (experimental) The volumes associated with this pod. * * Use `addVolume` to add volumes. * * @experimental */ get volumes(): Volume[]; /** * (experimental) Restart policy for all containers within the pod. * * @experimental */ get restartPolicy(): RestartPolicy | undefined; /** * (experimental) The service account used to run this pod. * * @experimental */ get serviceAccount(): IServiceAccount | undefined; /** * (experimental) Configure a label selector to this deployment. * * Pods that have the label will be selected by deployments configured with this spec. * * @param key - The label key. * @param value - The label value. * @experimental */ selectByLabel(key: string, value: string): void; /** * (experimental) Expose a deployment via a service. * * This is equivalent to running `kubectl expose deployment `. * * @param port The port number the service will bind to. * @param options Options. * @experimental */ expose(port: number, options?: ExposeOptions): Service; /** * (experimental) Add a container to the pod. * * @experimental */ addContainer(container: Container): void; /** * (experimental) Add a volume to the pod. * * @experimental */ addVolume(volume: Volume): void; }