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:

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

Parameters

Return Value

Function Body Breakdown

  1. 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).

  2. 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.

  3. 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.

  4. Invoke Deployment Function:

    return deployCoinstack({
      appName,
      coinstack,
      coinstackType: 'node',
      config,
      kubeconfig,
      namespace,
      sampleEnv,
    })
    
    • Calls the generic deployCoinstack function 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).

    • deployCoinstack is responsible for creating Kubernetes StatefulSets, Services, ConfigMaps, and other resources based on the provided configuration.


Important Implementation Details


Interaction with Other System Components


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.