Search code examples
kuberneteskubernetes-security

Kubernetes Secrets - What is the purpose of type "Opaque" in secret definitions


In most examples about using secrets in Kubernetes, you can find similar examples:

apiVersion: v1
kind: Secret
metadata:
  name: mysecret
type: Opaque
data:
  username: User
  password: **********

What is the purpose of type: Opaque in the definition above? What other types (and for which use cases) are possible to specify there?


Solution

  • type: Opaque means that from kubernetes's point of view the contents of this Secret is unstructured, it can contain arbitrary key-value pairs.

    In contrast, there is the Secret storing ServiceAccount credentials, or the ones used as ImagePullSecret. These have a constrained contents.