What command is used to create a secret in Kubernetes?

Prepare for the KCNA Certification Test. Study with flashcards, multiple-choice questions, and detailed explanations to enhance your understanding of Kubernetes Cloud Native concepts. Ace your exam!

Multiple Choice

What command is used to create a secret in Kubernetes?

Explanation:
Creating a secret uses the create secret subcommand, which is designed specifically for generating Secret resources in Kubernetes. You can choose the secret type (such as generic, docker-registry, or tls) and supply the data with --from-literal for key-value pairs or --from-file for file contents. For example, kubectl create secret generic my-secret --from-literal=username=admin --from-literal=password=secret123 creates a generic secret with those two keys. You can also create from a file, like kubectl create secret generic my-secret --from-file=ssh-privatekey=path/to/key. Other kubectl commands handle different actions: apply is used to apply a manifest that may create or update resources, edit opens an editor to modify an existing secret, and delete removes a secret. Therefore, the command used to create a secret is kubectl create secret.

Creating a secret uses the create secret subcommand, which is designed specifically for generating Secret resources in Kubernetes. You can choose the secret type (such as generic, docker-registry, or tls) and supply the data with --from-literal for key-value pairs or --from-file for file contents. For example, kubectl create secret generic my-secret --from-literal=username=admin --from-literal=password=secret123 creates a generic secret with those two keys. You can also create from a file, like kubectl create secret generic my-secret --from-file=ssh-privatekey=path/to/key. Other kubectl commands handle different actions: apply is used to apply a manifest that may create or update resources, edit opens an editor to modify an existing secret, and delete removes a secret. Therefore, the command used to create a secret is kubectl create secret.

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy