Deploying microservices to Kubernetes

duration 25 minutes
Git clone to get going right away:
git clone https://github.com/OpenLiberty/guide-kubernetes-intro.git
Copy Github clone command

Deploy microservices in Open Liberty Docker containers to Kubernetes and manage them with the Kubernetes CLI, kubectl.

What is Kubernetes?

Kubernetes is an open source container orchestrator that automates many tasks involved in deploying, managing, and scaling containerized applications.

Over the years, Kubernetes has become a major tool in containerized environments as containers are being further leveraged for all steps of a continuous delivery pipeline.

Why use Kubernetes?

Managing individual containers can be challenging. A few containers used for development by a small team might not pose a problem, but managing hundreds of containers can give even a large team of experienced developers a headache. Kubernetes is a primary tool for deployment in containerized environments. It handles scheduling, deployment, as well as mass deletion and creation of containers. It provides update rollout abilities on a large scale that would otherwise prove extremely tedious to do. Imagine that you updated a Docker image, which now needs to propagate to a dozen containers. While you could destroy and then re-create these containers, you can also run a short one-line command to have Kubernetes make all those updates for you. Of course, this is just a simple example. Kubernetes has a lot more to offer.

Architecture

Deploying an application to Kubernetes means deploying an application to a Kubernetes cluster.

A typical Kubernetes cluster is a collection of physical or virtual machines called nodes that run containerized applications. A cluster is made up of one master node that manages the cluster, and many worker nodes that run the actual application instances inside Kubernetes objects called pods.

A pod is a basic building block in a Kubernetes cluster. It represents a single running process that encapsulates a container or in some scenarios many closely coupled containers. Pods can be replicated to scale applications and handle more traffic. From the perspective of a cluster, a set of replicated pods is still one application instance, although it might be made up of dozens of instances of itself. A single pod or a group of replicated pods are managed by Kubernetes objects called controllers. A controller handles replication, self-healing, rollout of updates, and general management of pods. One example of a controller that you will use in this guide is a deployment.

A pod or a group of replicated pods are abstracted through Kubernetes objects called services that define a set of rules by which the pods can be accessed. In a basic scenario, a Kubernetes service exposes a node port that can be used together with the cluster IP address to access the pods encapsulated by the service.

To learn about the various Kubernetes resources that you can configure, see the official Kubernetes documentation.

What you’ll learn

You will learn how to deploy two microservices in Open Liberty containers to a local Kubernetes cluster. You will then manage your deployed microservices using the kubectl command line interface for Kubernetes. The kubectl CLI is your primary tool for communicating with and managing your Kubernetes cluster.

The two microservices you will deploy are called system and inventory. The system microservice returns the JVM system properties of the running container and it 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 demonstrates how communication can be established between pods inside a cluster.

You will use a local single-node Kubernetes cluster.

Prerequisites

Before you begin, have the following tools installed:

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

WINDOWS | MAC

Use Docker Desktop, where a local Kubernetes environment is pre-installed and enabled. If you do not see the Kubernetes tab then you have an older version of Docker Desktop; upgrade to the latest version.

Complete the setup for your operating system:

  • Set up Docker for Windows. On the Docker for Windows General Setting page, ensure that the option Expose daemon on tcp://localhost:2375 without TLS is enabled. This is required by the dockerfile-maven part of the build.

  • Set up Docker for Mac.

  • After following one of the sets of instructions, ensure that Kubernetes (not Swarm) is selected as the orchestrator in Docker Preferences.

LINUX

You will use Minikube as a single-node Kubernetes cluster that runs locally in a virtual machine. For Minikube installation instructions see the minikube installation instructions. Make sure to pay attention to the requirements as they vary by platform.

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-kubernetes-intro.git
cd guide-kubernetes-intro

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

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

Starting and preparing your cluster for deployment

Start your Kubernetes cluster.

WINDOWS | MAC

Start your Docker Desktop environment.

LINUX

Run the following command from a command line:

minikube start

Next, validate that you have a healthy Kubernetes environment by running the following command from the command line.

kubectl get nodes

This command should return a Ready status for the master node.

WINDOWS | MAC

You do not need to do any other step.

LINUX

Run the following command to configure the Docker CLI to use Minikube’s Docker daemon. After you run this command, you will be able to interact with Minikube’s Docker daemon and build new images directly to it from your host machine:

eval $(minikube docker-env)

Building and containerizing the microservices

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

