Skip to content

Commit 44ba8d6

Browse files
committed
OKD lab
1 parent 7961b73 commit 44ba8d6

File tree

3 files changed

+35
-14
lines changed

3 files changed

+35
-14
lines changed

README.md

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,11 @@ The vote microservice stores feedback from the sessions and displays how well al
6161

6262
You can clone the lab artifacts and explore the application:
6363

64-
1. Clone the project into your machine.
64+
1. Navigate to your home directory:
65+
```console
66+
cd ~
67+
```
68+
1. Clone the project into your machine:
6569
```console
6670
$ git clone https://github.com/microservices-api/kubernetes-microprofile-lab.git
6771
```
@@ -131,6 +135,14 @@ The following steps will build the sample application and create a Docker image
131135
## Part 1B: Upload the Docker image to OKD's internal registry
132136

133137
OKD provides an internal, integrated container image registry. For this lab, we will use this registry to host our application image.
138+
**NOTE:** If you are running the lab on the same VM as OKD, run the following two commands and then skip to the next section.
139+
1. Tag your docker image:
140+
```bash
141+
docker tag microservice-vote:1.0.0 docker-registry.default.svc:5000/myproject/microservice-vote:1.0.0
142+
```
143+
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.
144+
145+
Run the following steps **only** if you are running the lab on a system other than the OKD VM:
134146

135147
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:
136148
```console
@@ -152,7 +164,7 @@ OKD provides an internal, integrated container image registry. For this lab, we
152164
```console
153165
$ docker push docker-registry-default.apps.<okd_ip>.nip.io/myproject/microservice-vote:1.0.0
154166
```
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
167+
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.
156168

157169
## Part 2: Deploy Open Liberty operator and and CouchDB Helm chart
158170

@@ -194,30 +206,35 @@ In this section, we will deploy CouchDB Helm chart. However, as OKD does not com
194206
Rollout process might take a few minutes to complete. You can check the status of the deployment using `oc get deployment`.
195207
1. If things go well, the following commands should run successfully and you will see version of both the client and the server:
196208
```console
197-
$ helm version
209+
$ helm version --tiller-namespace=tiller
198210
```
211+
Since we did not install Tiller in its default namespace (`kube-system`), we had to specify `--tiller-namespace=tiller`. Alternatively, you can run `export TILLER_NAMESPACE=tiller` instead of specifying `--tiller-namespace=tiller` in your Helm commands.
199212
1. Grant the Tiller server `edit` and `admin` access to the current project:
200213
```console
201214
$ oc policy add-role-to-user edit "system:serviceaccount:tiller:tiller"
202215
$ oc policy add-role-to-user admin "system:serviceaccount:tiller:tiller"
203216
```
204217

205218
Now that Helm is configured both locally and on OKD, you can deploy CouchDB Helm chart.
206-
1. Navigate to `lab-artifacts/helm/database`:
219+
1. Navigate to `kubernetes-microprofile-lab/lab-artifacts/helm/database`:
207220
```console
208-
$ cd ../helm/database
221+
$ cd /lab-artifacts/helm/database
209222
```
210-
1. Switch to your application project:
223+
1. Create a new project to host our application called `myproject`:
224+
```console
225+
$ oc new-project myproject
226+
If you have already created the `myproject`, then switch to the project:
211227
```console
212228
$ oc project myproject
213229
```
214230
1. Allow the `myproject` namespace to run containers as any UID by changing the namespace's Security Context Constraints (SCC):
215231
```console
232+
$ oc adm policy add-scc-to-group anyuid system:serviceaccount:myproject
216233
$ oc adm policy add-scc-to-user anyuid system:serviceaccount:myproject:default
217234
```
218235
1. Deploy the CouchDB Helm chart:
219236
```console
220-
$ helm install couchdb-1.2.0.tgz -f db_values.yaml --name couchdb
237+
$ helm install couchdb-1.2.0.tgz -f db_values.yaml --name couchdb --tiller-namespace=tiller
221238
```
222239
Ensure the CouchDB pod is up and running by executing `kubectl get pods` command. Your output will look similar to the following:
223240
```console
@@ -241,6 +258,8 @@ Now that Helm is configured both locally and on OKD, you can deploy CouchDB Helm
241258
$ kubectl apply -f deploy/
242259
```
243260

261+
You would need to wait for the Open Liberty Operator installation to be completed. You can check the status using `kubectl get pods` and wait until the `open-liberty-operator` pod is ready.
262+
244263
#### Deploy application
245264

246265
1. Deploy the microservice application using the provided CR:
@@ -249,7 +268,7 @@ Now that Helm is configured both locally and on OKD, you can deploy CouchDB Helm
249268
$ kubectl apply -f application-cr.yaml
250269
```
251270
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>`.
252-
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.
271+
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 `https://console.<okd_ip>.nip.io:30698/openapi/ui/`. If those invocations are still taking long, please wait a few minutes for the deployment to fully initiate.
253272
1. Congratulations! You have successfully deployed a [MicroProfile](http://microprofile.io/) container into an OKD cluster using operators!
254273

255274
## Part 3: Explore the application

lab-artifacts/ApplicationDockerfile

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
FROM microservice-enterprise-web:1.0.0
22

3-
COPY --chown=1001:0 server.xml /config/server.xml
4-
COPY --chown=1001:0 application/target/microservice-vote-1.0.0-SNAPSHOT.war /config/apps/vote.war
3+
#COPY --chown=1001:0 server.xml /config/server.xml
4+
#COPY --chown=1001:0 application/target/microservice-vote-1.0.0-SNAPSHOT.war /config/apps/vote.war
5+
6+
COPY server.xml /config/server.xml
7+
COPY application/target/microservice-vote-1.0.0-SNAPSHOT.war /config/apps/vote.war
8+
USER root
9+
RUN chown 1001:0 /config/server.xml /config/apps/vote.war
10+
user 1001:0
511

612
RUN configure.sh

lab-artifacts/operator/application/application-cr.yaml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,6 @@ spec:
2222
secretKeyRef:
2323
name: couchdb-couchdb
2424
key: adminPassword
25-
ingress:
26-
enabled: true
27-
rewriteTarget: "/"
28-
path: "/"
2925
microprofile:
3026
health:
3127
enabled: true

0 commit comments

Comments
 (0)