One of the cloud managed database services that is available within the Microsoft cloud is Azure Database for PostgreSQL. This is a fully managed dabatase service that comes in three different flavors.
I'm not going to explain in depth what each of thse flavors entail. But each flavor serves a different use case and depending on your requirements, you end up selecting either one. The latest flavor that has become available from Microsoft is flexible server. It's the new kid on the block.
Why is this interesting you might ask? Well if you are about to do a deployment of the latest version of Viya on Azure Kubernetes Service, you have a decision to make. Am I going to use the PostgreSQL database that SAS ships with deployment or am I going to use the cloud managed database service that Azure provides. There are a couple of advantages to using a cloud managed database service, like:
For most deployments I've done so far on Azure Kubernetes Service of Viya, I tend to use Azure Database for PostgreSQL - single server. However this has some drawbacks. One of them not being able to shut down the database. Enter Azure Database for PostgreSQL - flexible server, a service that is currently in preview.
This flavors comes with a couple of exiting new features:
If you are like me and keep close tabs on your cloud expenses, the ability to stop / start the server in combination with stopping your kubernetes cluster when your are not using it is a nice way to reduce your cloud expenses.
In the remainder of this blog I will explain the steps to setup a PostgreSQL database and connect it to your SAS Viya deployment.
Please be aware that at the time of writing this blog post, the PostgreSQL for flexible server is still in the preview phase and is limited to specific regions.
It's a good practice to make sure that the database we are going to deploy is not publicly accessible. This means that our database will not receive a public IP address through which we are able to connect to it. The only connections the database is going to accept is from the Virtual Network, in which we also have our Azure Kubernetes Service running.
To setup a database that is only accessible from within our Virtual Network, it is required to setup a separate subnet within your Virtual Network that is dedicated to your PostgreSQL database.
Then setup the following parameters for the subnet.
Now click on Save and we have created the required subnet and are now ready to move on to the next step in which we will create the database.
Now we are ready to create the PostgreSQL flexible server.
You will then end up in a landing page from which you are able to create the PostgreSQL database.
Click on Add to create a new database. This will bring up the wizard we are going to go through to create the PostgreSQL database. On the first page of this wizard we need to provide the following information.
Make sure to take a note of the username and password as we will be needing this later on for the deployment.
Let's move on to the second page of the wizard where we can configure the following settings.
Click on review + create and after a while, you will end up with an Azure PostgreSQL flexible server instance that you an use for your SAS Viya deployment.
Now let's make the required modifications to our SAS Viya deployment to make use of our newly created database. As you might be aware we now use overlays to apply certain customizations through kustomize. These customizations are gathered in a file called kustomizations.yaml. This file is used by kustomize to generate a YAML file with our modifications, which then can be applied to the cluster to deploy SAS Viya.
To modify the deployment to use the PostgreSQL flexible server, we need to add the following overlays to the kustomization.yaml file.
transformers:
- sas-bases/overlays/external-postgres/external-postgres-transformer.yaml
secretGenerator:
- name: postgres-sas-user # THIS IS FOR INTERNAL USE ONLY - DO NOT EDIT
literals:
- username={{ EXTERNAL-ADMIN-USERNAME }}
- password={{ EXTERNAL-ADMIN-PASSWORD }}
configMapGenerator:
- name: sas-postgres-config # THIS IS FOR INTERNAL USE ONLY - DO NOT EDIT
behavior: merge
literals:
- DATABASE_HOST={{ EXTERNAL-HOST }}
- DATABASE_PORT={{ EXTERNAL-PORT }}
- DATABASE_SSL_ENABLED="true"
- DATABASE_NAME=SharedServices
- EXTERNAL_DATABASE="true" # THIS IS FOR INTERNAL USE ONLY - DO NOT EDIT
- SAS_DATABASE_DATABASESERVERNAME="postgres"
Modify the parameters to reflect your environment and regenerate the deployment yaml file. Run a kubectl apply and sit back and relax. If all goes well, you now have successfully deployed SAS Viya with Azure PostgreSQL flexible server.
Using flexible server in combination with your SAS Viya deployment allows you to completely start / stop your SAS Viya enviornment, with all the benefits of using a cloud managed database. I'm excited about what the flexible server has to offer and I'm looking forward to it becoming General Available.
Have you already done a deployment of SAS Viya on AKS and did you deploy it with an external Postgres database? Let me know in the comments.
Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.
If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website.
Data Literacy is for all, even absolute beginners. Jump on board with this free e-learning and boost your career prospects.