lynq

module
v1.1.9-alpha.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 13, 2025 License: Apache-2.0

README ΒΆ

Kubernetes Lynq Operator

Lynq Operator

Kubernetes-Native Database-Driven Automation

Automate node lifecycle from database to production

Go Report Card License Artifact Hub Build Status Container Image Go Version

Overview β€’ Features β€’ Quick Start β€’ Documentation β€’ Contributing


πŸ“– Overview

Lynq Operator is a Kubernetes operator that automates database-driven infrastructure provisioning. It reads node data from external datasources (MySQL, PostgreSQL planned for v1.2) and dynamically creates, updates, and manages Kubernetes resources using declarative templates.

One database row = One fully provisioned node stack

Why Lynq Operator?

Traditional provisioning approaches are limited:

  • ❌ Helm: Manual per-node releases and values files
  • ❌ GitOps: Static manifests don't scale to thousands of nodes
  • ❌ Custom scripts: Fragile, hard to maintain, no drift correction

Lynq Operator provides:

  • βœ… Database-driven automation: Your existing database becomes the source of truth
  • βœ… Real-time sync: Changes propagate automatically (30s status reflection)
  • βœ… Production-grade: SSA, webhooks, finalizers, metrics, and drift detection built-in

πŸ“š Complete Documentation β€’ πŸ—οΈ Architecture Details


✨ Key Features

Feature Description
πŸ—„οΈ Database-Driven MySQL support (PostgreSQL in v1.2)
πŸ“ Template Engine Go templates + 200+ Sprig functions
πŸ”„ Server-Side Apply Conflict-free resource management
πŸ“Š Dependencies DAG-based resource ordering
βš™οΈ Policies Fine-grained lifecycle control
πŸš€ Production-Ready Webhooks, metrics, drift detection

Advanced capabilities: Multi-template support, cross-namespace provisioning, orphan cleanup, smart watch predicates, custom template functions (sha1sum, fromJson, toHost), and more.

πŸ“– Full feature list: Documentation

Integrations
  • ExternalDNS - Automatic DNS records (Route53, Cloudflare, etc.)
  • Terraform Operator - Cloud resource provisioning (S3, RDS, CDN)
  • cert-manager - Automatic TLS certificates
  • Prometheus/Grafana - Complete monitoring with dashboards

πŸ—οΈ Architecture

Lynq Operator uses a three-controller design for database-to-Kubernetes synchronization:

  1. LynqHub Controller - Syncs database β†’ Creates LynqNode CRs
  2. LynqForm Controller - Validates templates and linkage
  3. LynqNode Controller - Renders templates β†’ Applies resources via SSA

Multi-template support: One registry can be referenced by multiple templates (prod, staging, etc.). Desired count = referencingTemplates Γ— activeRows.

πŸ“Š Detailed architecture diagrams: Architecture Guide

Supported Kubernetes Versions

Version Status
v1.28 - v1.33 βœ… Validated
Other GA releases ⚠️ Expected

The operator targets GA/stable Kubernetes APIs and is decoupled from specific cluster releases. Validate in staging before production rollout.


πŸš€ Quick Start

Get started in 5 minutes with a working example:

🎯 Quick Start Guide with Minikube - Automated setup scripts included

# 1. Install cert-manager (required for webhooks)
kubectl apply -f https://github.com/cert-manager/cert-manager/releases/download/v1.13.0/cert-manager.yaml

# 2. Install Lynq Operator
helm repo add lynq-operator https://k8s-lynq.github.io/lynq
helm repo update

helm install lynq k8s-lynq/lynq \
  --namespace lynq-system \
  --create-namespace

πŸ“– More installation options: Installation Guide

Configuration Example

1. Connect to your database (LynqHub):

apiVersion: operator.lynq.sh/v1
kind: LynqHub
metadata:
  name: my-saas-hub
spec:
  source:
    type: mysql
    mysql:
      host: mysql.database.svc.cluster.local
      database: nodes
      table: node_configs
      passwordRef:
        name: mysql-secret
        key: password
    syncInterval: 1m
  valueMappings:
    uid: node_id
    hostOrUrl: node_url
    activate: is_active  # Must be "1", "true", or "yes"

πŸ“– Database setup guide: DataSource Configuration

2. Define resource template (LynqForm):

apiVersion: operator.lynq.sh/v1
kind: LynqForm
metadata:
  name: saas-app-template
spec:
  hubId: my-saas-hub
  deployments:
    - id: app
      nameTemplate: "{{ .uid }}-app"
      spec:
        apiVersion: apps/v1
        kind: Deployment
        spec:
          replicas: 2
          template:
            spec:
              containers:
              - name: app
                image: myapp:latest
                env:
                - name: NODE_ID
                  value: "{{ .uid }}"

πŸ“– Template syntax and functions: Template Guide

3. Verify:

kubectl get lynqnodes --watch
kubectl get lynqnode <lynqnode-name> -o yaml

Result: Each active database row automatically provisions a complete node stack!


πŸ“š Documentation

Complete documentation is available at lynq.sh

Category Pages
Getting Started Quick Start β€’ Installation
Core Concepts Architecture β€’ API Reference β€’ Templates β€’ Policies β€’ Dependencies
Operations DataSource Setup β€’ Monitoring β€’ Alert Runbooks β€’ Troubleshooting β€’ Performance
Integrations ExternalDNS β€’ Terraform Operator β€’ Argo CD
Advanced Security β€’ Development β€’ Contributing
Examples

Simple SaaS Application:

INSERT INTO nodes VALUES ('acme-corp', 'https://acme.myapp.io', 1, 'enterprise');

β†’ Automatically creates Deployment, Service, Ingress, ConfigMaps, and Secrets

Multi-region with custom variables:

extraValueMappings:
  region: deployment_region
  dbHost: database_host

Template functions:

nameTemplate: "{{ .uid | sha1sum | trunc63 }}"  # Unique names
value: "{{ (.config | fromJson).apiKey }}"      # Parse JSON
value: "{{ .nodeUrl | toHost }}"                # Extract host

πŸ“– More examples: Quick Start Guide


πŸ› οΈ Development

Building from Source
# Clone repository
git clone https://github.com/k8s-lynq/lynq.git
cd lynq

# Install dependencies
go mod download

# Run tests
make test

# Build binary
make build

# Build and push container
make docker-build docker-push IMG=<your-registry>/lynq:tag
Running Locally
# Install CRDs
make install

# Run controller locally (uses ~/.kube/config)
make run

# Run with debug logging
LOG_LEVEL=debug make run
Running Tests
# Unit tests
make test

# Integration tests
make test-integration

# E2E tests (requires kind)
make test-e2e

# Coverage report
make test-coverage

🀝 Contributing

We welcome contributions from anyone interested in database-driven Kubernetes automation.

Our vision: We're building this project with open governance and community-first principles. As the project grows, we aspire to join cloud-native foundations like CNCF to foster broader collaboration and adoption.

Ways to contribute:

  • πŸ› Bug reports and feature requests
  • πŸ“ Documentation improvements
  • πŸ’» Code contributions (features, bug fixes, optimizations)
  • 🌍 Translations and internationalization
  • 🎨 UX/UI improvements for tooling
  • πŸ“Š Use case sharing and feedback
🌟 Want to Add a New Datasource?

Lynq Operator uses a pluggable adapter pattern that makes it easy to add support for new datasources (PostgreSQL, MongoDB, REST APIs, etc.).

Why contribute a datasource?

  • βœ… Only 2 methods to implement
  • βœ… MySQL reference implementation to follow
  • βœ… Complete step-by-step guide provided
  • βœ… Recognition in release notes

πŸ“š Full Guide: Contributing a New Datasource

How to Contribute
  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'feat: add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request
Contribution Guidelines
  • Follow Conventional Commits
  • Add tests for new features
  • Update documentation
  • Run make lint before submitting
  • Ensure all CI checks pass

See CONTRIBUTING.md for detailed guidelines.


πŸ—ΊοΈ Roadmap

See full roadmap for details.


πŸ“Š Status

Component Status Description
Core Controllers βœ… Production LynqHub, LynqForm, and LynqNode controllers with SSA
MySQL Datasource βœ… Production Sync from MySQL with column mapping and VIEWs
Template Engine βœ… Production Go templates with 200+ Sprig functions + custom functions
Webhooks βœ… Production Validation and defaulting for all CRDs
Performance βœ… Production Event-driven reconciliation with smart watch predicates
Multi-Template βœ… Production One registry, multiple templates (prod, staging, etc.)
Cross-Namespace βœ… Production Provision resources across namespaces with label tracking
Orphan Cleanup βœ… Production Automatic detection and cleanup of removed resources
PostgreSQL 🚧 Planned PostgreSQL datasource adapter (v1.2)

Kubernetes: v1.28-v1.33 validated β€’ Status: Production-ready


❓ FAQ

How is this different from Helm or GitOps?

Lynq Operator is database-driven and designed for SaaS platforms where node data lives in databases, not git repositories. It automates provisioning from database rows with real-time sync, whereas Helm and GitOps require manual per-node configuration.

πŸ“– Architecture Guide

Can I use my existing database?

Yes! You just need read-only access and column mappings. If your schema doesn't match, create a MySQL VIEW to transform the data.

πŸ“– DataSource Configuration Guide

What values are valid for the `activate` column?

Must be exactly one of: "1", "true", "TRUE", "True", "yes", "YES", "Yes"

All other values (including "active", "0", empty, NULL) are considered inactive. Use a VIEW to transform your data if needed.

πŸ“– DataSource Guide - Activate Column

⚠️ What happens if I delete LynqHub or LynqForm?

Warning: Causes cascade deletion of all LynqNode CRs and their resources!

Protection: Set deletionPolicy: Retain on resources BEFORE deleting, or update in-place instead of delete/recreate.

πŸ“– Policies Guide - Protecting LynqNodes

How does it scale to thousands of nodes?

Production deployments handle 1000+ nodes with concurrent reconciliation, SSA efficiency, resource caching, and optional sharding.

πŸ“– Performance Guide

How fast does it react to changes?
  • Immediate: Event-driven drift correction
  • 30 seconds: Periodic status reflection
  • Configurable: Database sync interval (e.g., 1 minute)

πŸ“– Architecture - Reconciliation Flow

Can one registry support multiple environments?

Yes! One registry can be referenced by multiple templates (prod, staging, dev). Each database row creates multiple LynqNode CRs.

πŸ“– Configuration Guide - Multi-Template

How do I set up webhook certificates?

Install cert-manager first - it automatically manages TLS certificates for webhook communication. See installation guide for details.

πŸ“– Installation Guide


πŸ“ License

Copyright 2025 Lynq Operator Authors

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.


🌟 Acknowledgments

Built with:

Inspired by the cloud-native ecosystem and CNCF projects.


πŸ“¬ Contact & Community

We're looking for:

  • Users sharing their experiences and use cases
  • Contributors interested in database-driven Kubernetes
  • Organizations interested in collaboration

Star History

Star History Chart

Directories ΒΆ

Path Synopsis
api
v1
Package v1 contains API Schema definitions for the lynq v1 API group.
Package v1 contains API Schema definitions for the lynq v1 API group.
internal
test

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL