index.ts
Overview
The [index.ts](/projects/291/68798) file serves as a centralized module that consolidates and exports configuration interfaces and types primarily related to Kubernetes-based service deployments, Docker integration, and service state management. It defines key TypeScript interfaces that describe configuration schemas for Docker Hub credentials, Kubernetes services, persistent storage, and stateful applications. Additionally, it re-exports modules from adjacent files such as `config`, `api`, `docker`, `statefulService`, and `hasher`, facilitating a clean and organized import structure for consumers of this package.
This file is foundational in defining the shape and expectations of configuration objects used across the broader system, particularly for orchestrating containerized services on Kubernetes clusters using Pulumi infrastructure-as-code tooling.
Detailed Description of Interfaces and Types
1. Dockerhub
export interface Dockerhub {
username: string
password: string
server: string
}
Purpose: Represents credentials and server information required to authenticate with a Docker registry (Docker Hub or private registry).
Properties:
username: Docker registry username.password: Docker registry password.server: URL or address of the Docker registry server.
**Usage example:**
const dockerCredentials: Dockerhub = {
username: "myuser",
password: "mypassword",
server: "docker.io"
}
2. BaseConfig
export interface BaseConfig {
dockerhub?: Dockerhub
additionalEnvironments?: string[]
rootDomainName?: string
}
Purpose: Base configuration interface for service deployments, including Docker registry access and DNS ingress setup.
Properties:
dockerhub: Optional credentials for Docker Hub, used when creating repositories and handling image push/pull.additionalEnvironments: Optional array of additional environment names or labels.rootDomainName: Optional root domain for creating ingress resources. Requires ExternalDNS and Traefik to be configured on the Kubernetes cluster.
**Implementation note:** The `rootDomainName` property assumes that ExternalDNS (automated DNS record management) and Traefik (Ingress controller) are pre-configured in the Kubernetes environment to route traffic properly.
3. StatefulService
export interface StatefulService {
replicas: number
services: Array<ServiceConfig>
}
Purpose: Represents a stateful service deployment, typically a Kubernetes StatefulSet.
Properties:
replicas: Number of pod replicas.services: Array ofServiceConfigobjects defining the individual services that comprise the stateful application.
4. Config
export interface Config extends BaseConfig {
stack: string
assetName: string
network: string
environment?: string
api?: ApiConfig
statefulService?: StatefulService
}
Purpose: Main configuration interface extending
BaseConfigwith additional deployment context.Properties:
stack: Deployment stack name (e.g., dev, prod).assetName: Name of the deployment asset or application.network: Network or Kubernetes namespace targeted.environment: Optional environment label.api: Optional API configuration (ApiConfigimported from./api).statefulService: Optional stateful service configuration.
5. Port
export interface Port extends k8s.types.input.core.v1.ServicePort {
ingressRoute?: boolean
pathPrefix?: string
stripPathPrefix?: boolean
}
Purpose: Extends Kubernetes
ServicePorttype with additional ingress routing metadata.Properties:
Inherits all properties from
k8s.types.input.core.v1.ServicePort(e.g.,port,targetPort,protocol).ingressRoute: Optional boolean indicating if this port should expose an ingress route.pathPrefix: Optional string to specify an HTTP path prefix for ingress routing.stripPathPrefix: Optional boolean indicating if the path prefix should be stripped before forwarding.
6. StorageClass
export type StorageClass = 'gp2' | 'gp3'
Defines allowed storage class names for persistent volumes, reflecting AWS EBS volume types (gp2 and gp3).
7. ServiceConfig
export interface ServiceConfig {
cpuLimit: string
cpuRequest?: string
image: string
memoryLimit: string
memoryRequest?: string
name: string
storageSize: string
storageIops?: string
storageThroughput?: string
storageClassName?: StorageClass
}
Purpose: Configuration schema for a single Kubernetes service container.
Properties:
cpuLimit: CPU limit for the container (e.g., '500m').cpuRequest: Optional CPU request (guaranteed CPU).image: Docker image reference.memoryLimit: Memory limit (e.g., '512Mi').memoryRequest: Optional memory request.name: Service name, used for identification.storageSize: Persistent volume claim size (e.g., '20Gi').storageIops: Optional IOPS for gp3 volumes only (baseline 3000, max 16000).storageThroughput: Optional throughput for gp3 volumes (baseline 125 MiB/s, max 1000 MiB/s).storageClassName: Optional storage class, either 'gp2' or 'gp3'.
**Implementation details:** The `storageIops` and `storageThroughput` parameters are relevant only for `gp3` storage classes and control performance tuning of AWS EBS volumes. If omitted, defaults equivalent to `gp2` are used.
8. CoinServiceArgs
export interface CoinServiceArgs extends ServiceConfig {
ports?: Record<string, Port>
command?: Array<string>
args?: Array<string>
env?: Record<string, string>
dataDir?: string
configMapData?: Record<string, string>
volumeMounts?: Array<k8s.types.input.core.v1.VolumeMount>
startupProbe?: k8s.types.input.core.v1.Probe
livenessProbe?: k8s.types.input.core.v1.Probe
readinessProbe?: k8s.types.input.core.v1.Probe
useMonitorContainer?: boolean
}
Purpose: Extends
ServiceConfigwith additional Kubernetes pod/container-level configuration specific to a "coin" service (likely a blockchain or distributed service).Properties:
ports: Optional mapping of port names toPortdefinitions.command: Optional array defining the container entrypoint command.args: Optional array of command arguments.env: Optional environment variables mapping.dataDir: Optional directory path for persistent data inside the container.configMapData: Optional key-value pairs for Kubernetes ConfigMap to be mounted.volumeMounts: Optional array of Kubernetes volume mounts.startupProbe: Optional Kubernetes startup probe configuration.livenessProbe: Optional Kubernetes liveness probe configuration.readinessProbe: Optional Kubernetes readiness probe configuration.useMonitorContainer: Optional boolean flag to deploy an additional monitoring container alongside the main container.
9. Service
export interface Service {
name: string
ports: Array<Port>
configMapData: Record<string, string>
containers: Array<k8s.types.input.core.v1.Container>
volumeClaimTemplates: Array<k8s.types.input.core.v1.PersistentVolumeClaim>
}
Purpose: Defines a fully realized service abstraction ready to be deployed on Kubernetes.
Properties:
name: Service name.ports: Array of ports exposed by the service.configMapData: Configuration data to be embedded as Kubernetes ConfigMap.containers: Kubernetes container definitions.volumeClaimTemplates: Kubernetes PersistentVolumeClaim templates for stateful volumes.
10. Outputs
export type Outputs = Record<string, any>
Purpose: Generic key-value map used for output values, typically representing deployment outputs or resource attributes.
Type: Allows any type of value under string keys, useful for passing dynamic deployment results.
Important Implementation Details
The file uses Pulumi's Kubernetes SDK types (
k8s.types.input.core.v1.*) to strongly type Kubernetes resource specifications for containers, probes, volume mounts, service ports, and persistent volume claims.The interfaces capture both high-level configuration (e.g.,
Config,StatefulService) and detailed container-level specifications (CoinServiceArgs,ServiceConfig), enabling a layered and modular configuration approach.The emphasis on AWS EBS storage classes (
gp2andgp3) and associated parameters like IOPS and throughput suggests this system is tuned for AWS cloud deployments with performance-sensitive storage requirements.Re-exported modules (
config,api,docker,statefulService,hasher) imply this file acts as an entry point or facade, simplifying imports for downstream consumers.
Interaction with Other System Components
apimodule: Provides API-related configuration (ApiConfig), which is referenced in theConfiginterface.configmodule: Likely contains additional configuration utilities or definitions, re-exported for convenience.dockermodule: Presumably manages Docker image building and pushing, tying into theDockerhubcredentials defined here.statefulServicemodule: Expected to handle deployment logic for stateful Kubernetes services, usingStatefulServiceandServiceConfig.hashermodule: Potentially offers hashing utilities for asset versioning or configuration integrity.
This file mainly defines typings and re-exports that provide a consistent configuration contract between these modules, enabling type-safe, declarative infrastructure deployment and service management.
Visual Diagram
classDiagram
class Dockerhub {
+username: string
+password: string
+server: string
}
class BaseConfig {
+dockerhub?: Dockerhub
+additionalEnvironments?: string[]
+rootDomainName?: string
}
class StatefulService {
+replicas: number
+services: ServiceConfig[]
}
class Config {
+stack: string
+assetName: string
+network: string
+environment?: string
+api?: ApiConfig
+statefulService?: StatefulService
}
class Port {
<<extends>> k8s.types.input.core.v1.ServicePort
+ingressRoute?: boolean
+pathPrefix?: string
+stripPathPrefix?: boolean
}
class ServiceConfig {
+cpuLimit: string
+cpuRequest?: string
+image: string
+memoryLimit: string
+memoryRequest?: string
+name: string
+storageSize: string
+storageIops?: string
+storageThroughput?: string
+storageClassName?: StorageClass
}
class CoinServiceArgs {
<<extends>> ServiceConfig
+ports?: Record<string, Port>
+command?: string[]
+args?: string[]
+env?: Record<string,string>
+dataDir?: string
+configMapData?: Record<string,string>
+volumeMounts?: k8s.types.input.core.v1.VolumeMount[]
+startupProbe?: k8s.types.input.core.v1.Probe
+livenessProbe?: k8s.types.input.core.v1.Probe
+readinessProbe?: k8s.types.input.core.v1.Probe
+useMonitorContainer?: boolean
}
class Service {
+name: string
+ports: Port[]
+configMapData: Record<string,string>
+containers: k8s.types.input.core.v1.Container[]
+volumeClaimTemplates: k8s.types.input.core.v1.PersistentVolumeClaim[]
}
Config --> BaseConfig
Config --> ApiConfig
Config --> StatefulService
StatefulService --> ServiceConfig
CoinServiceArgs --> ServiceConfig
Port ..|> k8s.types.input.core.v1.ServicePort
Service --> Port
Summary
The [index.ts](/projects/291/68798) file defines a comprehensive set of TypeScript interfaces and types that specify configuration schemas for deploying containerized services on Kubernetes with Pulumi. It abstracts complexities related to Docker authentication, Kubernetes service and storage configurations, and stateful service orchestration. By centralizing these definitions and re-exporting related modules, it provides a unified interface for infrastructure and application deployment configuration across the system. This modular design supports maintainability, type safety, and clarity in managing cloud-native service lifecycles.