Deploy Java apps on the IBM Cloud Kubernetes service

The other day, I was told to do hands-on in the title, so I will write the procedure before I forget it. What I want to do is create a Docker image with OpenLiberty from my Java app (which is a war file) and deploy that image on the IBM Cloud. This time, you can also create a light account for free, so even beginners should definitely try it.

image.png

The procedure is

  1. Create a Kubernetes cluster on IBM Cloud
  2. Create a local Docker Docker image and upload it to Docker Hub
  3. Deploy on IBM Cloud Kubernetes service

The app (servant) is extremely simple, but you should be able to create complex apps.

image.png

  1. Create a Kubernetes cluster on IBM Cloud This was made with reference to this. https://cloud.ibm.com/docs/containers?topic=containers-cs_cluster_tutorial&locale=ja I did it with a free cluster that can be created with a light account.

  2. Create a local Docker Docker image and upload it to Docker Hub Run the following command on your PC or MAC Download the Open Liberty Docker image $ docker image pull open-liberty

Next, create a Dockerfile with the following contents

FROM open-liberty COPY ./book-deploy.war /config/dropins/book-deploy.war


Place the war file in the same folder and create a Docker image of open liberty-handson with the following command. $ docker build . openliberty-handson

Upload to Docker Hub if you can $ docker tag openliberty-handson / openliberty-handson $ docker push username / openliberty-handson Confirm that it has been uploaded image.png

  1. Deploy on IBM Cloud Kubernetes service After logging in to IBM cloud, create a Deployment and service with the following command. $ Kubectl run liberty --image = / openliberty-handson $ kubectl expose deployment liberty --type="NodePort" --port=9080

It's done. Next, check the IP address and port number and access from a browser. IP address is $ ibmcloud cs workers This is the public address that came out in. The port number is $ kubectl get service liberty The second number of Port (s) that appears in is the number in the 30000s.

Let's access it with a browser!

Recommended Posts

Deploy Java apps on the IBM Cloud Kubernetes service
Deploy Java programs on SAP Cloud Platform
[Java] Deploy the Spring Boot application to Azure App Service
Try Quarkus on IBM Cloud Shell
Consideration on the 2017 Java Persistence Framework (1)
Try using the service on Android Oreo
Kick ShellScript on the server from Java
Deploy Java Servlet app locally on Tomcat
Try calling the CORBA service in Java 11+
Build Java 8 development environment on AWS Cloud9
Looking back on the basics of Java
Deploy a Java web app on Heroku
Execute Java code stored on the clipboard.
Install the IBM Cloud CLI in the container
Create Java applications with IBM Cloud Functions
Try using Firebase Cloud Functions on Android (Java)
Try Azure Service Fabric (Java) on Mac-Local Environment
Try calling the CORBA service from Spring (Java)
Compile and run Java on the command line
I touched on the new features of Java 15
[Java] Memo on how to write the source
I tried running a DB access application on IKS + Db2 on IBM Cloud (6. Preparation of DB access application (java))