What is the Java client for Kubernetes?

Copy URL

The Kubernetes Java™ client is a client library that enables the use of the Java programming language to interface with Kubernetes. Built on top of the Kubernetes REST API, the Java client provides programmatic access to Kubernetes and grants the ability to create, modify, and delete various resources within a Kubernetes cluster, scale deployments, execute commands, and monitor events. 

Kubernetes is an open source container orchestration platform that automates the deployment, management, and scaling of containerized applications. Kubernetes client libraries can handle tasks like authentication and make it easier for developers to write applications that use the Kubernetes API.

The oldest and most widely used client framework is the official Kubernetes Go client, called client-go. Client-go is used by Kubernetes itself, as well as other distributions and platforms like Red Hat® OpenShift. Other popular clients include both official and community-maintained client libraries for a variety of programming languages. While several community Java clients exist for Kubernetes, the Kubernetes Java client is the official client library maintained by the Kubernetes API Machinery Special Interest Group.

In recent years, developers have moved away from monolithic architectures in favor of more versatile, cloud-native applications. Many organizations looking to modernize legacy Java applications choose to transition to a cloud deployment model. A crucial part of Java application modernization, cloud-native Java often involves the use of a container orchestration platform like Kubernetes to efficiently manage, deploy, and scale applications. 

While containerized applications don’t always need to communicate with the Kubernetes API, there are plenty of use cases where API calls are necessary to accomplish a particular task. If you are taking a DIY approach to managing Kubernetes clusters, rather than using a platform like Red Hat OpenShift and a component like Red Hat Advanced Cluster Management for Kubernetes, you can use the official Java client to talk to the Kubernetes API for the following use cases:

  • Managing applications
  • Scaling and autoscaling
  • Monitoring, alerting, and logging
  • Setting up continuous deployment
  • Extending the Kubernetes API with custom operators
  • Cluster administration
  • Managing your hybrid cloud

Since Kubernetes and many of its tools and libraries are written in Golang, moving to cloud-native development in Kubernetes may require additional training and resources if an organization’s existing developers do not have a Golang background. For organizations with existing Java applications or developers with backgrounds in Java, the Kubernetes Java client eliminates the need to learn a new programming language and simplifies the transition to cloud-native development.

Red Hat resources

Although the official Kubernetes Java client may seem like the best choice for Java developers, there are several other options available to help operate and manage Kubernetes clusters.

Kubernetes REST API & kubectl
The Kubernetes REST API serves as the front end of the Kubernetes control plane and is used to manage, create, and configure Kubernetes clusters. You can interact with the API using the Kubernetes command line tool, kubectl, to make API calls and manage Kubernetes resources. You can also access the REST API directly by using an http client like curl or Wget.

Fabric8 Java Client
The Fabric8 Java client is a community-maintained client library and the oldest Java library for Kubernetes. It differentiates itself from the official Java client by providing a robust domain-specific language (DSL), a variety of extensions, and support for custom resources without the need to add additional dependencies. 

Kubernetes operators
A Kubernetes operator is a custom, application-specific controller that uses the Kubernetes API and kubectl tooling to create, configure, and manage applications. Unlike most controllers, Kubernetes operators include domain or application-specific knowledge to automate the entire lifecycle of a containerized application, making it easier for developers to deploy and scale processes that these applications rely on. 

Other third-party libraries
Although the Fabric8 and official Java clients are the most popular Java libraries for Kubernetes, they are by no means the only options available. Other Java clients include the Amdatu Labs Java client for the OSGI Java framework and the YAKC Java client for Kubernetes.

Alternatively, developers with expertise in other programming language may choose a non-Java client that better suits their needs. Other official and third-party libraries are available for numerous languages including C, dotnet, Haskell, Javascript, Perl, Python, Ruby, and more.

Kubernetes is a powerful open source container orchestration platform, but it lacks the functionality to integrate other components like networking, storage, monitoring, and CI/CD, which are necessary for quicker application development. Red Hat OpenShift builds on Kubernetes and provides an enterprise container orchestration platform while incorporating all of these components and accelerating the delivery of containerized applications.

While you can still use the official Kubernetes Java client and any other Kubernetes libraries, there are other clients available that allow you to take advantage of the additional resources and API endpoints added by Red Hat OpenShift. Like the Kubernetes clients, REST API client libraries for OpenShift are available for Java and numerous other programming languages.

In addition to providing expertise in container technologies, Red Hat can help you overcome the complexity of modernizing applications by automating infrastructure management with a combination of Red Hat OpenShift, Red Hat Ansible Automation Platform, and Kubernetes operators. Red Hat also offers additional tooling for automating application management across multiple clusters and different infrastructures with Red Hat Advanced Cluster Management for Kubernetes, helping you speed up application delivery and modernize your workloads.

Hub

The official Red Hat blog

Get the latest information about our ecosystem of customers, partners, and communities.

All Red Hat product trials

Our no-cost product trials help you gain hands-on experience, prepare for a certification, or assess if a product is right for your organization.

Keep reading

What is container orchestration?

Container orchestration automates the deployment, management, scaling, and networking of containers.

What is Kubernetes?

Kubernetes is a container orchestration platform that eliminates many manual processes involved in deploying and scaling containerized applications.

What are hosted control planes?

Pave the way for a true hybrid-cloud approach that allows smaller nodes to run a control plane, thereby reducing the cost of clusters.

Containers resources

Related articles