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,260 points
2,681 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,460 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,497 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,350 points
1,033 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
15,574 views
0 votes
1 answer

permissions related to AWS ECR

if you add allowContainerRegistry: true, kops will add those permissions ...READ MORE

answered Oct 9, 2018 in Kubernetes by Kalgi
• 52,350 points
1,430 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,460 points
4,777 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,460 points
869 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