Kahibaro
Discord Login Register

Best practices for configuration

Principles of Good Configuration Design

Configuration in OpenShift should be:

Applied to OpenShift, this means using ConfigMap, Secret, Deployment, BuildConfig, etc. in a consistent way and avoiding “magic” configuration inside images.

Key goals:

What Belongs Where: ConfigMaps, Secrets, and Images

A core best practice is deciding where each piece of configuration lives.

Split configuration types clearly

Anti-patterns to avoid

Structuring Configuration in OpenShift

Prefer environment variables for simple values

For simple key-value pairs:

Advantages:

Examples:

env:
  - name: APP_LOG_LEVEL
    valueFrom:
      configMapKeyRef:
        name: myapp-config
        key: log.level
  - name: DB_PASSWORD
    valueFrom:
      secretKeyRef:
        name: myapp-db-credentials
        key: password

Use mounted files for structured config

When configuration is more complex:

Example pattern:

volumes:
  - name: app-config
    configMap:
      name: myapp-config
containers:
  - name: myapp
    volumeMounts:
      - name: app-config
        mountPath: /etc/myapp
        readOnly: true

Prefer this when:

Avoid configuration sprawl

Configuration should be organized, not scattered:

Managing Configuration Across Environments

Keep configuration shape identical

Across environments (dev, test, prod):

This enables:

Bad:

Good:

Use clear naming conventions

Common patterns:

Pick one pattern and apply it consistently.

Use Git and overlays (GitOps-friendly)

Store all configuration manifests in Git:

Benefits:

Even without a full GitOps setup, treat configuration as code.

Security-Focused Configuration Practices

Never store secrets in plain text sources

Avoid:

Preferred approaches:

Use least privilege and separation

Application pods should only be able to read the Secrets they actually need.

Validate that configuration doesn’t leak secrets

Practices:

Use separate ConfigMaps and Secrets instead of mixing sensitive and non-sensitive values in one resource. This reduces the risk of exposing secrets by accident.

Operational Best Practices

Make configuration changes controlled and trackable

Use:

Example:

metadata:
  name: myapp-config
  labels:
    app: myapp
    component: backend
  annotations:
    owner: "team-payments"
    change-ticket: "INC-12345"

Minimize required restarts for config changes

Some configuration requires pod restarts, some not:

Balance between:

Validate configuration before applying

Avoid pushing broken configs into production:

If configuration is used by multiple tenants or teams, treat changes as backward-incompatible unless proven safe.

Use defaults and fallbacks carefully

In the application:

In OpenShift manifests:

Designing for Multi-Tenancy and Teams

Namespace-level isolation

Use namespaces to:

Each namespace:

This prevents accidental cross-usage of configuration between unrelated workloads.

Align configuration ownership and responsibilities

Define:

Common models:

Patterns for Complex Applications

Shared vs. per-service configuration

For microservices:

But:

Configuration for jobs and batch workloads

Batch jobs often:

Best practices:

Example pattern:

Practical Tips and Anti-Patterns

Practical tips

Common anti-patterns

Summary Checklist

When designing configuration for an OpenShift workload, verify:

Following these practices produces configurations that are safer, easier to reason about, and friendlier to automation and GitOps workflows in OpenShift.

Views: 12

Comments

Please login to add a comment.

Don't have an account? Register now!