-
Notifications
You must be signed in to change notification settings - Fork 10
Feature: add external database support #177
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Conversation
Add support for external MySQL/MariaDB databases with the following changes: - Add database.mode setting to switch between internal and external modes - Add database.external section with host, port, name, user, password, timeout - Support existingSecret for secure credential management - Add JSON schema validation for database configuration This allows users to use existing database instances instead of the bundled MySQL.
Add 7 new helper functions to abstract database configuration: - librenms.dbHost: Returns database hostname (strips port if included) - librenms.dbPort: Returns database port (extracts from host string if needed) - librenms.dbName: Returns database name - librenms.dbUser: Returns database username - librenms.dbTimeout: Returns connection timeout with default - librenms.dbPasswordEnv: Renders password from literal or secret - librenms.validateExternalDB: Validates required external DB parameters Helpers support both internal (bundled MySQL) and external database modes.
Replace hardcoded MySQL values with helper function calls: - DB_HOST: Now rendered without port for proper mariadb client usage - DB_PORT: Added as separate environment variable - DB_USERNAME: Uses dbUser helper - DB_DATABASE: Uses dbName helper This ensures database configuration is correctly injected regardless of internal or external database mode.
Update deployment, cron, and poller StatefulSet templates: - Use dbPasswordEnv helper for secure password injection - Fix poller readiness probe to use separate host/port parameters - Ensure all workloads properly reference configmap for DB settings These changes enable external database connectivity across all LibreNMS components while maintaining backward compatibility with internal mode.
Add extensive documentation to README template covering: - Internal vs external database mode selection - External database configuration examples - Flexible connection string formats (host:port or separate port) - Kubernetes secret integration for credentials - Database pre-requisites and requirements - Example kubectl commands for secret creation Documentation is clear and production-ready.
Regenerate README.md from updated template using helm-docs. Includes comprehensive external database configuration guide with examples, prerequisites, and best practices.
2ec2f32 to
f0c6d69
Compare
jacobw
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great PR! Couple of small comments.
| # -- Database configuration for LibreNMS | ||
| database: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you consider merging the existing mysql section so all database configuration was under on e section, possibly as external and internal?
| {{- if contains ":" $host -}} | ||
| {{- $host | splitList ":" | first -}} | ||
| {{- else -}} | ||
| {{- $host -}} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The values description didn't say you could define host:port. Was it your intention to support both formats? This sounds maybe unnecessary given you'd only really set this once.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh I see you adding this in the README, but not in the values.yaml comment.
Testing/Validation
I wrote some test scripts to validate both an internal DB and an external DB with this chart.
Testing script output: