Get the App
SLTechnology News&Howtos  ›  Servers  › 

How to create a secret for PostgreSQL in Kubernetes

Shulou Source: shulou.com Published: 2022-06-01 12:50:38 10月05日 Update

This article focuses on "how to create a secret for PostgreSQL in Kubernetes". Interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn how to create secret for PostgreSQL in Kubernetes.

Create an initdb.sql file and enter the following:

-- This is a postgres initialization script for the postgres container.

-- Will be executed during container initialization ($> psql postgres-f initdb.sql)

CREATE ROLE adsuser WITH LOGIN PASSWORD 'initial' INHERIT CREATEDB

CREATE DATABASE ads WITH ENCODING 'UNICODE' LC_COLLATE' C 'LC_CTYPE' C 'TEMPLATE template0

GRANT ALL PRIVILEGES ON DATABASE ads TO adsuser

CREATE SCHEMA ads AUTHORIZATION adsuser

-- ALTER DATABASE ads SET search_path TO 'ads'

ALTER DATABASE ads OWNER TO adsuser

Execute the following command to redirect the output to a yaml file called ads-db-secret.

Kubectl create secret generic ads-db-secret-- from-file initdb.sql-- dry-run-o yaml > ads-db-secret.yaml

The secret file is as follows:

Delete the automatically generated creationTimestamp, and then add postgres_password_value.

Finally, the secret is generated using kubectl app.

At this point, I believe you have a deeper understanding of "how to create secret for PostgreSQL in Kubernetes". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Tags: Content file learning generation practical deeper interest command practicality practical simple operation method more friends website automatic generation channel query input output Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Apple OPPO Reno Shulou Technology vpn Xiaomi