The starting Java project, which you can find in the start directory, is a multi-module Maven project that’s made up of the system and inventory microservices. Each microservice resides in its own directory, start/system and start/inventory. Each of these directories also contains a Dockerfile, which is necessary for building Docker images. If you’re unfamiliar with Dockerfiles, check out the Using Docker containers to develop microservices guide, which covers Dockerfiles in depth.

If you’re familiar with Maven and Docker, you might be tempted to run a Maven build first and then use the .war file produced by the build to build a Docker image. While it is by no means a wrong approach, we’ve setup the projects such that this process is automated as a part of a single Maven build. This is done by using the dockerfile-maven plug-in, which automatically picks up the Dockerfile located in the same directory as its POM file and builds a Docker image from it.

Navigate to the start directory and run the following command:

mvn clean package

The package goal automatically invokes the dockerfile-maven:build goal, which runs during the package phase. This goal builds a Docker image from the Dockerfile located in the same directory as the POM file.

During the build, you’ll see various Docker messages describing 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:

WINDOWS | MAC

REPOSITORY                                                       TAG
inventory                                                        1.0-SNAPSHOT
system                                                           1.0-SNAPSHOT
open-liberty                                                     latest
k8s.gcr.io/kube-proxy-amd64                                      v1.10.3
k8s.gcr.io/kube-scheduler-amd64                                  v1.10.3
k8s.gcr.io/kube-controller-manager-amd64                         v1.10.3
k8s.gcr.io/kube-apiserver-amd64                                  v1.10.3
k8s.gcr.io/etcd-amd64                                            3.1.12
k8s.gcr.io/k8s-dns-dnsmasq-nanny-amd64                           1.14.8
k8s.gcr.io/k8s-dns-sidecar-amd64                                 1.14.8
k8s.gcr.io/k8s-dns-kube-dns-amd64                                1.14.8
k8s.gcr.io/pause-amd64                                           3.1

LINUX

REPOSITORY                                                       TAG
inventory                                                        1.0-SNAPSHOT
system                                                           1.0-SNAPSHOT
open-liberty                                                     latest
k8s.gcr.io/kube-proxy-amd64                                      v1.10.0
k8s.gcr.io/kube-controller-manager-amd64                         v1.10.0
k8s.gcr.io/kube-apiserver-amd64                                  v1.10.0
k8s.gcr.io/kube-scheduler-amd64                                  v1.10.0
quay.io/kubernetes-ingress-controller/nginx-ingress-controller   0.12.0
k8s.gcr.io/etcd-amd64                                            3.1.12
k8s.gcr.io/kube-addon-manager                                    v8.6
k8s.gcr.io/k8s-dns-dnsmasq-nanny-amd64                           1.14.8
k8s.gcr.io/k8s-dns-sidecar-amd64                                 1.14.8
k8s.gcr.io/k8s-dns-kube-dns-amd64                                1.14.8
k8s.gcr.io/pause-amd64                                           3.1
k8s.gcr.io/kubernetes-dashboard-amd64                            v1.8.1
k8s.gcr.io/kube-addon-manager                                    v6.5
gcr.io/k8s-minikube/storage-provisioner                          v1.8.0
gcr.io/k8s-minikube/storage-provisioner                          v1.8.1
k8s.gcr.io/defaultbackend                                        1.4
k8s.gcr.io/k8s-dns-sidecar-amd64                                 1.14.4
k8s.gcr.io/k8s-dns-kube-dns-amd64                                1.14.4
k8s.gcr.io/k8s-dns-dnsmasq-nanny-amd64                           1.14.4
k8s.gcr.io/etcd-amd64                                            3.0.17
k8s.gcr.io/pause-amd64                                           3.0

If you don’t see the system:1.0-SNAPSHOT and inventory:1.0-SNAPSHOT images, then check the Maven build log for any potential errors. In addition, if you are using Minikube, make sure your Docker CLI is configured to use Minikube’s Docker daemon and not your host’s as described in the previous section.

Deploying the microservices

Now that your Docker images are built, deploy them using a Kubernetes resource definition.

A Kubernetes resource definition is a yaml file that contains a description of all your deployments, services, or any other resources that you want to deploy. All resources can also be deleted from the cluster by using the same yaml file that you used to deploy them.

