You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jul 22, 2024. It is now read-only.
Copy file name to clipboardExpand all lines: workshop/Lab7/README.md
+45-5Lines changed: 45 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,6 +3,7 @@ This lab configures our nodejs guestbook Application to connect to an external d
3
3
4
4
## Approach 1: Manually create database service on IBM Cloud console
5
5
6
+
### Create a Cloudant DB service
6
7
In these steps will be using a free `lite` CloudantDB on IBM Cloud using your free IBM Cloud account. [Create an account](https://cloud.ibm.com/registration) if you haven't already.
7
8
8
9
Navigate to the [IBM Cloud Catalog](https://cloud.ibm.com/catalog). Make sure your personal account in selected in the dropdown in the upper right. Select the Cloudant tile.
@@ -13,6 +14,22 @@ Set the instance name to "mycloudant". Ensure the "Lite" plan is selected. Then
13
14
14
15

15
16
17
+
### Create a credential for your CloudantDB service
18
+
19
+
Locate your credentials in your CloudantDB service on IBM Cloud. From the Cloudant DB service, select **Service Credentials** on the left. Then click the blue **New credential** on the right.
20
+
21
+

22
+
23
+
Select the default name and role (should be `manager`) for the credentials, and click **Create**.
24
+
25
+
Expand the credential and take note of the **url** parameter. We will be using this value to populate a Kubernetes secret in the next step.
26
+
27
+
### Save your credentials in a Kubernetes `secret`
28
+
29
+
k
30
+
31
+
32
+
Once completed, [skip ahead to the next section](##Next-Steps)
16
33
17
34
## Approach 2: Use the IBM Cloud Operator to provision and manage the database instance on IBM Cloud
18
35
@@ -194,9 +211,32 @@ Note that the API version is different from what you may have seen in other reso
194
211
The role of the IBM Cloud operator is to manage instances of these services and also create a **Binding** to the service that is stored as a secret in the cluster.
195
212
The operator will monitor the IBM Cloud account service instances. If something happens to the service instance, the operator will detect the change and take action. For example, if a the service instance is deleted, the operator will create a new service instance and update the credentials stored in the binding secret.
196
213
197
-
## Modify the guestbook application to read from CloudantDB
214
+
## Next Steps
215
+
216
+
Regardless of whether you did approach 1 or approach 2, the end result is the same. You should now have a CloudantDB service created on IBM Cloud with credentials to that service saved inside your Kubernetes as a `secret`. The next steps walk you through
217
+
218
+
1) Create a new database on the CloudantDB Service
219
+
1) Modify the guestbook application to read from CloudantDB
220
+
1) Build and push a new guestbook docker image
221
+
1) Edit the Kubernetes deployment yaml files to pull the new version of the application AND the credentials saved in the secret
222
+
1) Check your changes by deploying to Kubernetes and testing the application
223
+
224
+
225
+
### Create a new database on the CloudantDB service
226
+
227
+
From your newly created Cloudant service on the IBM Cloud console, click "launch dashboard"
Remember this name as we will be using it later when we deploy our application.
236
+
237
+
### Modify the guestbook application to read from CloudantDB
198
238
199
-
The credentials information is created for your automatically and saved in a Kubernetes `secret`, but your'll have to make minor changes to the Guestbook nodejs application to read from your newly created CloudantDB service.
239
+
You will have to make minor changes to the Guestbook nodejs application to read from your newly created CloudantDB service.
200
240
201
241
Download the guestbook application if you haven't already.
202
242
@@ -243,7 +283,7 @@ Reference the datasource you just created in `src/server/model-config.json` as s
243
283
}
244
284
```
245
285
246
-
## Build a new Docker Images
286
+
###Build and push a new docker image
247
287
248
288
In order to deploy to kubernetes, we will need a Docker Image saved to a registry somewhere. In this lab, we will build an image locally and push directly to DockerHub. In real-life, we would use CI/CD process to build and push our docker image from source control.
249
289
@@ -259,7 +299,7 @@ Build the docker image
259
299
Your guestbook application is all set to talk to a Cloudant database. Next, we will configure our Kubernetes deployment to use the image you just pushed, and to load the missing environment variables: `CLOUDANT_URL` and `CLOUDANT_DB` from our `binding-cloudant` secret.
260
300
261
301
262
-
## Configure Kubernetes yamls
302
+
###Configure Kubernetes yamls
263
303
264
304
We have a yaml file create for you, but you will need to enter the location of the Docker Image you built in the previous step.
265
305
@@ -303,7 +343,7 @@ Replace `[IMAGE_NAME]` in the file [guestbook-deployment-cloudant.yaml](../../sr
303
343
304
344
Notice how we load the environment variable `CLOUDANT_URL` from the `binding-cloudant` secreat that we created for us by the IBM Cloud Operator. This yaml files now defines all the environment variables our guestbook application needs to connect to our Cloudant DB.
0 commit comments