102 Appendix B Running a PostgreSQL database on DigitalOcean
About this lesson
Watch 102 Appendix B Running a PostgreSQL database on DigitalOcean by Antonio. This content is being analysed by DeepCamp AI to generate a detailed summary.
Full Transcript
section b.2 running a postgressql database on digital ocean in most of the book you've been running postgressql database instances as containers both in Docker and in your local kubernetes cluster in production we'd like to take advantage of the platform and use a managed postgressql service provided by digital ocean this link the applications we developed throughout the book are Cloud native and follow the 15 Factor methodology as such they treat backing Services as attached resour ources that can be swapped without changing anything in the application code furthermore we followed the environment parity principle and used a real postgressql database both for development and testing and it's the same database we want to use in production moving from a postgressql container running in your local environment to a managed service with high availability scalability and resilience is a matter of changing the values of a few configuration properties for spring boot how great is that first create a new postgressql server named polar postgress as shown in the following code snippet we'll use postgressql 14 which is the same version we used for development and testing remember to replace your underscore region with the geographical region you'd like to use it should be the same as the region you used for the kubernetes cluster in my case it's am 3 see this code the database server provisioning will take several minutes you can verify the installation status with the following command I have filtered the result for the sake of clarity see this code when the database is online your database server is ready take note of the database server ID you'll need it later to mitigate unnecessary attack vectors you can configure a firewall so that the postgressql server is only accessible from the kubernetes cluster created previously remember that I asked you to take notes of the resource IDs for postgressql and kubernetes use them in the following command to configure the firewall and secure access to the database server see this code next let's create two databases to be used by catalog service polard bore catalog and Order service polar bore order remember to replace postgress ID with your postgressql resource ID see this code finally let's retrieve the details for connecting to postgressql remember to replace postgress ID with your postgressql resource ID see this code before concluding this section let's create some secrets in the kubernetes cluster with the postgressql credentials required by the two applications in a real world scenario we should create dedicated users for the two applications and Grant limited privileges for Simplicity we'll use the admin account for both first create a secret for catalog service using the information returned by the previous doyl command see this code similarly create a secret for order service pay attention to the slightly different syntax required by Spring data r2dbc for the URL see this code that's it for postgressql in the next section you'll see how to initialize redus using digital ocean
Watch on YouTube ↗
(saves to browser)
Sign in to unlock AI tutor explanation · ⚡30
Related Reads
📰
📰
📰
📰
TCP vs UDP, Explained — Part 1: Building a TCP Server in C++
Medium · Programming
The Session ID That Wouldn't Stop Changing
Dev.to · Michał Iżewski
Stop Data Leaks: Tenant Scopes in Laravel 🛡️
Dev.to · Prajapati Paresh
Base64 Encoding in JavaScript: A Practical Guide with Real Examples
Dev.to · jiebang-tools
🎓
Tutor Explanation
DeepCamp AI