From the course: Certified Kubernetes Security Specialist (CKS) Cert Prep

Unlock this course with a free trial

Join today to access over 24,900 courses taught by industry experts.

Creating and using a secret

Creating and using a secret

- There are a few different ways to be able to configure secrets within Kubernetes, and we're going to show you an example of doing it via the imperative command. Now, the good thing about this particular command is it uses kubectl to be able to create the secret. You can then echo the user to a username text file. You can then echo a password into the password.txt, and then from here you've got two files that you're going to use to be able to construct your secret. And then from there you'll use kubectl create secret. In this case, we'll use generic, the secret name as well as the files that you're going to use as part of that. And then ultimately, this is also then going to do all the base64 encoding and the other components that are necessary to make a secret work within Kubernetes. The other method that we have to be able to create a secret is to use a declarative method. And from here we have to do a little bit of the encoding ourselves. So we're going to take the username, we're…

Contents