Skip to content

feat: made simplens k8s native - #30

Merged
Adhish-Krishna merged 47 commits into
masterfrom
development
Oct 20, 2026
Merged

Adhish-Krishna merged 47 commits into
masterfrom
development

Conversation

@Adhish-Krishna

Copy link
Copy Markdown
Member

The changes include:

  1. Made the plugin management accessible via dashboard and the updates are synchronized across all the instances or API server and notification_processor though Redis pub/sub. Installing plugins via configuration file is also there as a fallback but it is installed only at startup. Plugin management can only be done using dashboard.
  2. Added support for configuring array of fallback providers for a channel. Provider errors and rate-limits are cascaded through the fallback array automatically.
  3. Provider rate-limit usages are tracked and displayed in the dashboard in real time.
  4. API key management is added in the dashboard and notification usages are tracked on the api keys.
  5. Create k8s probe server (/healthz and /readyz) endpoint for each and every application service so that k8s can know when a pod is ready and healthy.
  6. Moved docker-compose files to docker-compose dir with separate files for separate environments (local, dev and master)
  7. Made the BASE_PATH configurable in .env file for both api and dashboard service. The share the common BASE_PATH

…v, and master environments

- Created docker-compose.dev.yaml for development environment with API server, worker, notification processor, delayed processor, recovery service, and admin dashboard.
- Created docker-compose.infra.yaml for shared infrastructure services including MongoDB, Kafka, Redis, Loki, and Grafana.
- Created docker-compose.local.yaml for local environment with build context for API server and dashboard.
- Created docker-compose.master.yaml for master environment using latest images from GHCR.
- Added scripts for switching between environments (switch-env.ps1 and switch-env.sh) with options for rebuilding images and pulling the latest versions.
…min authentication

- Added dynamic configuration service to manage operational settings with zero-restart updates.
- Refactored environment variable handling to utilize dynamic settings for various worker parameters.
- Updated system configuration model to support mixed types for dynamic settings.
- Enhanced delayed and recovery processors to listen for dynamic configuration changes and adjust intervals accordingly.
- Created integration tests for admin authentication routes and settings API.
- Added unit tests for dynamic configuration schema validations and functionality.
…hancements

- Added NpmAuthService to manage npm authentication tokens and registry configurations.
- Introduced new API endpoints for retrieving, saving, and deleting npm auth configurations.
- Enhanced plugin installation process to support private packages with authentication.
- Implemented validation for SimpleNSProvider to ensure compliance with required methods and manifest structure.
- Updated schemas for npm auth configuration and plugin installation payloads.
- Added integration and unit tests for the new npm auth service and plugin validation logic.
…s and scopes

- Updated API client to handle npm auth configurations with optional scope.
- Modified types to include support for multiple npm registries and their statuses.
- Enhanced the npm auth service to manage multiple tokens and registry configurations.
- Updated controller methods to accommodate new parameters for saving and deleting npm auth configurations.
- Improved tests to cover new functionality for multiple registries and scoped tokens.
…g provider fallback

- Introduced `rate_limit_retry_delay_ms` to operational settings for dynamic configuration.
- Updated dashboard settings to allow administrators to configure rate limit retry delay.
- Enhanced rate limiter to use fixed retry delay instead of staggered delay based on queue position.
- Implemented cascading provider fallback mechanism in the unified consumer to handle rate-limited providers.
- Added utility function for exponential backoff calculation.
- Updated tests to cover new functionality and ensure proper behavior of rate limiting and fallback logic.
- Implemented API endpoints for retrieving and resetting provider rate limits.
- Added types and schemas for provider rate limit configurations and statuses.
- Enhanced rate limiter logic to support batch querying and telemetry for multiple providers.
- Updated Redis key management to include new rate limit metrics.
- Added unit tests for the new endpoints and rate limiter functionalities.
…prove environment variable handling

- Bump version to 1.0.13 in package.json
- Enhance README with updated CLI commands and version compatibility details
- Add tests for version comparison and environment variable loading
- Refactor env-config to differentiate between legacy and modern SimpleNS versions
- Update docker-compose templates to support new versioning scheme
- Modify onboarding process to allow skipping plugin configuration for SimpleNS > 1.3.0
- Improve security notices for auto-generated credentials based on version
- Introduced `api_key_id` field in notification schema for tracking.
- Enhanced Redis subscriber service with error handling and reconnection logic.
- Added API key schemas and types for creation, response, and usage tracking.
- Implemented integration tests for API key management, including CRUD operations and usage tracking.
- Updated admin authentication routes to use new API key logic.
- Refactored auth middleware to support dynamic API keys and admin JWT authentication.
- Added unit tests for JWT utilities and API key usage update functions.
- Updated notification controller tests to accommodate new API key features.
- Enhanced settings API tests to use admin JWT for authorization.
- Updated MCP server tests to reflect changes in tool registration.
Adhish-Krishna and others added 12 commits September 25, 2026 17:02
- Created health check routes: /api/health, /api/healthz (liveness), and /api/readyz (readiness).
- Implemented health check logic in health.controller.js to assess MongoDB and Redis connectivity.
- Integrated health probe server for Kubernetes with readiness and liveness checks.
- Enhanced delayed and status consumers with health check capabilities, including crash detection and heartbeat monitoring.
- Added unit tests for health endpoints and consumer health checks to ensure reliability.
… retention

