DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Please enter at least three characters to search
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

The software you build is only as secure as the code that powers it. Learn how malicious code creeps into your software supply chain.

Apache Cassandra combines the benefits of major NoSQL databases to support data management needs not covered by traditional RDBMS vendors.

Generative AI has transformed nearly every industry. How can you leverage GenAI to improve your productivity and efficiency?

Modernize your data layer. Learn how to design cloud-native database architectures to meet the evolving demands of AI and GenAI workloads.

Related

  • Using Python Libraries in Java
  • Java's Quiet Revolution: Thriving in the Serverless Kubernetes Era
  • Fixing OutOfMemoryErrors in Java Applications
  • SRE Best Practices for Java Applications

Trending

  • FIPS 140-3: The Security Standard That Protects Our Federal Data
  • Cloud Security and Privacy: Best Practices to Mitigate the Risks
  • DGS GraphQL and Spring Boot
  • Automating Data Pipelines: Generating PySpark and SQL Jobs With LLMs in Cloudera
  1. DZone
  2. Software Design and Architecture
  3. Cloud Architecture
  4. Deploying Python and Java Applications to Kubernetes With Korifi

Deploying Python and Java Applications to Kubernetes With Korifi

Tutorial covering the installation and configuration of Cloud Foundry Korifi to push a Java and Python application to Kubernetes with a single command.

By 
Sylvain Kalache user avatar
Sylvain Kalache
·
Aug. 11, 23 · Tutorial
Likes (6)
Comment
Save
Tweet
Share
8.2K Views

Join the DZone community and get the full member experience.

Join For Free

Open-source Cloud Foundry Korifi is designed to provide developers with an efficient approach to delivering and managing cloud-native applications on Kubernetes with automated networking, security, availability, and more. With Korifi, the simplicity of the cf push command is now available on Kubernetes.

In this tutorial, I will walk you through the installation of Korifi on kind using a locally deployed container registry. The installation process happens in two steps:

  1. Installation of prerequisites
  2. Installation of Korifi and dependencies

Then, we will deploy two applications developed in two very different programming languages: Java and Python. This tutorial has been tested on Ubuntu Server 22.04.2 LTS.

Let's dive in!

Installing Prerequisites

There are several prerequisites needed to install Korifi. There is a high chance that Kubernetes users will already have most of them installed.

Here is the list of prerequisites:

  • Cf8 cli
  • Docker
  • Go
  • Helm
  • Kbld
  • Kind
  • Kubectl
  • Make

To save time, I wrote a Bash script that installs the correct version of prerequisites for you. You can download it and run it by running the two commands below.

Shell
 
git clone https://github.com/sylvainkalache/korifi-prerequisites-installation
cd korifi-prerequisites-installation && ./install-korifi-prerequisites.sh


Installing Korifi

The Korifi development team maintains an installation script to install Korifi on a kind cluster. It installs the required dependencies and a local container registry. This method is especially recommended if you are trying Korifi for the first time.

Shell
 
git clone https://github.com/cloudfoundry/korifi
cd korifi/scripts && ./deploy-on-kind.sh korifi-cluster


The install script does the following:

  • Creates a kind cluster with the correct port mappings for Korifi
  • Deploys a local Docker registry using the twuni helm chart
  • Creates an admin user for Cloud Foundry
  • Installs cert-manager to create and manage internal certificates within the cluster
  • Installs kpack, which is used to build runnable applications from source code using Cloud Native Buildpacks
  • Installs contour, which is the ingress controller for Korifi
  • Installs the service binding runtime, which is an implementation of the service binding spec
  • Installs the metrics server
  • Installs Korifi

Similar to installing prerequisites, you can always do this manually by following the installation instructions.

Setting up Your Korifi Instance

Before deploying our application to Kubernetes, we must sign into our Cloud Foundry instance. This will set up a tenant, known as a target, to which our apps can be deployed.

Authenticate with the Cloud FoundryAPI:

Shell
 
cf api https://localhost --skip-ssl-validation
cf auth cf-admin


Create an Org and a Space.

Shell
 
cf create-org tutorial-org
cf create-space -o tutorial-org tutorial-space


Target the Org and Space you created.

Shell
 
cf target -o tutorial-org -s tutorial-space


Everything is ready; let’s deploy two applications to Kubernetes. 

Single-Command Deployment to Kubernetes

Deploying a Java Application

For the sake of the tutorial, I am using a sample Java app, but you feel free to try it out on your own.

Shell
 
git clone https://github.com/sylvainkalache/sample-web-apps
cd sample-web-apps/java


Once you are inside your application repository, run the following command. Note that the first run of this command will take a while as it needs to install language dependencies from the requirements.txt and create a runnable container image. But all subsequent updates will be much faster:

Shell
 
cf push my-java-app


That’s it! The application has been deployed to Kubernetes. To check the application status, you can simply use the following command:

Shell
 
cf app my-java-app


Which will return an output similar to this:

Showing health and status for app my-java-app in org tutorial-org / space tutorial-space as cf-admin...

Shell
 
Showing health and status for app my-java-app in org tutorial-org / space tutorial-space as cf-admin...

name:              my-java-app
requested state:   started
routes:            my-java-app.apps-127-0-0-1.nip.io
last uploaded:     Tue 25 Jul 19:14:34 UTC 2023
stack:             io.buildpacks.stacks.jammy
buildpacks:

type:           web
sidecars:
instances:      1/1
memory usage:   1024M
     state     since                  cpu    memory        disk      logging      details
#0   running   2023-07-25T20:46:32Z   0.1%   16.1M of 1G   0 of 1G   0/s of 0/s

type:           executable-jar
sidecars:
instances:      0/0
memory usage:   1024M
There are no running instances of this process.

type:           task
sidecars:
instances:      0/0
memory usage:   1024M
There are no running instances of this process.


Within this helpful information, we can see the app URL of our app and the fact that it is properly running. 

You can double-check that the application is properly responding using curl:

Shell
 
curl -I --insecure https://my-java-app.apps-127-0-0-1.nip.io/


And you should get an HTTP 200 back. 

Shell
 
HTTP/2 200
date: Tue, 25 Jul 2023 20:47:07 GMT
x-envoy-upstream-service-time: 134
vary: Accept-Encoding
server: envoy


Deploying a Python Application

Next, we will deploy a simple Python Flask application. While we could deploy a Java application directly, there is an additional step for a Python one. Indeed, we need to provide a Buildpack that Korifi can use for Python applications – a more detailed explanation is available in the documentation. 

Korifi uses Buildpacks to transform your application source code into images that are eventually pushed to Kubernetes. The Paketo open-source project provides base production-ready Buildpacks for the most popular languages and frameworks. In this example, I will use the Python Paketo Buildpacks as the base Buildpacks. 

Let’s start by adding the Buildpacks source to our ClusterStore by running the following command:

Shell
 
kubectl edit clusterstore cf-default-buildpacks -n tutorial-space


Then add the line  - image: gcr.io/paketo-buildpacks/python, your file should look like this:

Shell
 
spec:
  sources:
  - image: gcr.io/paketo-buildpacks/java
  - image: gcr.io/paketo-buildpacks/nodejs
  - image: gcr.io/paketo-buildpacks/ruby
  - image: gcr.io/paketo-buildpacks/procfile
  - image: gcr.io/paketo-buildpacks/go
  - image: gcr.io/paketo-buildpacks/python


Then we need to specify when to use these Buildbacks by editing our ClusterBuilder. Execute the following command:

Shell
 
kubectl edit clusterbuilder cf-kpack-cluster-builder -n tutorial-space


Add the line - id: paketo-buildpacks/python at the top of the spec order list. your file should look like this:

Shell
 
spec:
  order:
  - group:
    - id: paketo-buildpacks/python
  - group:
    - id: paketo-buildpacks/java
  - group:
    - id: paketo-buildpacks/go
  - group:
    - id: paketo-buildpacks/nodejs
  - group:
    - id: paketo-buildpacks/ruby
  - group:
    - id: paketo-buildpacks/procfile


That’s it! 

Now you can either bring your own Python app or use this sample one by running the following commands:

Shell
 
git clone https://github.com/sylvainkalache/sample-web-apps
cd sample-web-apps/python


And deploy it:

Shell
 
cf push my-python-app


Run curl to make sure the app is responding:

Shell
 
curl --insecure https://my-python-app.apps-127-0-0-1.nip.io/dzone


Curl should return the following output:

Shell
 
Hello world!
Python version: 3.10.12


Video 


Conclusion

As you can see, Korifi makes deploying applications to Kubernetes very easy. While Java and Python are two very different stacks, the shipping experience remains the same. Korifi supports many other languages like Go, Ruby, PHP, Node.js, and more.

Cloud Foundry Kubernetes applications Java (programming language) Python (language)

Opinions expressed by DZone contributors are their own.

Related

  • Using Python Libraries in Java
  • Java's Quiet Revolution: Thriving in the Serverless Kubernetes Era
  • Fixing OutOfMemoryErrors in Java Applications
  • SRE Best Practices for Java Applications

Partner Resources

×

Comments
Oops! Something Went Wrong

The likes didn't load as expected. Please refresh the page and try again.

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends:

Likes
There are no likes...yet! 👀
Be the first to like this post!
It looks like you're not logged in.
Sign in to see who liked this post!