Challenge, Easy,  on  Kubernetes

Convert Pod to Deployment with Secret Management

Scenario

A Pod named osaka-pgsql-pod is currently running in the osaka-database namespace. The manifest file is available on the dev-machine at:

/home/laborant/osaka-pgsql-pod.yaml

The Pod contains hardcoded environment variables for PostgreSQL configuration. This approach is not secure or scalable for production environments.

You need to migrate this Pod to a Deployment for better scalability and management, externalize the configuration to a Secret for security, and remove the original Pod once the migration is complete.


Tasks

Convert the Pod into a Deployment named osaka-pgsql-deployment with 3 replicas in the osaka-database namespace.

Extract the hardcoded environment variables into a Secret named osaka-pgsql-secret in the osaka-database namespace.

Update the Deployment to consume environment variables from the Secret instead of plain text.

Preserve all existing labels and ensure all replicas are running.

Delete the original Pod osaka-pgsql-pod after successful conversion.


Important: Do not modify the original Pod manifest file. The Deployment should reference the Secret, not plain text values.


Hint

Create Secret from literal values, convert Pod spec to Deployment template, use envFrom with secretRef to inject all Secret keys as environment variables.


Test Cases