Deploying microservices to OpenShift

duration 45 minutes

Prerequisites:

Explore how to deploy microservices to Red Hat OpenShift.

What you’ll learn

You will learn how to deploy two microservices in Open Liberty containers to an OpenShift cluster.

There are different cloud-based solutions for running your Kubernetes workloads. With a cloud-based infrastructure, you can focus on developing your microservices without worrying about low-level infrastructure details for deployment. Using a cloud helps you to easily scale and manage your microservices in a high-availability setup.

Kubernetes is an open source container orchestrator that automates many tasks that are involved in deploying, managing, and scaling containerized applications. If you would like to learn more about Kubernetes, check out the Deploying microservices to Kubernetes guide.

OpenShift is a Kubernetes-based platform with added functions. It streamlines the DevOps process by providing an intuitive development pipeline. It also provides integration with multiple tools to make the deployment and management of cloud applications easier. To learn more about the different platforms that Red Hat OpenShift offers, check out their official documentation.

The two microservices you will deploy are called system and inventory. The system microservice returns the JVM system properties of the running container. It also returns the pod’s name in the HTTP header, making replicas easy to distinguish from each other. The inventory microservice adds the properties from the system microservice to the inventory. This process demonstrates how communication can be established between pods inside a cluster.

Additional prerequisites

Before you begin, the following additional tools need to be installed:

  • Docker: You need a containerization software for building containers. Kubernetes supports various container types, but you will use Docker in this guide. For installation instructions, refer to the official Docker documentation.

  • OpenShift account: To access a Kubernetes cluster, you must sign up for a Red Hat OpenShift online account. To sign up, refer to the official website. Keep in mind that the creation time depends on resource availability and may take some time.

  • OpenShift CLI: You need the OpenShift command-line tool oc to interact with your Kubernetes cluster. For installation instructions, refer to the official OpenShift Online documentation.

To verify that the OpenShift CLI is installed correctly, run the following command:

oc version

The output will be similar to:

Client Version: version.Info{Major:"4", Minor:"1+", GitVersion:"v4.1.14", ... }

Getting started

The fastest way to work through this guide is to clone the Git repository and use the projects that are provided inside:

git clone https://github.com/openliberty/guide-cloud-openshift.git
cd guide-cloud-openshift

The start directory contains the starting project that you will build upon.

The finish directory contains the finished project that you will build.

Accessing an OpenShift cluster

Before you can deploy your microservices, you must gain access to a cluster on OpenShift.

Creating an OpenShift account automatically grants you access to their multi-tenant, OpenShift cluster. After you have access, you are also given access to their online web console. To login to OpenShift by using the CLI, navigate to the online web console by following the [username] > Copy Login Command > Display Token > Log in with this token path.

The command looks like the following example:

oc login --token=[your-token] --server=https://api.[region].online-starter.openshift.com:[port]

Create a project by running the following command:

oc new-project [project-name]

Deploying microservices to OpenShift

In this section, you will learn how to deploy two microservices in Open Liberty containers to a Kubernetes cluster on OpenShift. You will build and containerize the system and inventory microservices, push them to a container registry, and then deploy them to your Kubernetes cluster.

Building and containerizing the microservices

The first step of deploying to Kubernetes is to build your microservices and containerize them.

The starting Java project, which is located in the start directory, is a multi-module Maven project. It is made up of the system and inventory microservices. Each microservice resides in its own directory, start/system or start/inventory. Both of these directories contain a Dockerfile, which is necessary for building the Docker images. See the Containerizing microservices guide if you’re unfamiliar with Dockerfiles.

If you’re familiar with Maven and Docker, you might be tempted to run a Maven build first and then use the .war file to build a Docker image. The projects are set up so that this process is automated as a part of a single Maven build.

To build these microservices, navigate to the start directory and run the following command:

mvn package

Next, run the docker build commands to build container images for your application:

docker build -t system:1.0-SNAPSHOT system/.
docker build -t inventory:1.0-SNAPSHOT inventory/.

The -t flag in the docker build command allows the Docker image to be labeled (tagged) in the name[:tag] format. The tag for an image describes the specific image version. If the optional [:tag] tag is not specified, the latest tag is created by default.

During the build, you see various Docker messages that describe what images are being downloaded and built. When the build finishes, run the following command to list all local Docker images:

docker images

Verify that the system:1.0-SNAPSHOT and inventory:1.0-SNAPSHOT images are listed among them, for example:

REPOSITORY                    TAG
system                        1.0-SNAPSHOT
inventory                     1.0-SNAPSHOT
open-liberty                  latest

If you don’t see the system:1.0-SNAPSHOT and inventory:1.0-SNAPSHOT images, check the Maven build log for any potential errors.

Pushing the images to OpenShift’s internal registry

In order to run the microservices on the cluster, you need to push the microservice images into a container image registry. You will use OpenShift’s integrated container image registry called OpenShift Container Registry (OCR). After your images are pushed into the registry, you can use them in the pods you create later in the guide.

First, you must authenticate your Docker client to your OCR. Start by running the login command:

oc registry login

You can store your Docker credentials in a custom external credential store, which is more secure than using a Docker configuration file. If you are using a custom credential store for securing your registry credentials, or if you are unsure where your credentials are stored, use the following command:

MAC | LINUX

docker login -u `oc whoami` -p `oc whoami -t` `oc registry info`

WINDOWS

Because the Windows command prompt doesn’t support the command substitution that is displayed for Mac and Linux, run the following commands:

oc whoami
oc whoami -t
oc registry info

Replace the square brackets in the following docker login command with the results from the previous commands:

docker login -u [oc whoami] -p [oc whoami -t] [oc registry info]

The command authenticates your credentials against the internal registry so that you are able to push and pull images. The registry address will be displayed after you run the oc registry login command. It is formatted similar to the following output:

default-route-openshift-image-registry.apps.[region].starter.openshift-online.com

You can also view the registry address by running the following command:

oc registry info

Ensure that you are logged in to OpenShift and the registry, and run the following commands to tag your applications:

MAC | LINUX

docker tag system:1.0-SNAPSHOT `oc registry info`/`oc project -q`/system:1.0-SNAPSHOT
docker tag inventory:1.0-SNAPSHOT `oc registry info`/`oc project -q`/inventory:1.0-SNAPSHOT

WINDOWS

Because the Windows command prompt doesn’t support the command substitution that is displayed for Mac and Linux, run the following commands:

oc registry info
oc project -q

Replace the square brackets in the following docker tag commands with the results from the previous commands:

docker tag system:1.0-SNAPSHOT [oc registry info]/[oc project -q]/system:1.0-SNAPSHOT
docker tag inventory:1.0-SNAPSHOT [oc registry info]/[oc project -q]/inventory:1.0-SNAPSHOT

Finally, push your images to the registry:

MAC | LINUX

docker push `oc registry info`/`oc project -q`/system:1.0-SNAPSHOT
docker push `oc registry info`/`oc project -q`/inventory:1.0-SNAPSHOT

WINDOWS

Because the Windows command prompt doesn’t support the command substitution that is displayed for Mac and Linux, run the following commands:

oc registry info
oc project -q

Replace the square brackets in the following docker push commands with the results from the previous commands:

docker push [oc registry info]/[oc project -q]/system:1.0-SNAPSHOT
docker push [oc registry info]/[oc project -q]/inventory:1.0-SNAPSHOT

After you push the images, run the following command to list the images that you pushed to the internal OCR:

oc get imagestream

Verify that the system and inventory images are listed among them, for example:

NAME        IMAGE REPOSITORY                                                                                     TAGS           UPDATED
inventory   default-route-openshift-image-registry.apps.us-west-1.starter.openshift-online.com/guide/inventory   1.0-SNAPSHOT   3 seconds ago
system      default-route-openshift-image-registry.apps.us-west-1.starter.openshift-online.com/guide/system      1.0-SNAPSHOT   17 seconds ago

Deploying the microservices

Now that your container images are built, deploy them by using a Kubernetes object configuration file.

Kubernetes objects can be configured in a YAML file that contains a description of all your deployments, services, or any other objects that you want to deploy. All objects can also be deleted from the cluster by using the same YAML file that you used to deploy them. The kubernetes.yaml object configuration file is provided for you. If you are interested in learning more about using and configuring Kubernetes clusters, check out the Deploying microservices to Kubernetes guide.

kubernetes.yaml

 1apiVersion: apps/v1
 2kind: Deployment
 3metadata:
 4  name: system-deployment
 5  labels:
 6    app: system
 7spec:
 8  selector:
 9    matchLabels:
