Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to create a secret for PostgreSQL in Kubernetes

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

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!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report