Skip to Content
Lynq

LynqHub API Reference

LynqHub CRD API reference — spec.source MySQL connection, syncInterval, valueMappings, status fields, and multi-template support.

Kind: LynqHub
API Version: operator.lynq.sh/v1
Group: operator.lynq.sh

LynqHub connects to a database, queries active rows on a configurable interval, and creates/deletes LynqNode CRs to match the active set. One hub can be referenced by multiple LynqForms.

→ Datasource configuration guide · API index

Spec

apiVersion: operator.lynq.sh/v1
kind: LynqHub
metadata:
  name: my-hub
  namespace: lynq-system
spec:
  source:
    type: mysql                      # mysql (postgresql planned for v1.2)
    mysql:
      host: string                   # MySQL hostname or IP (required)
      port: 3306                     # MySQL port (default: 3306)
      username: string               # Database username (required)
      passwordRef:
        name: string                 # Kubernetes Secret name (optional; omit for passwordless)
        key: string                  # Secret key containing password
      database: string               # Database name (required)
      table: string                  # Table or view name (required)
    syncInterval: "1m"               # Poll frequency, e.g. 30s, 1m, 5m (required)

  valueMappings:
    uid: string                      # Column mapping for unique node ID (required)
    activate: string                 # Column mapping for activation flag (required)
    # hostOrUrl: string              # DEPRECATED since v1.1.11, removed in v1.3.0

  extraValueMappings:                # Optional additional column → variable mappings
    planId: subscription_plan        # Available as {{ .planId }} in templates
    region: deployment_region        # Available as {{ .region }} in templates

spec.source.mysql fields

FieldTypeRequiredDescription
hoststring✓MySQL hostname or IP address
portintegerMySQL port (default: 3306)
usernamestring✓Database username
passwordRef.namestringKubernetes Secret name (omit for passwordless connections)
passwordRef.keystringKey within the Secret
databasestring✓Database name
tablestring✓Table or view to query

spec.source.syncInterval

Duration string format: <number><unit> where unit is s, m, or h. Defaults to 30s when omitted.

ValueMeaning
30sEvery 30 seconds (default)
1mEvery minute (recommended for production)
5mEvery 5 minutes (for large deployments)

spec.valueMappings

Maps database column names to the two required template variables.

KeyRequiredPurpose
uid✓Maps a column to .uid — unique node identifier, used in resource naming
activate✓Maps a column to .activate — truthy/falsy activation flag
hostOrUrlDeprecatedRemoved in v1.3.0. Use extraValueMappings + toHost() instead

Accepted truthy values for activate: 1, true, TRUE, True, yes, YES, Yes. All other values (including NULL) are treated as inactive.

spec.extraValueMappings

Optional map of templateVariable: databaseColumn. Each entry makes a new variable available in all templates for this hub's LynqNodes.

extraValueMappings:
  planId: subscription_plan   # → {{ .planId }}
  region: aws_region          # → {{ .region }}
  nodeUrl: node_url           # → {{ .nodeUrl | toHost }} for hostname extraction

Status

status:
  observedGeneration: int64
  referencingTemplates: int32        # Number of LynqForms referencing this hub
  desired: int32                     # referencingTemplates × activeRows
  ready: int32                       # LynqNodes with Ready=True
  failed: int32                      # LynqNodes with reconciliation failures
  conditions:
  - type: Ready
    status: "True" | "False" | "Unknown"
    reason: string
    message: string
    lastTransitionTime: timestamp

status.desired calculation

desired = referencingTemplates × activeRows

A hub with 3 active rows and 2 referencing LynqForms has desired: 6.

Ready condition reasons

ReasonStatusMeaning
SyncSucceededTrueLast sync completed successfully
DatabaseConnectionFailedFalseCannot reach the database
QueryFailedFalseConnection succeeded but query failed
SyncInProgressUnknownSync is running

Validation

The admission webhook enforces:

  • spec.valueMappings must include uid and activate
  • spec.source.syncInterval must match ^\d+(s|m|h)$
  • spec.source.mysql.host is required when type: mysql

