Skip to content
This repository was archived by the owner on Jul 22, 2024. It is now read-only.

Commit a976a0b

Browse files
committed
adding more instructions
1 parent 87dcbe9 commit a976a0b

File tree

5 files changed

+45
-5
lines changed

5 files changed

+45
-5
lines changed
296 KB
Loading
108 KB
Loading
277 KB
Loading
238 KB
Loading

workshop/Lab7/README.md

Lines changed: 45 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ This lab configures our nodejs guestbook Application to connect to an external d
33

44
## Approach 1: Manually create database service on IBM Cloud console
55

6+
### Create a Cloudant DB service
67
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.
78

89
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
1314

1415
![Install CloudantDB from console](../.gitbook/assets/install-cloudant-console.png)
1516

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+
![create new credentials](../.gitbook/assets/cloudant-service-creds.png)
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)
1633

1734
## Approach 2: Use the IBM Cloud Operator to provision and manage the database instance on IBM Cloud
1835

@@ -194,9 +211,32 @@ Note that the API version is different from what you may have seen in other reso
194211
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.
195212
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.
196213

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"
228+
229+
![launch cloudant dashboard](../.gitbook/assets/cloudant-launch-dashboard.png)
230+
231+
Use your IBM Credentials to login if necessary. From the Cloudant Dashboard screen, click "Create Database" and give it name, such as "mydatabase"
232+
233+
![launch cloudant dashboard](../.gitbook/assets/cloudant-create-db.png)
234+
235+
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
198238

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.
200240

201241
Download the guestbook application if you haven't already.
202242

@@ -243,7 +283,7 @@ Reference the datasource you just created in `src/server/model-config.json` as s
243283
}
244284
```
245285

246-
## Build a new Docker Images
286+
### Build and push a new docker image
247287

248288
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.
249289

@@ -259,7 +299,7 @@ Build the docker image
259299
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.
260300

261301

262-
## Configure Kubernetes yamls
302+
### Configure Kubernetes yamls
263303

264304
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.
265305

@@ -303,7 +343,7 @@ Replace `[IMAGE_NAME]` in the file [guestbook-deployment-cloudant.yaml](../../sr
303343

304344
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.
305345

306-
## Finally: Deploy to Kubernetes
346+
### Test your changes by deploying to Kubernetes
307347

308348
Deploy to kubernetes using `kubectl apply`:
309349

0 commit comments

Comments
 (0)