You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When setting up a database cluster, it is often necessary to initialize the databases, database users, and even the database schema. To achieve this, an OpsRequest defining the scripts to be executed during database initialization is required.
Here is an example,
apiVersion: apps.kubeblocks.io/v1alpha1
kind: OpsRequest
metadata:
name: myops
namespace: default
spec:
# cluster name
clusterRef: pg-cluster
type: DataScript
# After a period of time, the ops is automatically deleted
ttlSecondsAfterSucceed: 600
# Waiting for cluster is ready and exit when times out
ttlsecondsBeforeAbort: 3600
scriptSpec:
componentName: postgres
script: |
CREATE USER u1 IDENTIFIED BY "pwd";
CREATE DATABASE test;
USE test;
CREATE TABLE IF NOT EXISTS model (
id BIGSERIAL PRIMARY KEY,
user_id VARCHAR(50) NOT NULL,
q TEXT NOT NULL,
);
CREATE INDEX IF NOT EXISTS model_userId_index ON model USING HASH (user_id);
The user can also specify a secret from an sql script file created by kubectl create secret generic my-secret --from-file=path/init.sql command. This can hide sensitive information such as passwords. Here is an example,
It is more than init, we shall support create database, index, and users when cluster is ready (status is running), through a more generic way. Such as wrap these scripts through OpsRequest.
create configmap from file: mysql/createdb.txt, pg/createdb.txt
using command `kubectl create cm --from-file
create secret from file: mysql/createdb.txt, pg/createdb.txt
using command kubectl create secret generic <name> --from-file <filename>
create a cluster for mysql
create ops for mysql using command kubectl apply -f mysql/mysqlops.yaml
create a cluster for pg
create ops for pg using command kubectl apply -f pg/pgops.yaml
We introduce a new API ttlSecondsBeforeAbort, so an ops can be created when cluster is still creating and this ops will wait till timeout for cluster to become running.
When setting up a database cluster, it is often necessary to initialize the databases, database users, and even the database schema. To achieve this, an OpsRequest defining the scripts to be executed during database initialization is required.
Here is an example,
The user can also specify a secret from an sql script file created by
kubectl create secret generic my-secret --from-file=path/init.sql
command. This can hide sensitive information such as passwords. Here is an example,The text was updated successfully, but these errors were encountered: