The author faced a challenge with storing image data efficiently in a project on Google Cloud Platform. Initially, base64-encoded images were stored in Cloud SQL, which led to increased database load and potential performance degradation. To solve this, the author decided to migrate the images to Google Cloud Storage (GCS), which is optimized for storing large objects. A TypeScript script was created to handle the migration, and a Kubernetes Job on Google Kubernetes Engine (GKE) was set up to execute the script securely within a private network. GitHub Actions was used to automate the deployment, reducing manual errors and enhancing security. The migration process involved extracting image data from Cloud SQL, decoding the base64 string, determining the image file type, and uploading the image to GCS. After migration, the application code was updated to reference images from GCS, and thorough testing was conducted to ensure functionality. Finally, the Kubernetes Job and related resources were deleted, and the migration script was removed from the codebase to prevent unintended reuse.
dev.to
dev.to
Create attached notes ...
