import { Construct } from 'constructs'; import { Plone } from './plone'; /** * Health probe configuration for a VinylCache backend. */ export interface VinylCacheBackendProbe { /** * URL to probe. * @default '/' */ readonly url?: string; /** * How often to probe the backend. * @default '5s' */ readonly interval?: string; /** * Maximum time to wait for a probe response. * @default '2s' */ readonly timeout?: string; /** * Number of most recent probes to consider. * @default 10 */ readonly window?: number; /** * Minimum successful probes within window for healthy status. * @default 8 */ readonly threshold?: number; /** * Expected HTTP response status code. * @default 200 */ readonly expectedResponse?: number; } /** * An additional backend for the VinylCache. */ export interface VinylCacheBackend { /** * VCL identifier for this backend. Must match ^[a-zA-Z][a-zA-Z0-9_]*$. */ readonly name: string; /** * Kubernetes Service name to use as backend. */ readonly serviceName: string; /** * Port to use for this backend. */ readonly port: number; /** * Health probe configuration. * @default - no probe */ readonly probe?: VinylCacheBackendProbe; /** * Relative weight for the director. 0 means standby. * @default - operator default */ readonly weight?: number; } /** * A Varnish storage backend configuration. * * Maps to `spec.storage[]` on the VinylCache CRD. The operator emits one * `-s =,` argument per entry to varnishd. * * Without any storage entry the operator falls back to the varnishd default * (~100 MB malloc), which is almost always too small for real workloads. */ export interface VinylCacheStorage { /** * Internal storage identifier used in the varnishd `-s` argument. * Must be unique within the VinylCache and match `^[a-zA-Z][a-zA-Z0-9_]*$`. */ readonly name: string; /** * Storage backend type. Only "malloc" and "file" are permitted by the * admission webhook. */ readonly type: 'malloc' | 'file'; /** * Storage allocation as a Kubernetes resource quantity (e.g. "1Gi", "500M"). * Required for malloc; required for file. * @default - required for both malloc and file */ readonly size?: string; /** * Filesystem path for file-type storage. Ignored for malloc. * @default - required for type "file" */ readonly path?: string; } /** * A Kubernetes toleration for the Varnish pods. */ export interface VinylCacheToleration { /** * The taint key to tolerate. */ readonly key: string; /** * The operator (Equal or Exists). * @default 'Equal' */ readonly operator?: string; /** * The taint value to match (when operator is Equal). * @default - no value */ readonly value?: string; /** * The taint effect to tolerate (NoSchedule, PreferNoSchedule, NoExecute). * @default - tolerate all effects */ readonly effect?: string; } /** * Configuration options for PloneVinylCache (cloud-vinyl operator). * * Creates a VinylCache custom resource that the cloud-vinyl operator * reconciles into a Varnish Cache cluster with agent-based VCL delivery. * * Requires the cloud-vinyl operator to be installed in the cluster. */ export interface PloneVinylCacheOptions { /** * The Plone construct to attach the cache to. * Backends are auto-configured from the Plone services. */ readonly plone: Plone; /** * Additional backends to add after the auto-generated Plone backends. * Uses the same backend type structure as the VinylCache CRD. * @default - no extra backends */ readonly extraBackends?: VinylCacheBackend[]; /** * Number of Varnish pod replicas. * @default 2 */ readonly replicas?: number; /** * CPU request for Varnish pods. * @default '100m' */ readonly requestCpu?: string; /** * Memory request for Varnish pods. * @default '256Mi' */ readonly requestMemory?: string; /** * CPU limit for Varnish pods. * @default '500m' */ readonly limitCpu?: string; /** * Memory limit for Varnish pods. * @default '512Mi' */ readonly limitMemory?: string; /** * Varnish storage backends (`spec.storage`). * * Each entry becomes a `-s =,` argument to varnishd. * If omitted, the operator ships varnishd with its stock default (~100 MB * malloc) — almost always too small. Set an explicit malloc size at least * matching the pod's memory request to use the allocated memory for caching. * * @default - no storage configured; operator uses varnishd default (~100MB malloc) * @example * storage: [{ name: 's0', type: 'malloc', size: '1Gi' }] */ readonly storage?: VinylCacheStorage[]; /** * Director type for load distribution. * @default 'shard' */ readonly director?: string; /** * Shard director: what value is hashed for shard selection. * "HASH" uses the Varnish hash (default); "URL" uses the request URL. * Only applied when director is "shard". * Requires cloud-vinyl operator >= 0.4.2. * @default - operator default ("HASH") */ readonly shardBy?: string; /** * Shard director: which backends the director considers when selecting a shard. * "CHOSEN" (default) only considers the chosen backend healthy; "ALL" requires all * backends to be healthy. * Only applied when director is "shard". * Requires cloud-vinyl operator >= 0.4.2. * @default - operator default ("CHOSEN") */ readonly shardHealthy?: string; /** * Shard director: time after adding a backend before it receives its full share of * traffic, preventing thundering-herd. * Only applied when director is "shard". * @default - operator default ("30s") */ readonly shardRampup?: string; /** * Shard director: number of Ketama replicas per backend in the hash ring. * Only applied when director is "shard". * @default - operator default (67) */ readonly shardReplicas?: number; /** * Custom VCL snippet for vcl_recv subroutine. * Replaces the default Plone recv snippet. * @default - uses built-in plone-vinyl-recv.vcl */ readonly vclRecvSnippet?: string; /** * Custom VCL snippet for vcl_backend_response subroutine. * Replaces the default Plone backend_response snippet. * @default - uses built-in plone-vinyl-backend-response.vcl */ readonly vclBackendResponseSnippet?: string; /** * Enable cache invalidation (PURGE, BAN, xkey). * @default true */ readonly invalidation?: boolean; /** * Enable Prometheus monitoring. When true this turns on operator metrics, * a ServiceMonitor, and the prometheus_varnish_exporter sidecar (required * for cache hit-ratio and backend-health metrics). * @default false */ readonly monitoring?: boolean; /** * Container image for the Varnish pods. * @default 'varnish:7.6' */ readonly image?: string; /** * Tolerations for the Varnish pods. * @default - no tolerations */ readonly tolerations?: VinylCacheToleration[]; /** * Node selector labels for the Varnish pods. * Constrains pods to nodes matching all specified labels. * @default - no node selector */ readonly nodeSelector?: { [key: string]: string; }; /** * Custom VCL snippet for vcl_deliver subroutine. * @default - no snippet */ readonly vclDeliverSnippet?: string; /** * Custom VCL snippet for vcl_hit subroutine. * @default - no snippet */ readonly vclHitSnippet?: string; /** * Custom VCL snippet for vcl_miss subroutine. * @default - no snippet */ readonly vclMissSnippet?: string; /** * Custom VCL snippet for vcl_pass subroutine. * @default - no snippet */ readonly vclPassSnippet?: string; /** * Custom VCL snippet for vcl_pipe subroutine. * @default - no snippet */ readonly vclPipeSnippet?: string; /** * Custom VCL snippet for vcl_synth subroutine. * @default - no snippet */ readonly vclSynthSnippet?: string; /** * Custom VCL snippet for vcl_purge subroutine. * @default - no snippet */ readonly vclPurgeSnippet?: string; /** * Custom VCL snippet for vcl_hash subroutine. * @default - no snippet */ readonly vclHashSnippet?: string; /** * Custom VCL snippet for vcl_init subroutine. * @default - no snippet */ readonly vclInitSnippet?: string; /** * Custom VCL snippet for vcl_fini subroutine. * @default - no snippet */ readonly vclFiniSnippet?: string; /** * Custom VCL snippet for vcl_backend_fetch subroutine. * @default - no snippet */ readonly vclBackendFetchSnippet?: string; /** * Custom VCL snippet for vcl_backend_error subroutine. * @default - no snippet */ readonly vclBackendErrorSnippet?: string; } /** * PloneVinylCache construct for deploying Varnish Cache via cloud-vinyl operator. * * Creates a VinylCache custom resource with Plone backend/frontend services * auto-configured as backends. The cloud-vinyl operator manages the full * Varnish lifecycle including VCL generation, agent delivery, and monitoring. * * Requires the cloud-vinyl operator to be installed in the cluster. * * @example * const plone = new Plone(chart, 'plone'); * const cache = new PloneVinylCache(chart, 'cache', { * plone: plone, * replicas: 2, * }); * // Use cache.vinylCacheServiceName for IngressRoute */ export declare class PloneVinylCache extends Construct { /** * Name of the VinylCache service created by the operator. * Use this to reference the cache service from ingress or other constructs. */ readonly vinylCacheServiceName: string; constructor(scope: Construct, id: string, options: PloneVinylCacheOptions); }