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
Copy file name to clipboardExpand all lines: README.md
+59-99Lines changed: 59 additions & 99 deletions
Original file line number
Diff line number
Diff line change
@@ -51,7 +51,7 @@ This lab will walk you through the deployment of our sample MicroProfile applica
51
51
52
52
## Setting up the cluster
53
53
54
-
To setup a VM in vLaunch and install OKD, see [instructions here](https://apps.na.collabserv.com/wikis/home?lang=en-us#!/wiki/Wfe97e7c353a2_4510_8471_7148220c0bec/page/Setting%20up%20a%20vLaunch%20System%20for%20Red%20Hat%20OpenShift%20Lab). If you do not have access to IBM's vLaunch, follow [instructions here](https://github.com/gshipley/installcentos).
54
+
To setup a VM in vLaunch and install OKD, see [instructions here](https://apps.na.collabserv.com/wikis/home?lang=en-us#!/wiki/Wfe97e7c353a2_4510_8471_7148220c0bec/page/Setting%20up%20a%20vLaunch%20System%20for%20Red%20Hat%20OpenShift%20Lab).
55
55
56
56
## Part 1A: Build the application and Docker container
57
57
@@ -105,28 +105,27 @@ The following steps will build the sample application and create a Docker image
105
105
106
106
1. Navigate into the sample application directory if you are not already:
107
107
```bash
108
-
cd kubernetes-microprofile-lab/lab-artifacts/application
108
+
$ cd kubernetes-microprofile-lab/lab-artifacts/application
1. You can use the Docker CLI to verify that your image is built.
128
127
```bash
129
-
docker images
128
+
$ docker images
130
129
```
131
130
132
131
## Part 1B: Upload the Docker image to OKD's internal registry
@@ -135,80 +134,83 @@ OKD provides an internal, integrated container image registry. For this lab, we
135
134
136
135
1. Ensure you are logged in to OKD. You can use OKD command line interface (CLI) to interact with the cluster. Replace `<username>`, `<password>` and `<okd_ip>` with appropriate values:
1. Your image is now available in the Docker registry in OKD. You can verify this through the OKD's Registry Dashboard at `https://registry-console-default.apps.<okd_ip>.nip.io/registry`. You can use the same username and password as the one used in `oc login` command.
155
+
1. Your image is now available in the internal registry in OKD. You can verify this through the OKD's Registry Dashboard available at `https://registry-console-default.apps.<okd_ip>.nip.io/registry`. You can use the same username and password as the one used in `oc login` command. You Should see
157
156
158
157
## Part 2: Deploy Open Liberty operator and and CouchDB Helm chart
159
158
160
159
In this part of the lab you will install an operator and a Helm chart.
161
160
162
-
### Deploy CouchDB
161
+
### Deploy CouchDB Helm
163
162
164
-
In this section we will deploy CouchDB Helm chart. OKD does not come with tiller. So we need to install tiller first.
163
+
In this section, we will deploy CouchDB Helm chart. However, as OKD does not come with tiller, we will install tiller on the cluster and set up Helm CLI to be able to communicate with the tiller.
165
164
166
165
1. Create a project for Tiller
167
166
```bash
168
-
oc new-project tiller
169
-
```
170
-
If you already have `tiller` project, switch to the project:
171
-
```bash
172
-
oc project tiller
167
+
$ oc new-project tiller
173
168
```
174
169
1. Download Helm CLI and install the Helm client locally:
175
170
176
171
Linux:
177
172
```bash
178
-
curl -s https://storage.googleapis.com/kubernetes-helm/helm-v2.14.1-linux-amd64.tar.gz | tar xz
179
-
cd linux-amd64
173
+
$ curl -s https://storage.googleapis.com/kubernetes-helm/helm-v2.9.0-linux-amd64.tar.gz | tar xz
174
+
$ cd linux-amd64
180
175
```
176
+
181
177
OSX:
182
178
```bash
183
-
curl -s https://storage.googleapis.com/kubernetes-helm/ lm-v2.14.1-darwin-amd64.tar.gz | tar xz
184
-
cd darwin-amd64
179
+
$ curl -s https://storage.googleapis.com/kubernetes-helm/helm-v2.9.0-darwin-amd64.tar.gz | tar xz
1. Grant the default namespace's service account access to the newly created SCC, `ibm-open-liberty-scc`. Update `<namespace>` with the appropriate namespace:
243
+
1. Grant the default namespace's service account access to the newly created SCC, `ibm-open-liberty-scc`.
1. Deploy the microservice application using the provided CR:
249
251
```bash
250
-
cd ../application
251
-
kubectl apply -f application-cr.yaml
252
+
$ cd ../application
253
+
$ kubectl apply -f application-cr.yaml
252
254
```
253
255
1. You can view the status of your deployment by running `kubectl get deployments`. If the deployment is not coming up after a few minutes one way to debug what happened is to query the pods with `kubectl get pods` and then fetch the logs of the Liberty pod with `kubectl logs <pod>`.
254
-
1. Use `kubectl get ing | awk 'FNR == 2 {print $3;}'` to determine the address of the application. Note: If the previous command is printing out a port, such as `80`, please wait a few more minutes for the `URL` to be available.
255
-
1. Add `/openapi/ui` to the end of URL to reach the OpenAPI User Interface. For example, `https://<IP>:<PORT>/openapi/ui`.
256
-
1. If you find that your OKD ingress is taking too long to return the result of the invocation and you get a timeout error, you can bypass the ingress and reach the application via its NodePort layer. To do that, simply find the NodePort port by finding out your service name with `kubectl get services` and then running the command `kubectl describe service <myservice> | grep NodePort | awk 'FNR == 2 {print $3;}' | awk -F '/' '{print $1;}'` and then inserting that port in your current URL using `http`, for example `http://9.8.7.6.nip.io:30698/openapi/ui/`. If those invocations are still taking long, please wait a few minutes for the deployment to fully initiate.
256
+
1. We will access the application using NodePort service. To do that, simply find the NodePort port by finding out your service name with `kubectl get services` and then running the command `kubectl describe service <myservice> | grep NodePort | awk 'FNR == 2 {print $3;}' | awk -F '/' '{print $1;}'` and then inserting that port in your current URL using `http`, for example `http://9.8.7.6.nip.io:30698/openapi/ui/`. If those invocations are still taking long, please wait a few minutes for the deployment to fully initiate.
257
257
1. Congratulations! You have successfully deployed a [MicroProfile](http://microprofile.io/) container into an OKD cluster using operators!
258
258
259
259
## Part 3: Explore the application
@@ -269,62 +269,22 @@ The `vote` application is using various MicroProfile specifications. The `/open
269
269
1. Click on `Execute` and inspect that the `Respond body` contains the same name that you created in step 2. You successfully triggered a fetch from our microservice into the CouchDB database.
270
270
1. Feel free to explore the other APIs and play around with the microservice!
271
271
272
-
## Part 4: Update the Helm release
272
+
## Part 4: Update the Liberty Operator release
273
273
274
-
In this part of the lab you will practice how to make changes to the Helm release you just deployed on the cluster using the Helm CLI.
274
+
In this part of the lab you will practice how to make changes to the Liberty deployment you just deployed on the cluster using the Open Liberty Operator.
275
275
276
-
So far, the database you deployed stores the data inside the container running the database. This means if the container gets deleted or restarted for any reason, all the data stored in the database would be lost.
277
-
278
-
In order to store the data outside of the database container, you would need to enable data persistence through the Helm chart. When you enable persistence, the database would store the data in a PersistentVolume. A PersistentVolume (PV) is a piece of storage in the cluster that has been provisioned by an administrator or by an automatic provisioner.
279
-
280
-
The steps below would guide you how to enable persistence for your database:
281
-
282
-
1. In [Part 3](#Part-3-Explore-the-application), you would've observed that calling `GET /attendee/{id}` returns the `name` you specified. Calling `GET` would read the data from the database.
283
-
1. Find the name of the pod that is running the database container:
284
-
```bash
285
-
kubectl get pods
286
-
```
287
-
You should see a pod name similar to `couchdb-couchdb-0`.
288
-
1. Delete the CouchDB pod to delete the container running the database.
289
-
```bash
290
-
kubectl delete pod couchdb-couchdb-0
291
-
```
292
-
1. Run the following command to see the state of deployments:
293
-
```bash
294
-
kubectl get pods
295
-
```
296
-
You should get an output similar to the following:
Again, you need to wait until the couchdb pod is ready. Wait until the value under `READY` column becomes `2/2`.
276
+
The update scenario is that you will increase the number of replicas for the Liberty deployment to 3. That will increase the number of Open Liberty pods to 3.
303
277
304
-
1. Call again the `GET /attendee/{id}` endpoint from the OpenAPI UI page and see that the server does not return the attendee you created anymore. Instead, it returns 404. That's because the data was stored in the couchdb pod and was lost when the pod was deleted. Let's upgrade our release to add persistence.
305
-
1. Now let's enable persistence for our database:
278
+
1. In `lab-artifacts/operator/application/application-cr.yaml` file, change `replicaCount` value to 3.
279
+
1. Navigate to `lab-artifacts/operator/application` directory:
1. List the deployed packages with their chart versions by running:
314
-
```bash
315
-
helm ls
316
-
```
317
-
You can see that the number of revision should be 2 now for couchdb and Liberty.
318
-
1. Run the following command to see the state of deployments:
319
-
```bash
320
-
kubectl get pods
321
-
```
322
-
You need to wait until the couchdb and Liberty pods become ready. The old pods may be terminating while the new ones start up.
323
-
324
-
For Liberty, you will now see 2 pods, since we increased the number of replicas.
325
-
1. Refresh the page. You may need to add the security exception again. If you get `Failed to load API definition` message then try refreshing again.
326
-
1. Now add a new attendee through the OpenAPI UI as before.
327
-
1. Now repeat Steps 1-5 in this section to see that even though you delete the couchdb database container, data still gets recovered from the PersistentVolume.
287
+
1. You can view the status of your deployment by running `kubectl get deployments`. It might take a few minutes until all the pods are ready.
328
288
329
289
In this part you were introduced to rolling updates. DevOps teams can perform zero-downtime application upgrades, which is an important consideration for production environments.
0 commit comments