10      app: system
11  template:
12    metadata:
13      labels:
14        app: system
15    spec:
16      containers:
17      - name: system-container
18        # tag::systemImage[]
19        image: image-registry.openshift-image-registry.svc:5000/[project-name]/system:1.0-SNAPSHOT
20        # end::systemImage[]
21        ports:
22        - containerPort: 9080
23---
24apiVersion: apps/v1
25kind: Deployment
26metadata:
27  name: inventory-deployment
28  labels:
29    app: inventory
30spec:
31  selector:
32    matchLabels:
33      app: inventory
34  template:
35    metadata:
36      labels:
37        app: inventory
38    spec:
39      containers:
40      - name: inventory-container
41        # tag::inventoryImage[]
42        image: image-registry.openshift-image-registry.svc:5000/[project-name]/inventory:1.0-SNAPSHOT
43        # end::inventoryImage[]
44        ports:
45        - containerPort: 9080
46---
47apiVersion: v1
48kind: Service
49metadata:
50  name: system-service
51spec:
52  selector:
53    app: system
54  ports:
55  - protocol: TCP
56    port: 9080
57---
58apiVersion: v1
59kind: Service
60metadata:
61  name: inventory-service
62spec:
63  selector:
64    app: inventory
65  ports:
66  - protocol: TCP
67    port: 9080
68---
69# tag::systemRoute[]
70apiVersion: v1
71kind: Route
72metadata:
73  name: system-route
74spec:
75  to:
76    kind: Service
77    name: system-service
78# end::systemRoute[]
79---
80# tag::inventoryRoute[]
81apiVersion: v1
82kind: Route
83metadata:
84  name: inventory-route
85spec:
86  to:
87    kind: Service
88    name: inventory-service
89# end::inventoryRoute[]
Update the kubernetes.yaml file.
kubernetes.yaml

The image is the name and tag of the container image that you want to use for the container. The image address is the OCR address that you logged in to. Update the system image and the inventory image fields to include your project name.

Run the following commands to deploy the objects as defined in kubernetes.yaml file:

oc apply -f kubernetes.yaml

You see an output similar to the following example:

deployment.apps/system-deployment created
deployment.apps/inventory-deployment created
service/system-service created
service/inventory-service created
route.route.openshift.io/system-route created
route.route.openshift.io/inventory-route created

When the apps are deployed, run the following command to check the status of your pods:

oc get pods

If all the pods are healthy and running, you see an output similar to the following example:

NAME                                    READY     STATUS    RESTARTS   AGE
system-deployment-6bd97d9bf6-4ccds      1/1       Running   0          15s
inventory-deployment-645767664f-nbtd9   1/1       Running   0          15s

Making requests to the microservices

To access the services and the application, use a route. A route in OpenShift exposes a service at a hostname such as www.your-web-app.com so external users can access the application.

kubernetes.yaml

 1apiVersion: apps/v1
 2kind: Deployment
 3metadata:
 4  name: system-deployment
 5  labels:
 6    app: system
 7spec:
 8  selector:
 9    matchLabels:
10      app: system
11  template:
12    metadata:
13      labels:
14        app: system
15    spec:
16      containers:
17      - name: system-container
18        # tag::systemImage[]
19        image: image-registry.openshift-image-registry.svc:5000/[project-name]/system:1.0-SNAPSHOT
20        # end::systemImage[]
21        ports:
22        - containerPort: 9080
23---
24apiVersion: apps/v1
25kind: Deployment
26metadata:
27  name: inventory-deployment
28  labels:
29    app: inventory
30spec:
31  selector:
32    matchLabels:
33      app: inventory
34  template:
35    metadata:
36      labels:
37        app: inventory
38    spec:
39      containers:
40      - name: inventory-container
41        # tag::inventoryImage[]
42        image: image-registry.openshift-image-registry.svc:5000/[project-name]/inventory:1.0-SNAPSHOT
43        # end::inventoryImage[]
44        ports:
45        - containerPort: 9080
46---
47apiVersion: v1
48kind: Service
49metadata:
50  name: system-service
51spec:
52  selector:
53    app: system
54  ports:
55  - protocol: TCP
56    port: 9080
57---
58apiVersion: v1
59kind: Service
60metadata:
61  name: inventory-service
62spec:
63  selector:
64    app: inventory
65  ports:
66  - protocol: TCP
67    port: 9080
68---
69# tag::systemRoute[]
70apiVersion: v1
71kind: Route
72metadata:
73  name: system-route
74spec:
75  to:
76    kind: Service
77    name: system-service
78# end::systemRoute[]
79---
80# tag::inventoryRoute[]
81apiVersion: v1
82kind: Route
83metadata:
84  name: inventory-route
85spec:
86  to:
87    kind: Service
88    name: inventory-service
89# end::inventoryRoute[]

