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
This lab illustrates steps to deploy a MicroProfile application, running in a Open Liberty Docker container into [Minikube](https://kubernetes.io/docs/setup/minikube/)
6
+
This lab illustrates steps to deploy a MicroProfile application, running in a Open Liberty Docker container into [OKD](https://www.okd.io) using Open Liberty Operator.
7
7
8
8
If you find an issue with the lab instruction you can [report it](https://github.com/microservices-api/kubernetes-microprofile-lab/issues) or better yet, [submit a PR](https://github.com/microservices-api/kubernetes-microprofile-lab/pulls).
9
9
10
-
For questions/comments about Liberty's Docker container or Helm charts please email [Arthur De Magalhaes](mailto:arthurdm@ca.ibm.com).
10
+
For questions/comments about Open Liberty Docker container or Open Liberty Operator please email [Arthur De Magalhaes](mailto:arthurdm@ca.ibm.com).
11
11
12
12
# Before you begin
13
13
14
14
You'll need a few different artifacts to this lab. Check if you have these installed by running:
>OKD is a distribution of Kubernetes optimized for continuous application development and multi-tenant deployment. OKD adds developer and operations-centric tools on top of Kubernetes to enable rapid application development, easy deployment and scaling, and long-term lifecycle maintenance for small and large teams. OKD is the upstream Kubernetes distribution embedded in Red Hat OpenShift. OKD embeds Kubernetes and extends it with security and other integrated concepts. OKD is also referred to as Origin in github and in the documentation. An OKD release corresponds to the Kubernetes distribution - for example, OKD 1.10 includes Kubernetes 1.10. If you are looking for enterprise-level support, or information on partner certification, Red Hat also offers Red Hat OpenShift Container Platform.
38
+
39
+
## What are Operators?
35
40
41
+
From [Red Hat](https://www.redhat.com/en/blog/introducing-operator-framework-building-apps-kubernetes):
42
+
> An Operator is a method of packaging, deploying and managing a Kubernetes application. A Kubernetes application is an application that is both deployed on Kubernetes and managed using the Kubernetes APIs and kubectl tooling. To be able to make the most of Kubernetes, you need a set of cohesive APIs to extend in order to service and manage your applications that run on Kubernetes. You can think of Operators as the runtime that manages this type of application on Kubernetes.
36
43
37
-
# Deploying a MicroProfile application in a Minikube cluster
44
+
# Deploying a MicroProfile application in an OKD cluster
38
45
39
-
This lab will walk you through the deployment of our sample MicroProfile Application into a Minikube cluster, which is built on the open source Kubernetes framework. You'll build a MicroProfile application and package it inside a Open Liberty Docker container. You will then utilize a Helm chart that deploys the Liberty container to Minikube, with the appropriate service setup, while also deploying and configuring a CouchDB Helm chart that stands up the database that holds the data for this microservice.
46
+
This lab will walk you through the deployment of our sample MicroProfile Application into an OKD cluster. You'll build a MicroProfile application and package it inside a Open Liberty Docker container. You will then utilize an operator that deploys an Open Liberty container to OKD, with the appropriate service setup, while also deploying and configuring a CouchDB operator that stands up the a database that holds data for this microservice.
40
47
41
48
## Setting up the cluster
42
49
43
-
1. Download and setup minikube
44
-
1. Start minikube by running `minikube start`
45
-
1. Enable ingress with the command `minikube addons enable ingress`.
46
-
1. Set the Docker CLI to target the minikube Docker engine by running `eval $(minikube docker-env)`
47
-
1. Set up helm and tiller by running `helm init`
48
-
1. Wait until the following command indicates that the tiller-deploy deployment is available: `kubectl get deployment tiller-deploy --namespace kube-system` (Note: This could take a few minutes)
50
+
To install OKD on RHEL or CentOS, follow instructions describe [here](https://github.com/gshipley/installcentos#installation). Ensure SELinux is set to _permissive_.
49
51
50
52
## Part 1A: Build the application and Docker container
51
53
52
54
### Vote Microservice
53
55
54
-
The vote microservice stores feedback from the sessions and displays how well all sessions were liked in a pie chart. If the vote service is configured (via server.xml) to connect to a CouchDB database, the votes will be persisted. Otherwise, the vote data will simply be stored in-memory. This sample application is one of the MicroProfile [showcase](https://github.com/eclipse/microprofile-conference/tree/master/microservice-vote) applications.
56
+
The vote microservice stores feedback from the sessions and displays how well all sessions were liked in a pie chart. If the vote service is configured (via `server.xml`) to connect to a CouchDB database, the votes will be persisted. Otherwise, the vote data will simply be stored in-memory. This sample application is one of the MicroProfile [showcase](https://github.com/eclipse/microprofile-conference/tree/master/microservice-vote) applications.
55
57
56
58
You can clone the lab artifacts and explore the application:
57
59
58
-
1. Clone the project into your machine. This is already done on the laptop provided for you in this workshop, so you can skip this step. The cloned folder is under the Home directory (shortcut is on the desktop).
1. Navigate into the sample application directory:
63
-
```bash
65
+
```console
64
66
cd kubernetes-microprofile-lab/lab-artifacts/application
65
67
```
66
68
1. See if you can find where technologies described below are used in the application.
@@ -91,7 +93,7 @@ You can clone the lab artifacts and explore the application:
91
93
92
94
### Dockerizing Vote Microservice
93
95
94
-
By now you should have a general understanding about the application. Now you will see how you can package the sample application into a Docker container by using a Dockerfile that contains instructions on how the image is built.
96
+
By now you should have a general understanding about the application. Now, you will see how you can package the sample application into a Docker container by using a Dockerfile that contains instructions on how the image is built.
95
97
96
98
In this lab we demonstrate a best-practice pattern which separates the concerns between the enterprise architect and the developer. We first build a Docker image that will act as our `enterprise base image`, which in a company would be the shared curated image that all developers must start from - this allows for consistent and compliance across the enterprise. We then build the developer's Docker image, which starts from the enterprise base image and adds only the application and related configuration.
97
99
@@ -105,6 +107,10 @@ The following steps will build the sample application and create a Docker image
105
107
```bash
106
108
mvn clean package
107
109
```
110
+
1. Navigate into the `lab-artifacts` directory
111
+
```bash
112
+
cd ..
113
+
```
108
114
1. Build and tag the Enterprise Docker image:
109
115
```bash
110
116
cd ..
@@ -114,13 +120,38 @@ The following steps will build the sample application and create a Docker image
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.<CLUSTER_IP>.nip.io/registry`.
153
+
154
+
## Part 2: Deploy Liberty and CouchDB Operators
124
155
125
156
In this part of the lab you will use the Helm command line tool to install a Helm chart.
126
157
@@ -129,26 +160,95 @@ First, let's see what are **Helm charts**. Helm is a package manager for Kuberne
129
160
Now let's deploy our workload using Helm charts.
130
161
131
162
### Deploy CouchDB
163
+
164
+
In this section we will deploy CouchDB Helm chart. OKD does not come with tiller. So we need to install tiller first.
165
+
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
173
+
```
174
+
1. Download Helm CLI and install the Helm client locally:
175
+
176
+
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
180
+
```
181
+
OSX:
182
+
```bash
183
+
curl -s https://storage.googleapis.com/kubernetes-helm/ lm-v2.14.1-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:
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>`.
154
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.
@@ -222,7 +322,7 @@ The steps below would guide you how to enable persistence for your database:
222
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.
223
323
224
324
For Liberty, you will now see 2 pods, since we increased the number of replicas.
225
-
1. Refresh the page. You may need to add the security exception again. If you get `Failed to load API defintion` message then try refreshing again.
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.
226
326
1. Now add a new attendee through the OpenAPI UI as before.
227
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.
0 commit comments