npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@qrvey/cluster-sdk

v1.0.0-654

Published

A TypeScript SDK for managing Kubernetes resources including cluster clients, secrets, and container registry operations

Readme

@qrvey/cluster-sdk

install size coverage

@qrvey/cluster-sdk is a TypeScript library for interacting with Kubernetes cluster resources from Node.js applications. It provides services to manage Kubernetes clients, read secrets, extract registry credentials, and verify container image availability in registries.

Features

  • Read and parse Kubernetes secrets
  • Extract Docker registry credentials from secrets
  • Verify container image existence in registries

Installation

npm install @qrvey/cluster-sdk

or

yarn add @qrvey/cluster-sdk

Prerequisites

This library requires access to a Kubernetes cluster. It uses the Kubernetes client configuration from the default location (typically ~/.kube/config or in-cluster config when running inside a pod).

Optional Environment Variables

The following environment variables are optional and provide defaults for certain operations:

  • JOB_NAMESPACE - Default namespace for secret operations (default: 'qrveyapps-jobs')
  • JOB_IMAGE_PULL_SECRET_NAME - Default secret name for registry credentials (default: 'regcred')

Usage

ClusterClientService

Base service that provides access to Kubernetes API clients.

import { ClusterClientService } from '@qrvey/cluster-sdk';

const clusterClient = new ClusterClientService();

// Get CoreV1Api client for core Kubernetes resources
const coreApi = clusterClient.getCoreV1Api();

// Get BatchV1Api client for batch resources (jobs, cronjobs)
const batchApi = clusterClient.getBatchV1Api();

// Get KubeConfig instance
const kubeConfig = clusterClient.getKubeConfig();

SecretControllerService

Service for reading and parsing Kubernetes secrets, particularly Docker registry credentials.

import {
    ClusterClientService,
    SecretControllerService,
} from '@qrvey/cluster-sdk';

const clusterClient = new ClusterClientService();
const secretController = new SecretControllerService(clusterClient);

// Read a secret
const secret = await secretController.getSecret('my-namespace', 'my-secret');

// Extract registry credentials from a Docker config secret
const credentials = await secretController.getRegistryCredentialsFromSecret(
    'my-namespace',
    'regcred',
);

console.log(credentials);
// {
//   username: 'my.user',
//   password: 'my.password',
//   registry: 'https://myregistry.azurecr.io'
// }

RegistryImageService

Service for verifying container image availability in registries using credentials from Kubernetes secrets.

Check Single Image

import { ClusterClientService, RegistryImageService } from '@qrvey/cluster-sdk';

const clusterClient = new ClusterClientService();
const registryImageService = new RegistryImageService(clusterClient);

// Check if an image exists in a registry
const exists = await registryImageService.imageExists(
    'https://myregistry.azurecr.io',
    'my-image',
    'v1.0.0',
    'my-namespace', // optional, uses JOB_NAMESPACE env var if not provided
    'regcred', // optional, uses JOB_IMAGE_PULL_SECRET_NAME env var if not provided
);

console.log(exists); // true or false

Check Multiple Images

import { ClusterClientService, RegistryImageService } from '@qrvey/cluster-sdk';

const clusterClient = new ClusterClientService();
const registryImageService = new RegistryImageService(clusterClient);

const imagesToCheck = [
    {
        registryUrl: 'https://myregistry.azurecr.io',
        imageName: 'app-backend',
        imageTag: 'v1.0.0',
    },
    {
        registryUrl: 'https://myregistry.azurecr.io',
        imageName: 'app-frontend',
        imageTag: 'v1.0.0',
    },
];

const results = await registryImageService.checkImages(
    imagesToCheck,
    'my-namespace', // optional
    'regcred', // optional
);

console.log(results);
// [
//   { registryUrl: '...', imageName: 'app-backend', imageTag: 'v1.0.0', exists: true },
//   { registryUrl: '...', imageName: 'app-frontend', imageTag: 'v1.0.0', exists: false }
// ]

Error Handling

The library provides custom error classes for better error handling:

import {
    ClusterSDKError,
    SecretError,
    RegistryError,
} from '@qrvey/cluster-sdk';

try {
    const credentials = await secretController.getRegistryCredentialsFromSecret(
        'my-namespace',
        'regcred',
    );
} catch (error) {
    if (error instanceof SecretError) {
        console.error('Secret error:', error.message);
        console.error('Secret name:', error.toJSON().details.secretName);
        console.error('Namespace:', error.toJSON().details.namespace);
    } else if (error instanceof RegistryError) {
        console.error('Registry error:', error.message);
        console.error('Registry:', error.toJSON().details.registry);
    }
}

API Reference

ClusterClientService

  • getCoreV1Api() - Returns CoreV1Api instance for Kubernetes core resources
  • getBatchV1Api() - Returns BatchV1Api instance for batch resources
  • getKubeConfig() - Returns KubeConfig instance

SecretControllerService

  • getSecret(namespace: string, secretName: string): Promise<V1Secret> - Reads a Kubernetes secret
  • getRegistryCredentialsFromSecret(namespace: string, secretName: string): Promise<RegistryCredentials> - Extracts Docker registry credentials from a secret

RegistryImageService

  • imageExists(registryUrl: string, imageName: string, tag: string, namespace?: string, secretName?: string): Promise<boolean> - Checks if an image exists in a registry
  • checkImages(images: IServiceImageReference[], namespace?: string, secretName?: string): Promise<Array<IServiceImageReference & { exists: boolean }>> - Checks multiple images in batch