1
0
mirror of https://github.com/openshift/openshift-docs.git synced 2026-02-05 21:46:22 +01:00
Files
openshift-docs/modules/nodes-pods-secrets-creating-basic.adoc
2023-10-30 10:13:25 -04:00

51 lines
1.5 KiB
Plaintext

// Module included in the following assemblies:
//
// * nodes/nodes-pods-secrets.adoc
:_mod-docs-content-type: PROCEDURE
[id="nodes-pods-secrets-creating-basic_{context}"]
= Creating a basic authentication secret
As an administrator, you can create a basic authentication secret, which allows you to store the credentials needed for basic authentication. When using this secret type, the `data` parameter of the `Secret` object must contain the following keys encoded in the base64 format:
* `username`: the user name for authentication
* `password`: the password or token for authentication
[NOTE]
====
You can use the `stringData` parameter to use clear text content.
====
.Procedure
. Create a `Secret` object in a YAML file on a control plane node:
+
.Example `secret` object
[source,yaml]
----
apiVersion: v1
kind: Secret
metadata:
name: secret-basic-auth
type: kubernetes.io/basic-auth <1>
data:
stringData: <2>
username: admin
password: <password>
----
<1> Specifies a basic authentication secret.
<2> Specifies the basic authentication values to use.
. Use the following command to create the `Secret` object:
+
[source,terminal]
----
$ oc create -f <filename>.yaml
----
. To use the secret in a pod:
.. Update the pod's service account to reference the secret, as shown in the "Understanding how to create secrets" section.
.. Create the pod, which consumes the secret as an environment variable or as a file (using a `secret` volume), as shown in the "Understanding how to create secrets" section.