https://github.com/stenic/sql-operator
Manage SQL databases, users and grant using kubernetes manifests
https://github.com/stenic/sql-operator
hacktoberfest kubernetes mysql operator sql-operator
Last synced: 6 months ago
JSON representation
Manage SQL databases, users and grant using kubernetes manifests
- Host: GitHub
- URL: https://github.com/stenic/sql-operator
- Owner: stenic
- License: other
- Created: 2021-10-22T07:02:44.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2025-12-18T02:50:10.000Z (7 months ago)
- Last Synced: 2025-12-19T06:57:51.921Z (7 months ago)
- Topics: hacktoberfest, kubernetes, mysql, operator, sql-operator
- Language: Go
- Homepage: https://stenic.github.io/sql-operator/
- Size: 1.38 MB
- Stars: 6
- Watchers: 0
- Forks: 3
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# SqlOperator
[](https://github.com/stenic/sql-operator/actions/workflows/release.yaml)
[](https://artifacthub.io/packages/search?repo=sql-operator)
[](https://app.fossa.com/projects/git%2Bgithub.com%2Fstenic%2Fsql-operator?ref=badge_shield)
Operate sql databases, users and grants.
> This is a WIP project and should not at all be used in production at this time.
> Feel free to validate in CI pipelines.
## Engines
Currenty, only MySQL is supported.
## Installation
```shell
kubectl create namespace sql-operator
helm repo add sql-operator https://stenic.github.io/sql-operator/
helm install sql-operator --namespace sql-operator sql-operator/sql-operator
```
## Objects
### SqlHost
The `SqlHost` object contains information how the operator should connect to the remote server.
Note that this information should be protected using rbac.
### SqlDatabase
The `SqlDatabase` object manages a database on the referenced `SqlHost`.
### SqlUser
The `SqlUser` object manages a user on the referenced `SqlHost`.
### SqlGrant
The `SqlGrant` object manages the grant for the referenced `SqlUser` on the referenced `SqlDatabase`.
## Example
The following example registeres a `SqlHost` pointing to a shared integration host and creates a `database`,
`user` and `grants` to run integration tests for the application.
```yaml
---
# Register a host - Not created by the operator
apiVersion: stenic.io/v1alpha1
kind: SqlHost
metadata:
name: integration
spec:
engine: Mysql
dsn: sqloperator:xxxxxxxxxxx@tcp(192.168.1.123:3306)/
---
# Create a database on the host
apiVersion: stenic.io/v1alpha1
kind: SqlDatabase
metadata:
name: application-int-db
spec:
databaseName: myapp_testing
hostRef:
name: integration
cleanupPolicy: Delete
---
# Create a user on the host
apiVersion: stenic.io/v1alpha1
kind: SqlUser
metadata:
name: application-int-user
spec:
credentials:
username: myapp_username
password: myapp_password
hostRef:
name: integration
cleanupPolicy: Delete
---
# Add some grant to the user
apiVersion: stenic.io/v1alpha1
kind: SqlGrant
metadata:
name: application-int-grant
spec:
userRef:
name: application-int-user
databaseRef:
name: application-int-db
grants:
- INSERT
- SELECT
- UPDATE
- DELETE
cleanupPolicy: Delete
```
## License
[](https://app.fossa.com/projects/git%2Bgithub.com%2Fstenic%2Fsql-operator?ref=badge_large)