Get the App
SLTechnology News&Howtos  ›  Servers  › 

How to manage Confidential Information with K8s

Shulou Source: shulou.com Published: 2022-06-01 00:57:44 09月25日 Update

This article will explain in detail how to use K8s to manage confidential information. The content of the article is of high quality, so the editor will share it with you for reference. I hope you will have a certain understanding of the relevant knowledge after reading this article.

Some sensitive information may be required during the startup process of the application, such as the user name, password or secret key to access the database. It is obviously not appropriate to store this information directly in the container image, and the solution provided by Kubernetes is Secret.

Secret stores data in ciphertext, avoiding saving sensitive information directly in the configuration file. Secret is mount to Pod in the form of Volume, and the container can use the sensitive data in Secret through files; in addition, the container can also use this data as environment variables.

Secret can be created from the command line or YAML.

Create Secret

There are four ways to create a Secret:

1. Through-- from-literal:

Kubectl create secret generic mysecret-from-literal=username=admin-from-literal=password=123456

Each-- from-literal corresponds to an information entry.

two。 Through-- from-file:

Echo-n admin >. / usernameecho-n 123456 >. / passwordkubectl create secret generic mysecret-- from-file=./username-- from-file=./password

Each file content corresponds to an information entry.

3. Through-- from-env-file:

Cat env.txtusername=adminpassword=123456EOFkubectl create secret generic mysecret-from-env-file=env.txt

Each line of Key=Value in the file env.txt corresponds to an information entry.

4. Through the YAML configuration file:

The sensitive data in the file must be the result of being encoded by base64.

On how to use K8s to manage confidential information to share here, I hope the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.

Tags: Information files data content containers methods entries secrets management articles more knowledge articles accessible configured good inappropriate variables commands ciphertext Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MariaDB Docker Linux Shulou Tech Info vpn