Course contentsShow
← Cloud and Infrastructure
Lesson 1264 of 2,98925. Kubernetes Configuration and SecretsFree lesson

Secret Types and Use Cases

Explore built-in Secret types like Opaque, TLS, dockerconfigjson, and their specific purposes.

Secret Types and Use Cases

What You'll Learn

You'll discover the different built-in Secret types Kubernetes provides and when to use each one for specific scenarios.

Understanding Secret Types

Kubernetes doesn't treat all secrets the same way. While the data inside is always base64-encoded, different Secret types signal to Kubernetes (and administrators) what kind of sensitive data you're storing and how it should be handled.

Think of Secret types like labeled envelopes: a "confidential letter" envelope looks different from a "tax documents" envelope. Both are sealed, but the label tells you what's inside and how to handle it.

Built-In Secret Types

Opaque (Generic)

The default type when you don't specify one. Use this for arbitrary key-value data like API keys, passwords, or tokens. Most flexible but provides no special validation.

type: Opaque

kubernetes.io/tls

Specifically designed for TLS certificates and private keys. Kubernetes expects two keys: tls.crt (certificate) and tls.key (private key). Used with Ingress resources for HTTPS termination.

type: kubernetes.io/tls

kubernetes.io/dockerconfigjson

Stores Docker registry credentials for pulling private container images. Kubernetes knows to use this for authentication when pulling images. Contains a .dockerconfigjson key with registry authentication data.

type: kubernetes.io/dockerconfigjson

kubernetes.io/basic-auth and kubernetes.io/ssh-auth

Less common types for basic HTTP authentication and SSH credentials respectively.

Why Types Matter

Secret types provide validation and clarity. Using kubernetes.io/tls ensures you include both certificate and key. Using dockerconfigjson makes it clear this Secret is for image pulling. It prevents mistakes and makes your configuration self-documenting.

Key Takeaway: Kubernetes Secret types like Opaque, TLS, and dockerconfigjson serve different purposes—choose the type that matches your data to get validation and clear intent in your cluster.