How to create secrets from a text file in Kubernetes

0 votes

Hi Guys,

I am new to Kubernetes. I want to create one secret in Kubernetes from a text file. How can I do that?

Jul 16, 2020 in Kubernetes by akhtar
• 38,230 points
2,152 views

1 answer to this question.

0 votes

Hi@akhtar,

Secrets can contain user credentials required by Pods to access a database. For example, a database connection string consists of a username and password. You can store the username in a file ./username.txt and the password in a file ./password.txt on your local machine.

$ echo -n 'nadeem' > ./username.txt
$ echo -n 'redhat' > ./password.txt

The kubectl create secret command packages these files into a Secret and creates the object on the API server.

$ kubectl create secret generic db-user-pass --from-file=./username.txt --from-file=./password.txt
answered Jul 16, 2020 by MD
• 95,440 points

Related Questions In Kubernetes

0 votes
1 answer

How to use gravitational teleport in a container/kubernetes environment?

You can use teleport to augment kubernetes ...READ MORE

answered Jun 28, 2018 in Kubernetes by ajs3033
• 7,300 points
2,226 views
0 votes
1 answer

Not able to access kubernetes api from a pod in azure

Follow these steps Add --bind-address=0.0.0.0 option to the line https://github.com/kubernetes/kubernetes/blob/v1.2.0/docs/getting-started-guides/coreos/azure/cloud_config_templates/kubernetes-cluster-main-nodes-template.yml#L218  Created ...READ MORE

answered Aug 30, 2018 in Kubernetes by Kalgi
• 52,360 points
813 views
0 votes
2 answers
+1 vote
1 answer
0 votes
3 answers

Error while joining cluster with node

Hi Kalgi after following above steps it ...READ MORE

answered Jan 17, 2019 in Others by anonymous
14,587 views
+4 votes
1 answer

Installing Web UI (Dashboard):kubernetes-dashboard on main Ubuntu 16.04.6 LTS (Xenial Xerus) server

Follow these steps: $ kubeadm reset $ kubeadm init ...READ MORE

answered Apr 12, 2019 in Kubernetes by Kalgi
• 52,360 points

reshown Apr 12, 2019 by Kalgi 6,069 views
0 votes
1 answer

How to copy file inside a Pod in Kubernetes?

Hi@akhtar, You need to use the kubectl cp command ...READ MORE

answered Jul 5, 2020 in Kubernetes by MD
• 95,440 points
4,437 views
0 votes
1 answer

How to create a ConfigMap from a file?

Hi@akhtar, You can pass in the --from-file argument multiple times ...READ MORE

answered Aug 31, 2020 in Kubernetes by MD
• 95,440 points
592 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP