index.ts
Overview
This file serves as the **Pulumi deployment entrypoint** for the **Solana blockchain coinstack** within the ShapeShift Unchained platform. Its primary responsibility is to orchestrate the deployment of the Solana blockchain node infrastructure into a Kubernetes cluster by invoking shared deployment utilities.
Specifically, it:
Reads environment variables from a sample environment file.
Retrieves Kubernetes configuration, namespace, and coinstack-specific deployment configuration.
Calls a generic
deployCoinstackfunction to provision the Solana node services (daemon, indexer, etc.) according to the loaded configuration.
This minimal entrypoint leverages a standardized pattern common to all multi-blockchain coinstacks, enabling consistent, repeatable deployments across different blockchain networks.
Detailed Explanation
Exported Async Function (Default Export)
export = async (): Promise<Outputs> => { ... }
Purpose
Acts as the main entrypoint when Pulumi runs this deployment script.
Returns a Promise resolving to an
Outputsobject representing deployed resources' metadata.
Parameters
None.
Return Value
Promise<Outputs>: Resolves after the deployment completes, containing output information such as Kubernetes resource states, service endpoints, or other relevant metadata.
Function Body Breakdown
Constants:
const appName = 'unchained' const coinstack = 'solana'appName: Identifies the application context. Here, "unchained" is the umbrella app for coinstacks.coinstack: Specifies the blockchain being deployed ("solana" in this case).
Read Environment File:
const sampleEnv = readFileSync('../sample.env')Synchronously reads a
.env-style file containing environment variables tailored for the Solana coinstack deployment.This data will be injected as environment configuration into the deployed pods.
Retrieve Kubernetes and Deployment Config:
const { kubeconfig, config, namespace } = await getConfig()Calls a shared utility
getConfig()to asynchronously fetch:kubeconfig: Kubernetes cluster access credentials and context.config: The coinstack-specific deployment configuration, likely parsed from a YAML or JSON file.namespace: Kubernetes namespace for resource isolation.
Invoke Deployment Function:
return deployCoinstack({ appName, coinstack, coinstackType: 'node', config, kubeconfig, namespace, sampleEnv, })Calls the generic
deployCoinstackfunction from the shared Pulumi library, passing all relevant deployment parameters.coinstackType: 'node'indicates this deployment is for a node-based blockchain stack (as opposed to, for example, API-only stacks).deployCoinstackis responsible for creating Kubernetes StatefulSets, Services, ConfigMaps, and other resources based on the provided configuration.
Important Implementation Details
Minimal Entrypoint: Unlike some other coinstack deployments, this file does not explicitly map individual services (daemon, indexer) or customize ports and probes within itself. It relies on
deployCoinstackand the shared config to handle those details.Environment Injection: The
.envfile is read synchronously and passed downstream to be used in pod environment variables or ConfigMaps, enabling environment-specific customization.Kubernetes Context Awareness:
getConfig()abstracts away cluster credentials and namespace lookup to simplify the deployment logic here.Pulumi Asynchronous Pattern: Exporting an async function returning a
Promise<Outputs>conforms to Pulumi's Javascript/Typescript requirements for dynamic program entrypoints.
Interaction with Other System Components
Pulumi Shared Modules:
deployCoinstack(frompulumi/src/coinstack): Core deployment logic shared across all blockchain coinstacks. It interprets the config and provisions Kubernetes resources accordingly.getConfig(frompulumi/src): Utility to retrieve Kubernetes and deployment configurations.
Kubernetes Cluster:
The script provisions resources into a Kubernetes namespace, managing lifecycle of pods running Solana node components.
Environment & Configuration Files:
Reads
../sample.envwhich should contain environment variables tailored for the Solana deployment.Uses the
configobject fromgetConfig()which defines the services, ports, probes, and volumes to deploy.
Multi-Blockchain Coinstacks Framework:
This file fits into the larger modular architecture where each blockchain network is deployed via a similar script enabling consistent infrastructure management.
Usage Example
This file is not invoked directly by developers but executed by Pulumi during deployment:
pulumi up --cwd ./path/to/solana/coinstack/pulumi
Pulumi loads this `index.ts` as the deployment entrypoint, runs the exported async function, and applies the resulting infrastructure changes.
Mermaid Diagram: Flowchart of index.ts Deployment Workflow
flowchart TD
A[Pulumi Starts Deployment] --> B[Read sample.env File]
B --> C[Call getConfig() to fetch kubeconfig, config, namespace]
C --> D[Call deployCoinstack() with parameters]
D --> E[deployCoinstack provisions Kubernetes resources]
E --> F[Kubernetes creates StatefulSets, Services, ConfigMaps]
F --> G[Pods start Solana daemon and indexer nodes]
G --> H[Deployment completes with Outputs]
Summary
Aspect | Description |
|---|---|
**File Purpose** | Pulumi deployment entrypoint for Solana coinstack. |
**Exports** | Async function returning `Promise`. |
**Key Operations** | Reads env file, loads config, calls generic deploy function. |
**Dependencies** | `deployCoinstack`, `getConfig`, `readFileSync`. |
**Target** | Kubernetes cluster deploying Solana blockchain nodes. |
**Role in System** | Part of multi-blockchain modular deployment framework. |
This concise but critical file abstracts the deployment of Solana blockchain infrastructure by leveraging shared Pulumi deployment utilities and configuration. Its simplicity aligns with the modular architecture of the multi-blockchain coinstacks system.