question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to create ingress in Kubernetes V1.23.1 version ?

See original GitHub issue

I referred to the sample code, but it did not compile successfully. I am using Kubernetes-Client version 5.12.1

Ingress ingress = new IngressBuilder() .withNewMetadata().withName("test-ingress").addToAnnotations("nginx.ingress.kubernetes.io/rewrite-target", "/").endMetadata() .withNewSpec() .addNewRule() .withNewHttp() .addNewPath() .withPath("/testPath").withNewBackend().withServiceName("test").withServicePort(new IntOrString(80)).endBackend() .endPath() .endHttp() .endRule() .endSpec() .build(); client.network().ingress().inNamespace("default").create(ingress);

But I compiled successfully in V4.12.0 using the following methods: client.extensions().ingresses().createorreplace (ingress);

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
fengqiao117commented, Jun 3, 2022

Resolved,Modify the code as follows: import io.fabric8.kubernetes.api.model.networking.v1.Ingress; import io.fabric8.kubernetes.api.model.networking.v1.IngressBuilder;

thanks!

1reaction
shawkinscommented, Apr 1, 2022

The error message is related to PUT performed by createOrReplace. See #3896 and related issues. Fabric8 6 will have basic support for server side apply #3334 - until then you may want to use something like:

// build the ingress keeping the other parts of the existing spec
Ingress buildOrEdit(IngressBuilder builder) {
  return builder.withNewMetadata().withName("test-ingress").addToAnnotations("nginx.ingress.kubernetes.io/rewrite-target", "/").endMetadata()
                .editOrNewSpec()
                .withRules(new IngressRuleBuilder()
                .withNewHttp()
                .addNewPath().withPathType("Prefix")
                .withPath("/"+"fims-web"+"/(.+)").withBackend(new IngressBackend())
                .endPath()
                .endHttp()
                .build())
                .endSpec()
                .build();
}

var ingresses = client.network().v1().ingresses().inNamespace("default");

try {
  ingresses.edit(i -> buildOrEdit(new IngressBuilder(i)));
} catch (KubernetesClientException e) {
  if (e.getCode() != 404) {
    throw e;
  }
  ingresses.create(buildOrEdit(new IngressBuilder());
}

This avoids a PUT on replace and when the diff is computed for an edit the buildOrEdit function will make sure that generated fields are retained.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Ingress - Kubernetes
An API object that manages external access to the services in a cluster, typically HTTP. Ingress may provide load balancing, SSL termination ...
Read more >
Kubernetes 1.23: The Next Frontier
Kubernetes releases now generate provenance attestation files describing the staging and release phases of the release process.
Read more >
Updating NGINX-Ingress to use the stable Ingress API
On a v1.22 Kubernetes cluster, you'll be able to access Ingress and IngressClass objects through the stable (v1) APIs, but access via their ......
Read more >
Set up Ingress on Minikube with the NGINX Ingress Controller
Create an Ingress · Create example-ingress.yaml from the following file: · Verify the IP address is set: kubectl get ingress · Add the...
Read more >
Installing NGINX Ingress Controller - Documentation
Install NGINX using NodePort# · Check that the Ingress controller pods have started · Check that you can see the NodePort service ·...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found