Managing Secrets and ConfigMaps in OpenShift: Secure App Configuration

Openshift RSH Network May 02, 2026 2 mins read

Learn how Red Hat OpenShift uses Secrets and ConfigMaps to securely manage sensitive data and application configuration in containerized environments.

Modern applications rely on configuration values and sensitive data such as API keys, database credentials, and certificates. Storing these directly in code or container images creates serious security risks.

OpenShift addresses this challenge with Secrets and ConfigMaps, enabling secure, dynamic, and scalable configuration management. These resources allow applications to consume data at runtime without exposing sensitive information.


๐Ÿ”‘ Secrets in OpenShift

Secrets are used to store sensitive information in a secure, encoded format.

๐Ÿ”น Key Features

  • Stores credentials, tokens, and certificates
  • Encoded using base64 (not encryption by default)
  • Can be mounted as environment variables or files

๐Ÿ“Œ Example Secret

 
apiVersion: v1
kind: Secret
metadata:
name: db-credentials
type: Opaque
data:
username: cmNoX3VzZXI=
password: c2VjdXJlX3Bhc3M=
 

๐Ÿ”น Usage

Secrets can be injected into pods as:

  • Environment variables
  • Mounted volumes

๐Ÿ“‘ ConfigMaps in OpenShift

ConfigMaps store non-sensitive configuration data, separating configuration from application logic.

๐Ÿ”น Key Features

  • Stores environment-specific settings
  • Enables dynamic updates without rebuilding images
  • Supports key-value pairs or full config files

๐Ÿ“Œ Example ConfigMap

 
apiVersion: v1
kind: ConfigMap
metadata:
name: app-config
data:
LOG_LEVEL: "debug"
FEATURE_FLAG: "true"
 

๐Ÿ”ง Using Secrets and ConfigMaps in Pods

You can inject both Secrets and ConfigMaps into containers using environment variables:

 
env:
- name: DB_USER
valueFrom:
secretKeyRef:
name: db-credentials
key: username
- name: LOG_LEVEL
valueFrom:
configMapKeyRef:
name: app-config
key: LOG_LEVEL
 

This approach keeps application code clean while securely managing configuration.


๐Ÿงช Troubleshooting Tips

  • Use oc get secrets and oc get configmaps to list resources
  • Inspect environment variables:

     
    oc exec <pod> -- env
     
  • Verify base64 encoding for Secret values
  • Check RBAC permissions if access issues occur

โœ… Best Practices

โœ” Never hardcode credentials in application code
โœ” Use RBAC to restrict access to Secrets
โœ” Rotate secrets regularly
โœ” Separate sensitive (Secrets) and non-sensitive data (ConfigMaps)
โœ” Use external secret managers for production-grade security


๐Ÿ“Œ Conclusion

Secrets and ConfigMaps are fundamental to secure and scalable application deployment in Kubernetes environments like OpenShift. By separating configuration from code and securing sensitive data, organizations can improve security posture while maintaining operational flexibility.

Advertisement

R
RSH Network

52 posts published

Sign in to subscribe to blog updates