Create the Kubernetes configuration file.
kubernetes.yaml

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        image: system:1.0-SNAPSHOT
19        ports:
20        - containerPort: 9080
21---
22apiVersion: apps/v1
23kind: Deployment
24metadata:
25  name: inventory-deployment
26  labels:
27    app: inventory
28spec:
29  selector:
30    matchLabels:
31      app: inventory
32  template:
33    metadata:
34      labels:
35        app: inventory
36    spec:
37      containers:
38      - name: inventory-container
39        image: inventory:1.0-SNAPSHOT
40        ports:
41        - containerPort: 9080
42---
43apiVersion: v1
44kind: Service
45metadata:
46  name: system-service
47spec:
48  type: NodePort
49  selector:
50    app: system
51  ports:
52  - protocol: TCP
53    port: 9080
54    targetPort: 9080
55    nodePort: 31000
56---
57apiVersion: v1
58kind: Service
59metadata:
60  name: inventory-service
61spec:
62  type: NodePort
63  selector:
64    app: inventory
65  ports:
66  - protocol: TCP
67    port: 9080
68    targetPort: 9080
69    nodePort: 32000

This file defines four Kubernetes resources. It defines two deployments and two services. A Kubernetes deployment is a resource responsible for controlling the creation and management of pods. A service exposes your deployment so that you can make requests to your containers. Three key items to look at when creating the deployments are the label, image, and containerPort fields. The label is a way for a Kubernetes service to reference specific deployments. The image is the name and tag of the docker image that you want to use for this container. Finally, the containerPort is the port that your container exposes for purposes of accessing your application. For the services, the key point to understand is that they expose your deployments. The binding between deployments and services is specified by the use of labels — in this case the app label. You will also notice the service has a type of NodePort. This means you can access these services from outside of your cluster via a specific port. In this case, the ports will be 31000 and 32000, but it can also be randomized if the nodePort field is not used.

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

kubectl apply -f kubernetes.yaml

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

kubectl get pods

You’ll see an output similar to the following if all the pods are healthy and running:

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

You can also inspect individual pods in more detail by running the following command:

kubectl describe pods

You can also issue the kubectl get and kubectl describe commands on other Kubernetes resources, so feel free to inspect all other resources.

Next you will make requests to your services.

WINDOWS | MAC

The default host name for Docker Desktop is localhost.

LINUX

The default host name for minikube is 192.168.99.100. Otherwise it can be found using the minikube ip command.

Then curl or visit the following URLs to access your microservices, substituting the appropriate host name:

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

  • http://[hostname]:32000/inventory/systems/system-service

The first URL returns system properties and the name of the pod in an HTTP header called X-Pod-Name. To view the header, you may use the -I option in the curl when making a request to http://[hostname]:31000/system/properties. The second URL adds properties from system-service to the inventory. Kubernetes Service. Visiting http://[hostname]:32000/inventory/systems/[kube-service] in general adds to the inventory depending on whether kube-service is a valid Kubernetes Service that can be accessed.

Scaling a deployment

To use load balancing, you need to scale your deployments. When you scale a deployment, you replicate its pods, creating more running instances of your applications. Scaling is one of the primary advantages of Kubernetes because replicating your application allows it to accommodate more traffic, and then descale your deployments to free up resources when the traffic decreases.

As an example, scale the system Deployment to three pods by running the following command:

kubectl scale deployment/system-deployment --replicas=3

Use the following command to verify that two new pods have been created.

kubectl get pods
NAME                                    READY     STATUS    RESTARTS   AGE
system-deployment-6bd97d9bf6-4ccds      1/1       Running   0          1m
system-deployment-6bd97d9bf6-jf9rs      1/1       Running   0          25s
system-deployment-6bd97d9bf6-x4zth      1/1       Running   0          25s
inventory-deployment-645767664f-nbtd9   1/1       Running   0          1m

Wait for your two new pods to be in the ready state, then curl -I or visit the http://[hostname]:31000/system/properties URL. You’ll notice that the X-Pod-Name header will have a different value when you call it multiple times. This is because there are now three pods running all serving the system application. Similarly, to descale your deployments you can use the same scale command with fewer replicas.

Redeploy microservices

When you’re building your application, you may find that you want to quickly test a change. To do that, you can rebuild your docker images then delete and re-create your Kubernetes resources. Note that there will only be one system pod after you redeploy since you’re deleting all of the existing pods.

mvn clean package
kubectl delete -f kubernetes.yaml
kubectl apply -f kubernetes.yaml

This is not how you would want to update your applications when running in production, but in a development environment this is fine. If you want to deploy an updated image to a production cluster, you can update the container in your deployment with a new image. Then, Kubernetes will automate the creation of a new container and decommissioning of the old one once the new container is ready.

