Note
This sample is used in the Deploy a Go PostgreSQL API Endpoint in SAP BTP, Kyma Runtime tutorial.
This sample provides a Golang API endpoint for communication with PostgreSQL databases. The API connects to a BTP-managed PostgreSQL instance using Service Binding credentials available in the Kyma cluster.
For the PostgreSQL example, use the deployment.yaml file. It provides the Deployment definition as well as an APIRule to expose the API without authentication. The Deployment references the PostgreSQL Service Binding Secret for connection credentials.
This sample demonstrates how to:
- Create a development namespace in the Kyma runtime.
- Deploy the following Kubernetes resources:
- API deployment written in GO
- API Rule
- Service
- ConfigMap
- SAP BTP, Kyma runtime instance
- PostgreSQL Service Instance and Service Binding in the Kyma cluster
- Docker
- Go
- kubectl configured to use the
KUBECONFIGfile downloaded from the Kyma runtime
-
Build and push the image to your Docker repository:
docker build -t {your-docker-account}/api-postgresql-go -f docker/Dockerfile . docker push {your-docker-account}/api-postgresql-go
-
Create a new
devnamespace:kubectl create namespace dev kubectl label namespaces dev istio-injection=enabled
-
Apply the ConfigMap:
kubectl -n dev apply -f ./k8s/configmap.yaml
-
Apply the Deployment:
kubectl -n dev apply -f ./k8s/deployment.yaml
-
Apply the APIRule:
kubectl -n dev apply -f ./k8s/apirule.yaml
-
Verify that the Deployment is up and running:
kubectl -n dev get deployment api-postgresql-go
-
Use the APIRule:
https://api-postgresql-go.{cluster-domain}/ordershttps://api-postgresql-go.{cluster-domain}/orders/10000001