Explain how a Kubernetes secret is created.

QuestionsQuestions8 SkillsProKubernetes Create CommandOct, 28 2025
083

To create a Kubernetes Secret, follow these steps:

  1. Create a YAML file: Define the Secret in a YAML file. For example, create a file named my-secret.yaml with the following content:

    apiVersion: v1
    kind: Secret
    metadata:
      name: my-secret
    type: Opaque
    data:
      password: dXNlcm5hbWU6cGFzc3dvcmQ=

    In this example:

    • The name of the Secret is my-secret.
    • The type is Opaque.
    • The data contains a key-value pair, where the key is password and the value is Base64-encoded.
  2. Apply the Secret: Use the kubectl apply command to create the Secret in your Kubernetes cluster:

    kubectl apply -f my-secret.yaml
  3. Verify the Secret: Check that the Secret was created successfully by running:

    kubectl get secrets

    You should see my-secret listed among the secrets.

This process allows you to securely manage sensitive information within your Kubernetes applications.

0 Comments

no data
Be the first to share your comment!