Running the application using odo: 0. Install https://operatorhub.io/operator/service-binding-operator
- Install https://operatorhub.io/operator/cloud-native-postgresql
- Create Cluster service to run postgres DB.
cat << EOF | kubectl apply -f -
apiVersion: postgresql.k8s.enterprisedb.io/v1
kind: Cluster
metadata:
name: cluster-sample
spec:
instances: 1
logLevel: info
primaryUpdateStrategy: unsupervised
storage:
size: 1Gi
EOF
- Run
odo add binding
from project directory to bind the application withCluster/cluster-sample
service.
$ odo add binding
? Do you want to list services from: current namespace
? Select service instance you want to bind to: cluster-sample (Cluster.postgresql.k8s.enterprisedb.io)
? Enter the Binding's name: todo-cluster-sample
? How do you want to bind the service? Bind As Environment Variables
? Select naming strategy for binding names: DEFAULT
✓ Successfully added the binding to the devfile.
Run `odo dev` to create it on the cluster.
You can automate this command by executing:
odo add binding --service cluster-sample.Cluster.postgresql.k8s.enterprisedb.io --name todo-cluster-sample --bind-as-files=false
- Run
odo dev
. - Access the application on port-forwarded URL, for e.g.
127.0.0.1:40001
.