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

7/15/2017

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?

-- Denis Biondic
kubernetes
kubernetes-security

4 Answers

7/16/2017

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.

-- Janos Lenart
Source: StackOverflow

3/30/2019

All types:

SecretType = "Opaque"                                 // Opaque (arbitrary data; default)
SecretType = "kubernetes.io/service-account-token"    // Kubernetes auth token
SecretType = "kubernetes.io/dockercfg"                // Docker registry auth
SecretType = "kubernetes.io/dockerconfigjson"         // Latest Docker registry auth

To learn more, see Secrets design document.

-- S.J
Source: StackOverflow

3/30/2019
-- user674669
Source: StackOverflow

7/15/2017

looks like its read only value for clients, clients are not allowed to modify this value.

This value MUST be treated as opaque by clients and passed unmodified back to the serve

this page has the details in the resourceVersion filed.


edit

link change here is the document info:

resourceVersion string An opaque value that represents the internal version of this object that can be used by clients to determine when objects have changed. May be used for optimistic concurrency, change detection, and the watch operation on a resource or set of resources. Clients must treat these values as opaque and passed unmodified back to the server. They may only be valid for a particular resource or set of resources. Populated by the system. Read-only. Value must be treated as opaque by clients and . More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#concurrency-control-and-consistency

https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.9/

-- sfgroups
Source: StackOverflow