The two microservices you will deploy are called
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. To build these applications, navigate to the
start directory and run the following command.
mvn clean package
Run the following command to download or update to the latest Open Liberty Docker image:
docker pull openliberty/open-liberty:kernel-java8-openj9-ubi
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/.
-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.
Run the following command to deploy the necessary Kubernetes resources to serve the applications.
kubectl apply -f kubernetes.yaml
When this command finishes, wait for the pods to be in the Ready state. Run the following command to view the status of the pods.
When the pods are ready, the output shows
1/1 for READY and
Running for STATUS.
NAME READY STATUS RESTARTS AGE
system-deployment-6bd97d9bf6-6d2cj 1/1 Running 0 34s
inventory-deployment-645767664f-7gnxf 1/1 Running 0 34s
After the pods are ready, you will make requests to your services.
The default host name for Docker Desktop is
The default host name for minikube is 192.168.99.100. Otherwise it can be found using the
minikube ip command.
http://[hostname]:31000/system/properties and use the user name
bob and the password
bobpwd to authenticate. Replace
[hostname] with the IP address or host name of your Kubernetes cluster. Open your browser’s developer console and examine the response headers.
You can also run the
curl command to make requests to your microservices. To view the header, you may use the
-I option in the
curl command when making a request to
http://[hostname]:31000/system/properties. Use the
-u option to pass in the user name
bob and the password
curl http://localhost:31000/system/properties -u bob:bobpwd -I
curl http://`minikube ip`:31000/system/properties -u bob:bobpwd -I
Observe that the
X-App-Name header currently has the value
Similarly, navigate to
http://[hostname]:32000/inventory/systems/system-service, or use the following
curl command, to add the system to your inventory.
curl http://`minikube ip`:32000/inventory/systems/system-service