Both the system and inventory routes are configured in the kubernetes.yaml file, and running the oc apply -f kubernetes.yaml command exposed both services.

Your microservices can now be accessed through the hostnames that you can find by running the following command:

oc get routes

They can also be found in the web console by following the Networking > Routes > Location path. Hostnames are in the inventory-route-[project-name].apps.[region].starter.openshift-online.com format. Ensure that you are in your project, not the default project, which is shown in the upper-left corner of the web console.

To access your microservices, point your browser to the following URLs. Substitute the appropriate hostnames for the system and inventory services:

  • http://[system-hostname]/system/properties/

  • http://[inventory-hostname]/inventory/systems

In the first URL, you see a result in JSON format with the system properties of the container JVM. The second URL returns an empty list, which is expected because no system properties are stored in the inventory yet.

Point your browser to the http://[inventory-hostname]/inventory/systems/system-service URL. When you to go this URL, the system properties that are taken from the system-service are automatically stored in the inventory. Go back to http://[inventory-hostname]/inventory/systems and you see a new entry.

Testing the microservices

pom.xml

  1<?xml version="1.0" encoding="UTF-8"?>
  2<project xmlns="http://maven.apache.org/POM/4.0.0"
  3    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  4    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  5
  6    <modelVersion>4.0.0</modelVersion>
  7
  8    <parent>
  9        <groupId>net.wasdev.wlp.maven.parent</groupId>
 10        <artifactId>liberty-maven-app-parent</artifactId>
 11        <version>RELEASE</version>
 12    </parent>
 13
 14    <groupId>io.openliberty.guides</groupId>
 15    <artifactId>kube-demo</artifactId>
 16    <version>1.0-SNAPSHOT</version>
 17    <packaging>pom</packaging>
 18
 19    <properties>
 20        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
 21        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
 22        <maven.compiler.source>1.8</maven.compiler.source>
 23        <maven.compiler.target>1.8</maven.compiler.target>
 24        <!-- Plugins -->
 25        <version.maven-war-plugin>2.6</version.maven-war-plugin>
 26        <version.exec-maven-plugin>1.6.0</version.exec-maven-plugin>
 27        <version.maven-surefire-plugin>3.0.0-M1</version.maven-surefire-plugin>
 28        <version.maven-failsafe-plugin>3.0.0-M1</version.maven-failsafe-plugin>
 29        <!-- OpenLiberty runtime -->
 30        <version.openliberty-runtime>RELEASE</version.openliberty-runtime>
 31        <http.port>9080</http.port>
 32        <https.port>9443</https.port>
 33        <!-- Default test properties -->
 34        <!-- tag::systemIP[] -->
 35        <system.ip>system-service-[project-name].apps.[cluster-ip].online-starter.openshift.com</system.ip>
 36        <!-- end::systemIP[] -->
 37        <!-- tag::inventoryIP[] -->
 38        <inventory.ip>inventory-service-[project-name].apps.[cluster-ip].online-starter.openshift.com</inventory.ip>
 39        <!-- end::inventoryIP[] -->
 40        <!-- tag::systemKubeService[] -->
 41        <system.kube.service>system-service</system.kube.service>
 42        <!-- end::systemKubeService[] -->
 43    </properties>
 44
 45    <dependencyManagement>
 46        <dependencies>
 47           <dependency>
 48               <groupId>io.openliberty.features</groupId>
 49               <artifactId>features-bom</artifactId>
 50               <version>RELEASE</version>
 51               <type>pom</type>
 52               <scope>import</scope>
 53           </dependency>
 54           <dependency>
 55                <groupId>org.eclipse.microprofile.rest.client</groupId>
 56                <artifactId>microprofile-rest-client-api</artifactId>
 57                <version>1.0.1</version>
 58                <scope>provided</scope>
 59            </dependency>
 60            <dependency>
 61                <groupId>junit</groupId>
 62                <artifactId>junit</artifactId>
 63                <version>4.12</version>
 64                <scope>test</scope>
 65            </dependency>
 66            <dependency>
 67                <groupId>org.glassfish</groupId>
 68                <artifactId>javax.json</artifactId>
 69                <version>1.0.4</version>
 70                <scope>test</scope>
 71            </dependency>
 72            <dependency>
 73                <groupId>org.apache.cxf</groupId>
 74                <artifactId>cxf-rt-rs-extension-providers</artifactId>
 75                <version>3.2.6</version>
 76                <scope>test</scope>
 77            </dependency>
 78            <dependency>
 79                <groupId>org.apache.cxf</groupId>
 80                <artifactId>cxf-rt-rs-client</artifactId>
 81                <version>3.2.6</version>
 82                <scope>test</scope>
 83            </dependency>
 84            <dependency>
 85                <groupId>org.apache.commons</groupId>
 86                <artifactId>commons-lang3</artifactId>
 87                <version>3.0</version>
 88                <scope>compile</scope>
 89            </dependency>
 90            <!-- Support for JDK 9 and above -->
 91            <dependency>
 92                <groupId>javax.xml.bind</groupId>
 93                <artifactId>jaxb-api</artifactId>
 94                <version>2.3.1</version>
 95                <scope>test</scope>
 96            </dependency>
 97            <dependency>
 98                <groupId>com.sun.xml.bind</groupId>
 99                <artifactId>jaxb-core</artifactId>
