Follow these instructions to deploy this application to Red Hat OpenShift and connect it with a Cloudant database.
- If you don't have one already, create an OpenShift cluster on the IBM Cloud.
- Follow the instructions in Installing the OpenShift CLI to set up your
oc
CLI. - Choose (and if necessary create) a namespace for the application
-
Go to the Catalog and create a new Cloudant database instance.
-
Choose
IAM
for Authentication. -
Create new credentials under Service Credentials and copy value of the url field.
-
Create a Kubernetes secret with your Cloudant credentials.
oc create secret generic cloudant --from-literal=url=<URL> --from-literal=iamApiKey=<IAM_API_KEY>
Example:
oc create secret generic cloudant --from-literal=url=https://xxxxx-yyyy-zzz-eeeee-ddddddd-bluemix.cloudantnosqldb.appdomain.cloud --from-literal=iamApiKey=xxxxxx-ddd-ppppppppppp
- Build and deploy the application from source:
oc new-app https://github.com/IBM-Cloud/get-started-node --strategy=source --env PORT=8080
You should see both a build pod and then an application pod appear, which you can check using:
oc get pods
- Once the application is running, you then need to patch the deployment to ensure that the cloudant secret is exposed to the application via environment variables:
oc patch deployment get-started-node --type "json" -p \
'[{"op":"add","path":"/spec/template/spec/containers/0/env/-","value":{"name":"CLOUDANT_URL","valueFrom":{"secretKeyRef":{"key":"url","name":"cloudant","optional":true}}}},{"op":"add","path":"/spec/template/spec/containers/0/env/-","value":{"name":"CLOUDANT_IAM_API_KEY","valueFrom":{"secretKeyRef":{"key":"iamApiKey","name":"cloudant","optional":true}}}}]'
You should see the applicaiton pod re-start.
- Expose a route to the application:
oc expose svc/get-started-node
- Identify the route to the application
oc get route get-started-node
- Access your application via the HTTP URL given in the HOST/PORT column, which will be of the form
get-started-node-.....containers.appdomain.cloud
.
If, and when, you want to remove the application:
oc delete deployment,route,service,buildconfig,imagestream -l app=get-started-node
oc delete secret cloudant