Testing microservices that are running on Kubernetes

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.dockerfile-maven-plugin>1.4.10</version.dockerfile-maven-plugin>
 27        <version.exec-maven-plugin>1.6.0</version.exec-maven-plugin>
 28        <version.maven-surefire-plugin>3.0.0-M1</version.maven-surefire-plugin>
 29        <version.maven-failsafe-plugin>3.0.0-M1</version.maven-failsafe-plugin>
 30        <!-- OpenLiberty runtime -->
 31        <version.openliberty-runtime>RELEASE</version.openliberty-runtime>
 32        <http.port>9080</http.port>
 33        <https.port>9443</https.port>
 34        <!-- Default test properties -->
 35        <cluster.ip>localhost</cluster.ip>
 36        <system.kube.service>system-service</system.kube.service>
 37        <system.node.port>31000</system.node.port>
 38        <inventory.node.port>32000</inventory.node.port>
 39    </properties>
 40
 41    <dependencyManagement>
 42        <dependencies>
 43           <dependency>
 44               <groupId>io.openliberty.features</groupId>
 45               <artifactId>features-bom</artifactId>
 46               <version>RELEASE</version>
 47               <type>pom</type>
 48               <scope>import</scope>
 49           </dependency>
 50           <dependency>
 51                <groupId>org.eclipse.microprofile.rest.client</groupId>
 52                <artifactId>microprofile-rest-client-api</artifactId>
 53                <version>1.0.1</version>
 54                <scope>provided</scope>
 55            </dependency>
 56            <dependency>
 57                <groupId>junit</groupId>
 58                <artifactId>junit</artifactId>
 59                <version>4.12</version>
 60                <scope>test</scope>
 61            </dependency>
 62            <dependency>
 63                <groupId>org.glassfish</groupId>
 64                <artifactId>javax.json</artifactId>
 65                <version>1.0.4</version>
 66                <scope>test</scope>
 67            </dependency>
 68            <dependency>
 69                <groupId>org.apache.cxf</groupId>
 70                <artifactId>cxf-rt-rs-extension-providers</artifactId>
 71                <version>3.2.6</version>
 72                <scope>test</scope>
 73            </dependency>
 74            <dependency>
 75                <groupId>org.apache.cxf</groupId>
 76                <artifactId>cxf-rt-rs-client</artifactId>
 77                <version>3.2.6</version>
 78                <scope>test</scope>
 79            </dependency>
 80            <dependency>
 81                <groupId>org.apache.commons</groupId>
 82                <artifactId>commons-lang3</artifactId>
 83                <version>3.0</version>
 84                <scope>compile</scope>
 85            </dependency>
 86            <!-- Support for JDK 9 and above -->
 87            <dependency>
 88                <groupId>javax.xml.bind</groupId>
 89                <artifactId>jaxb-api</artifactId>
 90                <version>2.3.1</version>
 91            </dependency>
 92        </dependencies>
 93    </dependencyManagement>
 94
 95    <profiles>
 96        <profile>
 97            <id>windowsExtension</id>
 98            <activation>
 99                <os><family>Windows</family></os>
100            </activation>
101            <properties>
102                <kubectl.extension>.cmd</kubectl.extension>
103            </properties>
104        </profile>
105        <profile>
106            <id>nonWindowsExtension</id>
107            <activation>
108                <os><family>!Windows</family></os>
109            </activation>
110            <properties>
111                <kubectl.extension></kubectl.extension>
112            </properties>
113        </profile>
114    </profiles>
115
116    <build>
117        <pluginManagement>
118            <plugins>
119                <plugin>
120                    <groupId>org.apache.maven.plugins</groupId>
121                    <artifactId>maven-war-plugin</artifactId>
122                    <version>${version.maven-war-plugin}</version>
123                    <configuration>
124                        <failOnMissingWebXml>false</failOnMissingWebXml>
125                        <packagingExcludes>pom.xml</packagingExcludes>
126                    </configuration>
127                </plugin>
128                <plugin>
129                    <groupId>net.wasdev.wlp.maven.plugins</groupId>
130                    <artifactId>liberty-maven-plugin</artifactId>
131                    <configuration>
132                        <assemblyArtifact>
133                            <groupId>io.openliberty</groupId>
134                            <artifactId>openliberty-runtime</artifactId>
135                            <version>RELEASE</version>
136                            <type>zip</type>
137                        </assemblyArtifact>
138                    </configuration>
139                </plugin>
140                <plugin>
141                    <groupId>com.spotify</groupId>
142                    <artifactId>dockerfile-maven-plugin</artifactId>
143                    <version>${version.dockerfile-maven-plugin}</version>
144                    <executions>
145                        <execution>
146                            <id>default</id>
147                            <goals>
148                                <goal>build</goal>
149                            </goals>
150                        </execution>
151                    </executions>
152                    <configuration>
153                        <repository>${project.artifactId}</repository>
154                        <tag>${project.version}</tag>
155                    </configuration>
156                </plugin>
157                <!-- Plugin to run unit tests -->
158                <plugin>
159                    <groupId>org.apache.maven.plugins</groupId>
160                    <artifactId>maven-surefire-plugin</artifactId>
161                    <version>${version.maven-surefire-plugin}</version>
162                    <executions>
163                        <execution>
164                            <phase>test</phase>
165                            <id>default-test</id>
166                            <configuration>
167                                <excludes>
168                                    <exclude>**/it/**</exclude>
169                                </excludes>
170                                <reportsDirectory>
171                                    ${project.build.directory}/test-reports/unit
172                                </reportsDirectory>
173                            </configuration>
174                        </execution>
175                    </executions>
176                </plugin>
177                <!-- Plugin to run functional tests -->
178                <plugin>
179                    <groupId>org.apache.maven.plugins</groupId>
180                    <artifactId>maven-failsafe-plugin</artifactId>
181                    <version>${version.maven-failsafe-plugin}</version>
182                    <executions>
183                        <execution>
184                            <phase>integration-test</phase>
185                            <id>integration-test</id>
186                            <goals>
187                                <goal>integration-test</goal>
188                            </goals>
189                            <configuration>
190                                <includes>
191                                    <include>**/it/**</include>
192                                </includes>
193                                <systemPropertyVariables>
194                                    <cluster.ip>${cluster.ip}</cluster.ip>
195                                    <system.ingress.path>
196                                        ${system.ingress.path}
197                                    </system.ingress.path>
198                                    <system.node.port>
199                                        ${system.node.port}
200                                    </system.node.port>
201                                    <system.kube.service>
202                                        ${system.kube.service}
203                                    </system.kube.service>
204                                    <inventory.ingress.path>
205                                        ${inventory.ingress.path}
206                                    </inventory.ingress.path>
207                                    <inventory.node.port>${inventory.node.port}</inventory.node.port>
208                                </systemPropertyVariables>
209                            </configuration>
210                        </execution>
211                        <execution>
212                            <id>verify-results</id>
213                            <goals>
214                                <goal>verify</goal>
215                            </goals>
216                        </execution>
217                    </executions>
218                    <configuration>
219                        <summaryFile>
220                            ${project.build.directory}/test-reports/it/failsafe-summary.xml
221                        </summaryFile>
222                        <reportsDirectory>
223                            ${project.build.directory}/test-reports/it
224                        </reportsDirectory>
225                    </configuration>
226                </plugin>
227            </plugins>
228        </pluginManagement>
229    </build>
230
231    <modules>
232        <module>system</module>
233        <module>inventory</module>
234    </modules>
235
236</project>

A few tests are included for you to test the basic functionality 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 proceeding further. The default properties defined in the pom.xml are:

PropertyDescription

cluster.ip

IP or host name for your cluster, localhost by default, which is appropriate when using Docker Desktop.

system.kube.service

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

system.node.port

The NodePort of the Kubernetes Service system-service, 31000 by default.

inventory.node.port

The NodePort of the Kubernetes Service inventory-service, 32000 by default.

Navigate back to the start directory.

WINDOWS | MAC

Run the integration tests against a cluster running with a host name of localhost:

mvn verify -Ddockerfile.skip=true

LINUX

Run the integration tests with the IP address for Minikube:

mvn verify -Ddockerfile.skip=true -Dcluster.ip=`minikube ip`

The dockerfile.skip parameter is set to true in order to skip building a new Docker image.

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

-------------------------------------------------------
 T E S T S
-------------------------------------------------------
Running it.io.openliberty.guides.system.SystemEndpointTest
Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.567 s - 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: 0.893 s - 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 all Kubernetes resources by running the kubectl delete command:

kubectl delete -f kubernetes.yaml

WINDOWS | MAC

Nothing more needs to be done for Docker Desktop.

LINUX

Perform the following steps to return your environment to a clean state.

  1. Point the Docker daemon back to your local machine:

    eval $(minikube docker-env -u)
  2. Stop your Minikube cluster:

    minikube stop
  3. Delete your cluster:

    minikube delete

Great work! You’re done!

You have just deployed two microservices running in Open Liberty to Kubernetes. You then scaled a microservice and ran integration tests against miroservices that are running in a Kubernetes cluster.

Guide Attribution

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

Copied to clipboard
Copy code block
Copy file contents
Git clone this repo to get going right away:
git clone https://github.com/OpenLiberty/guide-kubernetes-intro.git
Copy github clone command
Copied to clipboard

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