Skip to content

ConfigMaps vs Secrets

Course: Kubernetes Part 2 - chapter 16

  • Creating a ConfigMap
apiVersion: v1
kind: ConfigMap
metadata:
name: example-config
data:
key1: value1
key2: value2
  • Creating a Secret
apiVersion: v1
kind: Secret
metadata:
name: example-secret
data:
password: cGFzc3dvcmQ=
apiKey: YXBpa2V5
  • Purpose and Usage:
    • Secrets: Designed specifically to store sensitive data such as passwords, OAuth tokens, and SSH keys.
    • ConfigMaps: Used to store non-sensitive configuration data, such as configuration files, environment variables, or command-line arguments.
  • Base64 Encoding:
    • Secrets: The data stored in Secrets is base64 encoded. This is not encryption but simply encoding, making it slightly obfuscated. This encoding allows the data to be safely transmitted as part of JSON or YAML files.
    • ConfigMaps: Data in ConfigMaps is stored as plain text without any encoding.
  • Volatility and Updates:
    • Secrets: Often, the data in Secrets needs to be rotated or updated more frequently due to its sensitive nature.
    • ConfigMaps: Configuration data typically changes less frequently compared to sensitive data.
  • Kubernetes Features: