spec vs data vs binaryData
FieldUsed ForExamplespecDescribes the desired state/behavior of a Kubernetes resourcePod containers, Deployment replicasdataStores text configuration valuesDB_HOST, APP_MODEbinaryDataStores binary content (Base64 encoded)Certificates, images, binary files
spec Example (Deployment)
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx
spec:
replicas: 3
selector:
matchLabels:
app: nginxHere, spec tells Kubernetes how the Deployment should run.
data Example (ConfigMap)
apiVersion: v1
kind: ConfigMap
metadata:
name: app-config
data:
DB_HOST: mysql-service
APP_MODE: productionHere, data stores configuration values.
Get yuresh Gurung’s stories in your inbox
Join Medium for free to get updates from this writer.
binaryData Example (ConfigMap)
apiVersion: v1
kind: ConfigMap
metadata:
name: cert-config
binaryData:
cert.p12: MIIK...Here, binaryData stores Base64-encoded binary content.
One-Line Difference
spec = What Kubernetes should do/run
data = Text configuration
binaryData = Binary configuration (Base64 encoded)CKAD Memory Trick
Deployment/Pod/Service
↓
spec
(desired state)ConfigMap
↓
data / binaryData
(configuration values)ConfigMaps do not have a spec section; they use data and optionally binaryData instead.







