Kubernetes 1.19 Ingress API from Java using YAKC


Introduction

Kubernetes v1.19.0 was just released. Amongst the many new features and improvements, the graduation of Ingress API to V1 (#1453) stands out.

Despite users have widely adopted Ingress resources, and that Kubernetes introduced the beta feature back in 2015 (v1.1), it hasn’t been until the new v1.19 release that Ingress has gone GA.

An Ingress is “An API object that manages external access to the services in a cluster, typically HTTP”. In other words, Ingresses are the way to publicly expose your Kubernetes managed Services to the outer world.

In this post, I will show you how to use YAKC to create a new Ingress using the new v1 API introduced in Kubernetes v1.19.0.

An image of a diagram of YAKC interacting with Kubernetes Ingress API

Ingress from Java

You can use Ingresses to provide external reachable URLs, and traffic load balancing to Service resources. In addition, Ingress resources are useful if you want to provide name-based virtual hosting capabilities and SSL termination.

The Ingress resource requires an IngressController to be used. Kubernetes currently officially supports and maintains GCE and NGINX controllers.

Note that Ingress v1 introduces several changes to v1beta1, most notably, the pathType field is now required and no longer provides a default value.

The following YAML describes an Ingress using en existent NGINX IngressController:

You can achieve the exact same result using YAKC:

The main advantage of using Java (YAKC Kubernetes Client) is that you can perform these tasks dynamically. For instance, you can implement a Java-based Operator that will automatically create an Ingress whenever a Service gets created.

Conclusion

Kubernetes 1.19 marks the general availability of Ingress networking.k8s.io/v1. In this post, I’ve shown you how to use YAKC to create an Ingress using Java.

You can learn more by visiting YAKC’s GitHub project site. You can also see related code here.

Leave a comment

Your email address will not be published. Required fields are marked *