Access your SIP v2 database
First ensure that you can access the kubernetes cluster, see: How to access SIP v2 kubernetes cluster
Mariadb (mysql)
Find your database pod in your namespace. Typically the pod name should end in "0" since the mariadb operator creates the database pods as a statefulset. If you think you've found it, you can double-check by getting the image:
$ kubectl get pods -n vseth-staging
NAME READY STATUS RESTARTS AGE
vseth-wp-db-0 1/1 Running 0 19h
vseth-wp-db-metrics-7db6c48f64-q2wt2 1/1 Running 0 13d
vseth-wp-wp-5cb88bfc75-js9xc 2/2 Running 0 13d
# check the image
$ kubectl get pods -n vseth-staging vseth-wp-db-0 -o yaml | grep image:
image: mariadb:11.8.8
image: docker.io/library/mariadb:11.8.8
# check the environment variables that are relevant to MARIADB:
$ k exec -it -n vseth-staging vseth-wp-db-0 -- env | grep MARIADB
Here's how to connect to the db in the pod:
$ kubectl exec -it -n vseth-staging vseth-wp-db-0 -- bash # in the pod's shell: mysql@vseth-wp-db-0:/$ mariadb -u root -p$MARIADB_ROOT_PASSWORD Welcome to the MariaDB monitor. Commands end with ; or \g. Your MariaDB connection id is 24793 Server version: 11.8.8-MariaDB-ubu2404 mariadb.org binary distribution Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. MariaDB [(none)]> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | performance_schema | | sys | | vseth_wp_db | +--------------------+ 5 rows in set (0.003 sec) MariaDB [(none)]> quit Bye mysql@vseth-wp-db-0:/$ exit exit
Postgres
Find your database pod in your namespace. Typically the pod name should end in "1" since the postgres operator creates the database pods as a statefulset starting with 1. If you think you've found it, you can double-check by getting the image:
$ kubectl get pods -n api-prod
NAME READY STATUS RESTARTS AGE
ingress-status-pages-56d4d4bd98-snqt5 1/1 Running 0 20h
mail-api-app-5c4d4674df-b2g99 1/1 Running 0 13d
mail-api-db-1 1/1 Running 0 20h
# check the image:
$ kubectl get pods -n api-prod mail-api-db-1 -o yaml | grep image:
image: ghcr.io/cloudnative-pg/postgresql:18.4-standard-trixie@sha256:802cb43a4d482acf1037b418e421c865b16959ba22e07f16fc003e06cb21084c
image: ghcr.io/cloudnative-pg/cloudnative-pg:1.30.0
image: sha256:01d567e83eeb0a285e5441eb1cdc487c07018d29c3a2484c579dd20c25d346a5
image: ghcr.io/cloudnative-pg/cloudnative-pg:1.30.0
Here's how to connect to the database in the pod (just exec in the database pod and type psql ):
$ k exec -it -n api-prod mail-api-db-1 -- bash Defaulted container "postgres" out of: postgres, bootstrap-controller (init) postgres@mail-api-db-1:/$ psql psql (18.4 (Debian 18.4-1.pgdg13+1)) Type "help" for help. postgres=#
Some initial commands to get you started:
postgres@mail-api-db-1:/$ psql
psql (18.4 (Debian 18.4-1.pgdg13+1))
Type "help" for help.
## list the databases:
postgres=# \l
List of databases
Name | Owner | Encoding | Locale Provider | Collate | Ctype | Locale | ICU Rules | Access privileges
-----------+----------+----------+-----------------+---------+-------+--------+-----------+-----------------------
app | app | UTF8 | libc | C | C | | |
postgres | postgres | UTF8 | libc | C | C | | |
template0 | postgres | UTF8 | libc | C | C | | | =c/postgres +
| | | | | | | | postgres=CTc/postgres
template1 | postgres | UTF8 | libc | C | C | | | =c/postgres +
| | | | | | | | postgres=CTc/postgres
(4 rows)
## Connect to one of the databases:
postgres=# \c app
You are now connected to database "app" as user "postgres".
## List the tables of the database:
app=# \dt
List of tables
Schema | Name | Type | Owner
--------+------+-------+-------
public | mail | table | app
(1 row)
## describe the table:
app=# \d mail
Table "public.mail"
Column | Type | Collation | Nullable | Default
---------+-------------------+-----------+----------+----------------------------------
id | integer | | not null | nextval('mail_id_seq'::regclass)
to | character varying | | |
cc | character varying | | |
bcc | character varying | | |
replyTo | character varying | | |
subject | character varying | | |
header | character varying | | |
body | character varying | | |
mailID | character varying | | |
Indexes:
"mail_pkey" PRIMARY KEY, btree (id)
## quit
app=# \q