feat(api-keys): introduce apiKeyType for notification and admin keys

fix(docker): remove insecure default JWT_SECRET in docker-compose files

feat(plugins): enhance plugin management with version change and uninstall validation

fix(auth): restrict notification API keys from accessing management routes

feat(jwt): implement JWT_SECRET validation for security during server startup

feat(api-key): update API key model to include type and enforce validation

test(api-keys): add tests for API key management access based on key type

test(auth): enhance middleware tests for API key type restrictions

test(plugin-fs): add unit tests for npm package name and version validation
@Adhish-Krishna Adhish-Krishna changed the title made simplens k8s native feat: made simplens k8s native Oct 11, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c160f5e9c8

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

- simplens-infra
restart: unless-stopped
healthcheck:
test: [ "CMD", "node", "-e", "require('http').get('http://localhost:3000/api/health', (r) => process.exit(r.statusCode === 200 ? 0 : 1)).on('error', () => process.exit(1))" ]

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Include BASE_PATH in the Compose API health check

With the shipped .env.example default BASE_PATH=/dashboard, the API mounts health at /dashboard/api/health, but this health check (and the equivalent dev/master checks) still probes /api/health. The API container will therefore remain unhealthy, preventing the dependent worker, processor, recovery, and dashboard services from starting under the documented Compose setup.

Useful? React with 👍 / 👎.

environment:
NODE_ENV: production
PORT: ${DASHBOARD_PORT:-3002}
API_BASE_PATH_URL: http://api:{PORT:-3000}{BASE_PATH:-}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Set API_BASE_URL for the master dashboard

This production profile sets API_BASE_PATH_URL, but the dashboard middleware reads API_BASE_URL. Consequently, the master dashboard falls back to the env_file value (http://localhost:3000) or its built-in localhost default; inside the dashboard container that points to itself rather than the api service, so every proxied dashboard API request fails.

Useful? React with 👍 / 👎.

Comment on lines +70 to +74
await Promise.all([
system_config_model.findOneAndUpdate(
{ key: PUBLIC_KEY_CONFIG },
{ value: keyPair.publicKey },
{ upsert: true, new: true }

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Make credential key-pair initialization atomic

When two first-time provider operations or API instances call this concurrently, both can observe missing key documents and generate different pairs. The two independent upserts can interleave, leaving the public key from one generated pair and the private key from another; credentials encrypted with either public key then become undecryptable after a restart. Persist the pair atomically or serialize/bootstrap it with a lock.

Useful? React with 👍 / 👎.

Comment thread src/plugins/bootstrap/yaml-migrator.ts Outdated
Comment on lines +121 to +125
// Find channel from installed plugin manifest
const pluginDoc = await Plugin.findOne({ name: entry.package });
const channel = pluginDoc?.manifest?.channel || 'generic';

await Provider.findOneAndUpdate(

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Skip provider rows after a YAML plugin migration failure

If npm installation or manifest extraction fails above, migration only logs the failure, then this loop still creates an enabled provider using a generic channel and a plugin record that does not exist. Because future startups see a nonzero provider count, they skip YAML migration entirely, leaving that configured provider permanently unloadable unless an operator manually repairs or deletes it.

Useful? React with 👍 / 👎.

Comment on lines +289 to +292
PluginRegistry.setChannelConfig(routing.channel, {
default: remainingFallbacks[0] || '',
fallback: remainingFallbacks.slice(1),
});

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve the configured default when deleting a fallback

When deleting a provider that is only a fallback, the database update keeps routing.default_provider_id, but this registry update instead promotes the first remaining fallback (or clears the default). The originating process ignores its own sync event, so until a later reload it validates provider-unspecified requests against and routes through a different default than the persisted channel configuration.

Useful? React with 👍 / 👎.

Comment on lines +25 to +29
interface StoredRegistryEntry {
id: string;
scope?: string;
registry_url: string;
encrypted_token: encrypted_config;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Centralize npm authentication interfaces

Move these local npm-auth interface declarations (including StoredNpmAuthConfig and DecryptedRegistryEntry) into src/types/types.ts and import them here. The repository rule requires every interface and type inside src/ to have that single declaration location, so retaining these definitions splits the mandated type source of truth.

AGENTS.md reference: AGENTS.md:L24-L25

Useful? React with 👍 / 👎.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-11T07:11:25.627859Z c160f5e PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@Adhish-Krishna
Adhish-Krishna merged commit e97f351 into master Oct 20, 2026
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant