Skip to content
Open
21 changes: 21 additions & 0 deletions docs/examples/perconaxtradb/script-pxc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
apiVersion: kubedb.com/v1
kind: PerconaXtraDB
metadata:
name: script-pxc
namespace: demo
spec:
version: "8.4.3"
replicas: 3
storageType: Durable
storage:
storageClassName: "standard"
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 1Gi
init:
script:
configMap:
name: pxc-init-script
deletionPolicy: WipeOut
22 changes: 22 additions & 0 deletions docs/examples/pgbouncer/initialization/init_script.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
apiVersion: kubedb.com/v1
kind: PgBouncer
metadata:
name: script-pgbouncer
namespace: demo
spec:
version: "1.24.0"
replicas: 1
database:
syncUsers: true
databaseName: "postgres"
databaseRef:
name: "quick-postgres"
namespace: demo
connectionPool:
maxClientConnections: 20
reservePoolSize: 5
init:
script:
configMap:
name: pb-init-script
deletionPolicy: WipeOut
6 changes: 3 additions & 3 deletions docs/guides/clickhouse/initialization/script_source.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ Let's create a ConfigMap with the initialization script:

```bash
$ kubectl create configmap -n demo ch-init-script \
--from-literal=init.sql="$(curl -fsSL https://raw.githubusercontent.com/Bonusree/init_script/main/clickhouse_init.sql)"
--from-literal=init.sql="$(curl -fsSL https://raw.githubusercontent.com/kubedb/clickhouse-init-script/refs/heads/master/clickhouse_init.sql)"
configmap/ch-init-script created
```

> **Note:** The initialization script above is provided only as an example. You can use your own initialization script as long as it performs the required setup for your environment. If your script connects to ClickHouse, make sure to include the appropriate ClickHouse credentials (such as the password) so the script can authenticate successfully. After deploying ClickHouse with this ConfigMap, the initialization script runs automatically, and any databases, users, tables, or other objects created by the script can be verified after the deployment completes.
## Create ClickHouse with Script Source

Following YAML describes the ClickHouse object with `init.script`:
Expand Down Expand Up @@ -214,7 +214,7 @@ Now let's connect to our ClickHouse instance to verify that the database has bee
**Connection Information:**

- Host name/address: you can use any of these
- Service: `script-clickhouse.demo`
- Service: `script-clickhouse`
Comment thread
Bonusree marked this conversation as resolved.
- Pod IP: (`$ kubectl get pods script-clickhouse-0 -n demo -o yaml | grep podIP`)
- Port: `9000` (native TCP) or `8123` (HTTP)

Expand Down
22 changes: 18 additions & 4 deletions docs/guides/percona-xtradb/initialization/script_source.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ $ kubectl create configmap -n demo pxc-init-script \
--from-literal=init.sql="$(curl -fsSL https://raw.githubusercontent.com/kubedb/percona-xtradb-init-scripts/master/init.sql)"
configmap/pxc-init-script created
```

>**Note:** The initialization script above is provided only as an example. You can use your own initialization script as long as it performs the required setup for your environment. If your script connects to Percona XtraDB, make sure to include the appropriate MySQL credentials (such as the password) so the script can authenticate successfully. After deploying Percona XtraDB with this ConfigMap, the initialization script runs automatically, and any databases, users, tables, or other objects created by the script can be verified after the deployment completes.
## Create PerconaXtraDB with Script Source

Following YAML describes the PerconaXtraDB object with `init.script`:
Expand Down Expand Up @@ -88,7 +88,7 @@ VolumeSource provided in `init.script` will be mounted in the Pod and will be ex
Now, let's create the PerconaXtraDB CRD using the YAML shown above:

```bash
$ kubectl create -f https://github.com/kubedb/docs/raw/{{< param "info.version" >}}/docs/guides/percona-xtradb/initialization/yamls/script-pxc.yaml
$ kubectl create -f https://github.com/kubedb/docs/raw/{{< param "info.version" >}}/docs/examples/perconaxtradb/script-pxc.yaml
perconaxtradb.kubedb.com/script-pxc created
```

Expand Down Expand Up @@ -269,7 +269,7 @@ Now let's connect to our PerconaXtraDB cluster to verify that the database has b
**Connection Information:**

- Host name/address: you can use any of these
- Service: `script-pxc.demo`
- Service: `script-pxc`
- Pod IP: (`$ kubectl get pods script-pxc-0 -n demo -o yaml | grep podIP`)
- Port: `3306`

Expand All @@ -284,7 +284,7 @@ Now let's connect to our PerconaXtraDB cluster to verify that the database has b

```bash
$ kubectl get secret -n demo script-pxc-auth -o jsonpath='{.data.password}' | base64 -d
nsTqGdVwR!~DA(t
nsTqGdVwR!~DA(ta
```

Now, connect to the PerconaXtraDB cluster and run the following query to confirm initialization:
Expand Down Expand Up @@ -340,6 +340,20 @@ mysql: [Warning] Using a password on the command line interface can be insecure.
| wsrep_streaming_log |
+------------------------------------------------------+


$ kubectl exec -it -n demo script-pxc-0 -- \
mysql -u root --password='nsTqGdVwR!~DA(ta' \
-e "SELECT * FROM mysql.kubedb_table;"
Defaulted container "perconaxtradb" out of: perconaxtradb, px-coordinator, px-init (init)
mysql: [Warning] Using a password on the command line interface can be insecure.
+----+-------+
| id | name |
+----+-------+
| 1 | name1 |
| 2 | name2 |
| 3 | name3 |
+----+-------+

Comment thread
Bonusree marked this conversation as resolved.
```

We can see the TABLE `kubedb_table` in `mysql` database which was created through initialization.
Expand Down
1 change: 0 additions & 1 deletion docs/guides/pgbouncer/initialization/script_source.md
Original file line number Diff line number Diff line change
Expand Up @@ -165,5 +165,4 @@ $ kubectl delete ns demo

## Next Steps

- Learn about [backup and restore](/docs/guides/pgbouncer/backup/overview/index.md) PgBouncer using Stash.
- Want to hack on KubeDB? Check our [contribution guidelines](/docs/CONTRIBUTING.md).
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
apiVersion: ops.kubedb.com/v1alpha1
kind: ProxySQLOpsRequest
metadata:
name: add-user
namespace: demo
spec:
type: Reconfigure
proxyRef:
name: proxy-init-inline
configuration:
mysqlUsers:
users:
- username: wolverine
active: 1
default_hostgroup: 2
- username: superman
active: 1
default_hostgroup: 2
reqType: add
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,6 @@ spec:
configuration:
init:
inline:
mysqlUsers:
- username: wolverine
active: 1
default_hostgroup: 2
default_schema: marvel
- username: superman
active: 1
default_hostgroup: 3
mysqlQueryRules:
- rule_id: 1
active: 1
Expand Down
Loading
Loading