How to create a secret for PostgreSQL in Kubernetes
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!