Example

apiVersion: operator.lynq.sh/v1
kind: LynqHub
metadata:
  name: production-nodes
  namespace: lynq-system
spec:
  source:
    type: mysql
    mysql:
      host: mysql.default.svc.cluster.local
      port: 3306
      username: node_reader
      passwordRef:
        name: mysql-credentials
        key: password
      database: saas_db
      table: node_configs
    syncInterval: 1m
  valueMappings:
    uid: node_id
    activate: is_active
  extraValueMappings:
    planId: subscription_plan
    region: deployment_region

All Fields

Every field the CRD accepts, read from the installed schema. The sections above explain the ones that need it.

Spec

FieldTypeDescription
spec.extraValueMappingsmap[string]stringExtraValueMappings defines additional custom column to variable mappings Keys become template variables, values are column names
spec.sourcerequiredobjectSource defines the external data source configuration
spec.source.mysqlobjectMySQL contains MySQL-specific configuration
spec.source.mysql.databaserequiredstringDatabase is the MySQL database name
spec.source.mysql.hostrequiredstringHost is the MySQL server hostname or IP
spec.source.mysql.passwordRefobjectPasswordRef references a Secret containing the MySQL password
spec.source.mysql.passwordRef.keyrequiredstringKey is the key within the Secret
spec.source.mysql.passwordRef.namerequiredstringName is the name of the Secret
spec.source.mysql.portrequiredinteger (int32)Port is the MySQL server port Default 3306.
spec.source.mysql.tablerequiredstringTable is the MySQL table name containing node data
spec.source.mysql.usernamerequiredstringUsername is the MySQL username
spec.source.syncIntervalrequiredstringSyncInterval is how often to sync from the data source Default "30s".
spec.source.typerequiredstringType is the type of data source One of mysql.
spec.valueMappingsrequiredobjectValueMappings defines required column to variable mappings
spec.valueMappings.activaterequiredstringActivate is the column name for the activation status
spec.valueMappings.hostOrUrlstringHostOrURL is the column name for the node host or URL Deprecated: Use extraValueMappings with the toHost() function instead This field will be removed in v1.3.0
spec.valueMappings.uidrequiredstringUID is the column name for the node unique identifier

Generated from config/crd/bases/operator.lynq.sh_lynqhubs.yaml

Status

FieldTypeDescription
status.conditionsobject[]Conditions represent the latest available observations of the hub's state
status.conditions[].lastTransitionTimerequiredstring (date-time)lastTransitionTime is the last time the condition transitioned from one status to another. This should be when the underlying condition changed. If that is not known, then using the time when the API field changed is acceptable.
status.conditions[].messagerequiredstringmessage is a human readable message indicating details about the transition. This may be an empty string.
status.conditions[].observedGenerationinteger (int64)observedGeneration represents the .metadata.generation that the condition was set based upon. For instance, if .metadata.generation is currently 12, but the .status.conditions[x].observedGeneration is 9, the condition is out of date with respect to the current state of the instance.
status.conditions[].reasonrequiredstringreason contains a programmatic identifier indicating the reason for the condition's last transition. Producers of specific condition types may define expected values and meanings for this field, and whether the values are considered a guaranteed API. The value should be a CamelCase string. This field may not be empty.
status.conditions[].statusrequiredstringstatus of the condition, one of True, False, Unknown. One of True, False, Unknown.
status.conditions[].typerequiredstringtype of condition in CamelCase or in foo.example.com/CamelCase.
status.desiredinteger (int32)Desired is the total number of LynqNode CRs that should exist Calculated as: ReferencingTemplates * ActiveRows
status.failedinteger (int32)Failed is the number of failed LynqNode resources
status.observedGenerationinteger (int64)ObservedGeneration is the generation observed by the controller
status.readyinteger (int32)Ready is the number of ready LynqNode resources
status.referencingTemplatesinteger (int32)ReferencingTemplates is the number of LynqForms referencing this hub

Generated from config/crd/bases/operator.lynq.sh_lynqhubs.yaml

See Also

On this page