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
}

**Usage example:**

const dockerCredentials: Dockerhub = {
  username: "myuser",
  password: "mypassword",
  server: "docker.io"
}

2. BaseConfig

export interface BaseConfig {
  dockerhub?: Dockerhub
  additionalEnvironments?: string[]
  rootDomainName?: string
}

**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>
}

4. Config

export interface Config extends BaseConfig {
  stack: string
  assetName: string
  network: string
  environment?: string
  api?: ApiConfig
  statefulService?: StatefulService
}

5. Port

export interface Port extends k8s.types.input.core.v1.ServicePort {
  ingressRoute?: boolean
  pathPrefix?: string
  stripPathPrefix?: boolean
}

6. StorageClass

export type StorageClass = 'gp2' | '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
}

**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
}

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>
}

10. Outputs

export type Outputs = Record<string, any>

Important Implementation Details


Interaction with Other System Components

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.