Creating a user for an external PostgreSQL database
For Kaspersky Container Security, you can use PostgreSQL databases included in the solution or your own PostgreSQL databases. To install an external PostgreSQL database that does not work with the Kaspersky Container Security schema, you must create a separate user. You can do this by installing the Helm Chart package with the schema parameters specified for the external PostgreSQL database.
To create a user with a custom schema for an external PostgreSQL database:
- Run the following command to create a separate namespace for the external PostgreSQL database:
kubectl create ns kcspg
where
kcspg
is the namespace for the external PostgreSQL database. - To deploy an external PostgreSQL database:
- Specify the parameters for deploying the external PostgreSQL database in the pg.yaml configuration file.
The parameters specify the password of the database. You must then specify this password in the
infraconfig
section of the values.yaml configuration file, which is part of the Helm Chart package included in the distribution kit of the solution. - Run the following command:
kubectl apply -f pg.yaml -n kcspg
The name of this external database is formed as follows:
<
pod_name
>.<
namespace name
>.<
service
>.cluster.local
For example,
postgres.kcspg.svc.cluster.local
- Specify the parameters for deploying the external PostgreSQL database in the pg.yaml configuration file.
- To deploy a Service object in a cluster:
- Specify the Service object deployment parameters in the svc.yaml configuration file.
- Run the following command:
kubectl apply -f svc.yaml -n kcspg
- To create a user, a schema, and a user-schema relation:
- Using the postgres element expanded at step 2b, log in to the pod.
- Start the psql interactive terminal:
psql -h localhost -U postgres -d api
- Run the following commands:
CREATE ROLE kks LOGIN PASSWORD 'kks' NOINHERIT CREATEDB;
CREATE SCHEMA kks AUTHORIZATION kks;
GRANT USAGE ON SCHEMA kks TO PUBLIC;
- In the values.yaml configuration file, specify the necessary parameters to use an external PostgreSQL database.
The values of the parameters specified in values.yaml must match the values of corresponding parameters in the pg.yaml and svc.yaml configuration files.
- Start a solution update.