A logo showing the text blog.marcnuri.com
Español
Home»Java»Kubernetes 1.19 Ingress API from Java using YAKC

Recent Posts

  • Fabric8 Kubernetes Client 7.2 is now available!
  • Connecting to an MCP Server from JavaScript using AI SDK
  • Connecting to an MCP Server from JavaScript using LangChain.js
  • The Future of Developer Tools: Adapting to Machine-Based Developers
  • Connecting to a Model Context Protocol (MCP) Server from Java using LangChain4j

Categories

  • Artificial Intelligence
  • Front-end
  • Go
  • Industry and business
  • Java
  • JavaScript
  • Legacy
  • Operations
  • Personal
  • Pet projects
  • Tools

Archives

  • May 2025
  • April 2025
  • March 2025
  • February 2025
  • January 2025
  • December 2024
  • November 2024
  • August 2024
  • June 2024
  • May 2024
  • April 2024
  • March 2024
  • February 2024
  • January 2024
  • December 2023
  • November 2023
  • October 2023
  • September 2023
  • August 2023
  • July 2023
  • June 2023
  • May 2023
  • April 2023
  • March 2023
  • February 2023
  • January 2023
  • December 2022
  • November 2022
  • October 2022
  • September 2022
  • August 2022
  • July 2022
  • June 2022
  • May 2022
  • March 2022
  • February 2022
  • January 2022
  • December 2021
  • November 2021
  • October 2021
  • September 2021
  • August 2021
  • July 2021
  • January 2021
  • December 2020
  • November 2020
  • October 2020
  • September 2020
  • August 2020
  • July 2020
  • June 2020
  • May 2020
  • February 2020
  • January 2020
  • December 2019
  • October 2019
  • September 2019
  • July 2019
  • March 2019
  • November 2018
  • July 2018
  • June 2018
  • May 2018
  • April 2018
  • March 2018
  • February 2018
  • December 2017
  • July 2017
  • January 2017
  • December 2015
  • November 2015
  • December 2014
  • March 2014
  • February 2011
  • November 2008
  • June 2008
  • May 2008
  • April 2008
  • January 2008
  • November 2007
  • September 2007
  • August 2007
  • July 2007
  • June 2007
  • May 2007
  • April 2007
  • March 2007

Kubernetes 1.19 Ingress API from Java using YAKC

2020-08-30 in Java tagged Client / Cloud / Ingress / Java / Kubernetes / OpenShift / YAKC by Marc Nuri | Last updated: 2021-05-23
Versión en Español

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
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:

1apiVersion: networking.k8s.io/v1
2kind: Ingress
3metadata:
4 name: ingress-example
5 namespace: default
6spec:
7 ingressClassName: nginx
8 rules:
9   - host: "*.foo.com"
10     http:
11       paths:
12         - path: /
13           pathType: Exact
14           backend:
15             serviceName: path-exact
16             servicePort: 80

You can achieve the exact same result using YAKC:

1new KubernetesClient().create(NetworkingV1Api.class).createNamespacedIngress("default", Ingress.builder()
2  .metadata(ObjectMeta.builder()
3    .name("ingress-example")
4    .build())
5  .spec(IngressSpec.builder()
6    .addToRules(IngressRule.builder()
7      .host("*.foo.com")
8      .http(HTTPIngressRuleValue.builder()
9        .addToPaths(HTTPIngressPath.builder()
10          .path("/")
11          .pathType("Exact")
12          .backend(IngressBackend.builder()
13            .service(IngressServiceBackend.builder()
14              .name("path-exact")
15              .port(ServiceBackendPort.builder()
16                .number(80)
17                .build())
18              .build())
19            .build())
20          .build())
21        .build())
22      .build())
23    .build())
24  .build()
25).get();

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.

Twitter iconFacebook iconLinkedIn iconPinterest iconEmail icon

Post navigation
React + Quarkus integration using MavenQuarkus + JKube: Qute template with markdown processing from different sources
© 2007 - 2025 Marc Nuri