import { Construct } from 'constructs'; import { ResourceProps, Resource } from './base'; import * as cdk8s from 'cdk8s'; import { IServiceAccount } from './service-account'; import { Container } from './container'; import { Volume } from './volume'; import { ApiObjectMetadata, ApiObjectMetadataDefinition } from 'cdk8s'; /** * (experimental) 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. * * @experimental */ export interface IPodSpec { /** * (experimental) The containers belonging to the pod. * * Use `addContainer` to add containers. * * @experimental */ readonly containers: Container[]; /** * (experimental) The volumes associated with this pod. * * Use `addVolume` to add volumes. * * @experimental */ readonly volumes: Volume[]; /** * (experimental) Restart policy for all containers within the pod. * * @experimental */ readonly restartPolicy?: RestartPolicy; /** * (experimental) The service account used to run this pod. * * @experimental */ readonly serviceAccount?: IServiceAccount; /** * (experimental) Add a container to the pod. * * @param container The container. * @experimental */ addContainer(container: Container): void; /** * (experimental) Add a volume to the pod. * * @param volume The volume. * @experimental */ addVolume(volume: Volume): void; } /** * (experimental) Represents a resource that can be configured with a kuberenets pod template. (e.g `Deployment`, `Job`, ...). * * Use the `PodTemplate` class as an implementation helper. * * @experimental */ export interface IPodTemplate extends IPodSpec { /** * (experimental) Provides read/write access to the underlying pod metadata of the resource. * * @experimental */ readonly podMetadata: ApiObjectMetadataDefinition; } /** * (experimental) Provides read/write capabilities ontop of a `PodSpecProps`. * * @experimental */ export declare class PodSpec implements IPodSpec { /** * (experimental) Restart policy for all containers within the pod. * * @experimental */ readonly restartPolicy?: RestartPolicy; /** * (experimental) The service account used to run this pod. * * @experimental */ readonly serviceAccount?: IServiceAccount; private readonly _containers; private readonly _volumes; /** * @experimental */ constructor(props?: PodSpecProps); /** * (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) Add a container to the pod. * * @experimental */ addContainer(container: Container): void; /** * (experimental) Add a volume to the pod. * * @experimental */ addVolume(volume: Volume): void; } /** * (experimental) Properties of a `PodTemplate`. * * Adds metadata information on top of the spec. * * @experimental */ export interface PodTemplateProps extends PodSpecProps { /** * (experimental) The pod metadata. * * @experimental */ readonly podMetadata?: ApiObjectMetadata; } /** * (experimental) Provides read/write capabilities ontop of a `PodTemplateProps`. * * @experimental */ export declare class PodTemplate extends PodSpec implements IPodTemplate { /** * (experimental) Provides read/write access to the underlying pod metadata of the resource. * * @experimental */ readonly podMetadata: ApiObjectMetadataDefinition; /** * @experimental */ constructor(props?: PodTemplateProps); } /** * (experimental) Properties for initialization of `Pod`. * * @experimental */ export interface PodProps extends ResourceProps, PodSpecProps { } /** * (experimental) Properties of a `PodSpec`. * * @experimental */ export interface PodSpecProps { /** * (experimental) 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()` * * @default - No containers. Note that a pod spec must include at least one container. * @experimental */ readonly containers?: Container[]; /** * (experimental) List of volumes that can be mounted by containers belonging to the pod. * * You can also add volumes later using `podSpec.addVolume()` * * @default - No volumes. * @see https://kubernetes.io/docs/concepts/storage/volumes * @experimental */ readonly volumes?: Volume[]; /** * (experimental) Restart policy for all containers within the pod. * * @default RestartPolicy.ALWAYS * @see https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle/#restart-policy * @experimental */ readonly restartPolicy?: RestartPolicy; /** * (experimental) 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). * * @default - No service account. * @see https://kubernetes.io/docs/tasks/configure-pod-container/configure-service-account/ * @experimental */ readonly serviceAccount?: IServiceAccount; } /** * (experimental) Pod is a collection of containers that can run on a host. * * This resource is * created by clients and scheduled onto hosts. * * @experimental */ export declare class Pod extends Resource implements IPodSpec { /** * (experimental) The underlying cdk8s API object. * * @see base.Resource.apiObject * @experimental */ protected readonly apiObject: cdk8s.ApiObject; private readonly _spec; /** * @experimental */ constructor(scope: Construct, id: string, props?: PodProps); /** * (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) Add a container to the pod. * * @experimental */ addContainer(container: Container): void; /** * (experimental) Add a volume to the pod. * * @experimental */ addVolume(volume: Volume): void; } /** * (experimental) Restart policy for all containers within the pod. * * @experimental */ export declare enum RestartPolicy { /** * (experimental) Always restart the pod after it exits. * * @experimental */ ALWAYS = "Always", /** * (experimental) Only restart if the pod exits with a non-zero exit code. * * @experimental */ ON_FAILURE = "OnFailure", /** * (experimental) Never restart the pod. * * @experimental */ NEVER = "Never" }