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
@@ -11,21 +11,22 @@ For questions/comments about Open Liberty Docker container or Open Liberty Opera
11
11
12
12
# Before you begin
13
13
14
-
You'll need a few different artifacts to this lab. Check if you have these installed by running:
15
-
16
-
```bash
17
-
git --help
18
-
mvn --help
19
-
java -help
20
-
docker --help
21
-
kubectl --help
22
-
oc --help
14
+
You'll need a few different artifacts to this lab. _If you are running these commands on the same VM as the one you installed OKD, all commands except Maven are installed._
@@ -51,7 +52,7 @@ This lab will walk you through the deployment of our sample MicroProfile applica
51
52
52
53
## Setting up the cluster
53
54
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).
55
+
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
56
56
57
## Part 1A: Build the application and Docker container
57
58
@@ -63,11 +64,11 @@ You can clone the lab artifacts and explore the application:
1. You can use the Docker CLI to verify that your image is built.
128
-
```bash
129
-
docker images
128
+
```console
129
+
$ docker images
130
130
```
131
131
132
132
## Part 1B: Upload the Docker image to OKD's internal registry
133
133
134
134
OKD provides an internal, integrated container image registry. For this lab, we will use this registry to host our application image.
135
135
136
136
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.
156
+
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
157
158
158
## Part 2: Deploy Open Liberty operator and and CouchDB Helm chart
159
159
160
160
In this part of the lab you will install an operator and a Helm chart.
161
161
162
-
### Deploy CouchDB
162
+
### Deploy CouchDB Helm
163
163
164
-
In this section we will deploy CouchDB Helm chart. OKD does not come with tiller. So we need to install tiller first.
164
+
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
165
166
166
1. Create a project for Tiller
167
-
```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
+
```console
168
+
$ oc new-project tiller
173
169
```
174
170
1. Download Helm CLI and install the Helm client locally:
175
171
176
172
Linux:
177
-
```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
+
```console
174
+
$ curl -s https://storage.googleapis.com/kubernetes-helm/helm-v2.9.0-linux-amd64.tar.gz | tar xz
175
+
$ cd linux-amd64
180
176
```
177
+
181
178
OSX:
182
-
```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
+
```console
180
+
$ curl -s https://storage.googleapis.com/kubernetes-helm/helm-v2.9.0-darwin-amd64.tar.gz | tar xz
181
+
$ cd darwin-amd64
185
182
```
186
183
187
-
Now configure the Helm client locally:
188
-
```bash
189
-
sudo mv helm /usr/local/bin
190
-
sudo chmod a+x /usr/local/bin/helm
191
-
./helm init --client-only
184
+
1. Now configure the Helm client locally. **Note:** _This will replace your current's Helm CLI. If you can create a back up of your current Helm CLI and replace the lab's Helm CLI after you are done with the lab_:
1. Grant the default namespace's service account access to the newly created SCC, `ibm-open-liberty-scc`. Update `<namespace>` with the appropriate namespace:
1. Deploy the microservice application using the provided CR:
249
-
```bash
250
-
cd ../application
251
-
kubectl apply -f application-cr.yaml
248
+
```console
249
+
$ cd ../application
250
+
$ kubectl apply -f application-cr.yaml
252
251
```
253
252
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.
253
+
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
254
1. Congratulations! You have successfully deployed a [MicroProfile](http://microprofile.io/) container into an OKD cluster using operators!
258
255
259
256
## Part 3: Explore the application
@@ -269,62 +266,22 @@ The `vote` application is using various MicroProfile specifications. The `/open
269
266
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
267
1. Feel free to explore the other APIs and play around with the microservice!
271
268
272
-
## Part 4: Update the Helm release
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.
269
+
## Part 4: Update the Liberty Operator release
275
270
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.
271
+
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.
277
272
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.
273
+
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.
279
274
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`.
303
-
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.
1. List the deployed packages with their chart versions by running:
314
-
```bash
315
-
helm ls
275
+
1. In `lab-artifacts/operator/application/application-cr.yaml` file, change `replicaCount` value to 3.
276
+
1. Navigate to `lab-artifacts/operator/application` directory:
277
+
```console
278
+
$ cd lab-artifacts/operator/application
316
279
```
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
280
+
1. Apply the changes into the cluster:
281
+
```console
282
+
$ kubectl apply -f application-cr.yaml
321
283
```
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.
284
+
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
285
329
286
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