100                <version>2.3.0.1</version>
101                <scope>test</scope>
102            </dependency>
103            <dependency>
104                <groupId>com.sun.xml.bind</groupId>
105                <artifactId>jaxb-impl</artifactId>
106                <version>2.3.2</version>
107                <scope>test</scope>
108            </dependency>
109            <dependency>
110                <groupId>javax.activation</groupId>
111                <artifactId>activation</artifactId>
112                <version>1.1.1</version>
113                <scope>test</scope>
114            </dependency>
115        </dependencies>
116    </dependencyManagement>
117
118    <profiles>
119        <profile>
120            <id>windowsExtension</id>
121            <activation>
122                <os><family>Windows</family></os>
123            </activation>
124            <properties>
125                <kubectl.extension>.cmd</kubectl.extension>
126            </properties>
127        </profile>
128        <profile>
129            <id>nonWindowsExtension</id>
130            <activation>
131                <os><family>!Windows</family></os>
132            </activation>
133            <properties>
134                <kubectl.extension></kubectl.extension>
135            </properties>
136        </profile>
137    </profiles>
138
139    <build>
140        <pluginManagement>
141            <plugins>
142                <plugin>
143                    <groupId>org.apache.maven.plugins</groupId>
144                    <artifactId>maven-war-plugin</artifactId>
145                    <version>${version.maven-war-plugin}</version>
146                    <configuration>
147                        <failOnMissingWebXml>false</failOnMissingWebXml>
148                        <packagingExcludes>pom.xml</packagingExcludes>
149                    </configuration>
150                </plugin>
151                <plugin>
152                    <groupId>net.wasdev.wlp.maven.plugins</groupId>
153                    <artifactId>liberty-maven-plugin</artifactId>
154                    <configuration>
155                        <assemblyArtifact>
156                            <groupId>io.openliberty</groupId>
157                            <artifactId>openliberty-runtime</artifactId>
158                            <version>RELEASE</version>
159                            <type>zip</type>
160                        </assemblyArtifact>
161                    </configuration>
162                </plugin>
163                <!-- Plugin to run unit tests -->
164                <plugin>
165                    <groupId>org.apache.maven.plugins</groupId>
166                    <artifactId>maven-surefire-plugin</artifactId>
167                    <version>${version.maven-surefire-plugin}</version>
168                    <executions>
169                        <execution>
170                            <phase>test</phase>
171                            <id>default-test</id>
172                            <configuration>
173                                <excludes>
174                                    <exclude>**/it/**</exclude>
175                                </excludes>
176                                <reportsDirectory>
177                                    ${project.build.directory}/test-reports/unit
178                                </reportsDirectory>
179                            </configuration>
180                        </execution>
181                    </executions>
182                </plugin>
183                <!-- Plugin to run functional tests -->
184                <plugin>
185                    <groupId>org.apache.maven.plugins</groupId>
186                    <artifactId>maven-failsafe-plugin</artifactId>
187                    <version>${version.maven-failsafe-plugin}</version>
188                    <executions>
189                        <execution>
190                            <phase>integration-test</phase>
191                            <id>integration-test</id>
192                            <goals>
193                                <goal>integration-test</goal>
194                            </goals>
195                            <configuration>
196                                <includes>
197                                    <include>**/it/**</include>
198                                </includes>
199                                <systemPropertyVariables>
200                                    <system.kube.service>
201                                        ${system.kube.service}
202                                    </system.kube.service>
203                                    <system.ip>
204                                        ${system.ip}
205                                    </system.ip>
206                                    <inventory.ip>
207                                        $(inventory.ip)
208                                    </inventory.ip>
209                                    <system.ingress.path>
210                                        ${system.ingress.path}
211                                    </system.ingress.path>
212                                    <inventory.ingress.path>
213                                        ${inventory.ingress.path}
214                                    </inventory.ingress.path>
215                                </systemPropertyVariables>
216                            </configuration>
217                        </execution>
218                        <execution>
219                            <id>verify-results</id>
220                            <goals>
221                                <goal>verify</goal>
222                            </goals>
223                        </execution>
224                    </executions>
225                    <configuration>
226                        <summaryFile>
227                            ${project.build.directory}/test-reports/it/failsafe-summary.xml
228                        </summaryFile>
229                        <reportsDirectory>
230                            ${project.build.directory}/test-reports/it
231                        </reportsDirectory>
232                    </configuration>
233                </plugin>
234            </plugins>
235        </pluginManagement>
236    </build>
237
238    <modules>
239        <module>system</module>
240        <module>inventory</module>
241    </modules>
242
243</project>

A few tests are included for you to test the basic functions of the microservices. If a test failure occurs, then you might have introduced a bug into the code. To run the tests, wait for all pods to be in the ready state before you proceed further. The default properties that are defined in the pom.xml file are:

PropertyDescription

system.ip

IP or hostname of the system-service Kubernetes Service

inventory.ip

IP or hostname of the inventory-service Kubernetes Service

system.kube.service

Name of the Kubernetes Service wrapping the system pods, system-service by default

Use the following command to run the integration tests against your cluster. Substitute [region] and [project-name] with the appropriate values:

mvn verify -Ddockerfile.skip=true \
-Dsystem.ip=system-route-[project-name].apps.[region].starter.openshift-online.com  \
-Dinventory.ip=inventory-route-[project-name].apps.[region].starter.openshift-online.com
  • The dockerfile.skip parameter is set to true to skip building a new container image.

  • The system.ip parameter is replaced with the appropriate hostname to access your system microservice.

  • The inventory.ip parameter is replaced with the appropriate hostname to access your inventory microservice.

If the tests pass, you see an output for each service similar to the following example:

-------------------------------------------------------
 T E S T S
-------------------------------------------------------
Running it.io.openliberty.guides.system.SystemEndpointTest
Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.673 sec - in it.io.openliberty.guides.system.SystemEndpointTest

Results:

Tests run: 2, Failures: 0, Errors: 0, Skipped: 0
-------------------------------------------------------
 T E S T S
-------------------------------------------------------
Running it.io.openliberty.guides.inventory.InventoryEndpointTest
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 2.222 sec - in it.io.openliberty.guides.inventory.InventoryEndpointTest

Results:

Tests run: 1, Failures: 0, Errors: 0, Skipped: 0

Tearing down the environment

When you no longer need your deployed microservices, you can delete the Kubernetes deployments, services, and routes by running the following command:

oc delete -f kubernetes.yaml

To delete the pushed images, run the following commands:

oc delete imagestream/inventory
oc delete imagestream/system

Finally, you can delete the project by running the following command:

oc delete project [project-name]

Great work! You’re done!

You just deployed two microservices running in Open Liberty to OpenShift. You also learned how to use oc to deploy your microservices on a Kubernetes cluster.

Guide Attribution

Deploying microservices to OpenShift by Open Liberty is licensed under CC BY-ND 4.0

Copied to clipboard
Copy code block
Copy file contents

Prerequisites:

Nice work! Where to next?

What did you think of this guide?

Extreme Dislike Dislike Like Extreme Like

What could make this guide better?

Raise an issue to share feedback

Create a pull request to contribute to this guide

Need help?

Ask a question on Stack Overflow

Like Open Liberty? Star our repo on GitHub.

Star