Kahibaro
Discord Login Register

Managing sensitive data

Why Managing Sensitive Data Matters

OpenShift makes it easy to deploy and scale applications, but that also makes it easy to accidentally leak credentials or other sensitive information. Managing sensitive data is about:

This chapter focuses on how to handle sensitive data correctly in OpenShift, building on the mechanics of Secrets, ConfigMaps, and environment variables from previous sections.

Typical sensitive data includes:

Principles for Handling Sensitive Data

Least privilege

Avoid hard‑coding secrets

Avoid:

Instead:

Encryption in transit and at rest

Secret Usage Patterns

Secrets as environment variables vs volumes

You can consume secrets:

Guidelines:

Minimizing exposure in logs and diagnostics

Lifecycle of Secrets

Managing sensitive data is not a one-time step; it’s a lifecycle.

Creation

Example:

oc create secret generic db-credentials \
  --from-literal=username=dbuser \
  --from-literal=password="$(pass show prod/db-password)"

or:

oc create secret generic tls-cert \
  --from-file=tls.crt=server.crt \
  --from-file=tls.key=server.key

Avoid:

Rotation

Secret rotation is essential when:

Approach:

  1. Create a new secret with updated values (e.g., db-credentials-v2).
  2. Update deployments to use the new secret:
    • Change secretName in pod templates or env references.
  3. Roll out changes (oc rollout restart or by updating the deployment).
  4. Verify all pods are using the new secret.
  5. Remove or disable old credentials in the backend system (DB, external API).
  6. Delete the old secret from OpenShift if no longer needed.

For short-lived secrets (tokens, signed URLs), consider:

Revocation and incident response

When a secret is leaked or suspected:

  1. Revoke or change the credential in the external system (DB, cloud, API).
  2. Create new secrets with new values.
  3. Update workloads to the new secrets and restart pods.
  4. Audit:
    • Check who accessed the secret (via audit logs if available).
    • Identify where the secret might be present (logs, backups, scripts).
  5. Clean up:
    • Remove old secrets.
    • Sanitize logs or archives if possible.
    • Update policies to prevent recurrence.

Storing Secrets Securely

Git and configuration management

Storing OpenShift manifests in Git is standard, but raw secrets should not be committed in plain text.

Options:

General guidelines:

Environment access and shell history

Access Control and Policy

Controlling who can read or modify secrets is central to managing sensitive data.

Limiting user access to secrets

Use RBAC to:

Examples of role patterns:

Be cautious with “view all” permissions:

Limiting in-cluster access

Pods themselves should not be able to read arbitrary secrets:

Integrating with External Secret Stores

In many environments, OpenShift is not the only place secrets are managed.

Common external systems:

Integration patterns:

Security considerations:

Application-Level Practices

Avoiding overexposure inside the pod

Inside the container:

Reducing accidental disclosure

Testing with non-production data

Auditing and Compliance Considerations

For environments with compliance requirements:

Processes:

Practical Guidelines and Checklists

Do’s

Don’ts

By following these practices, you can use OpenShift’s built-in mechanisms and surrounding ecosystem to handle sensitive data in a way that is secure, auditable, and maintainable over the lifetime of your applications.

Views: 11

Comments

Please login to add a comment.

Don't have an account? Register now!