Fabric8 java library to edit existing resource

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP



Fabric8 java library to edit existing resource



I want to edit an ingress to have another path as follows



Existing Ingress :


apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: test-ingress
annotations:
nginx.ingress.kubernetes.io/rewrite-target: /
spec:
rules:
- http:
paths:
- path: /testpath
backend:
serviceName: test
servicePort: 80



Updated Ingress:


apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: test-ingress
annotations:
nginx.ingress.kubernetes.io/rewrite-target: /
spec:
rules:
- http:
paths:
- path: /testpath
backend:
serviceName: test
servicePort: 80

- path: /newPath
backend:
serviceName: newService
servicePort: 80



I want to add a new backend to a new path for an existing ingress. I am using the fabric8 java library to achieve this as follows


kubernetesClient.extensions().ingresses().inNamespace(my-env)
.withName(ingressName).edit().editOrNewSpec().editFirstRule().editHttp()
.addNewPathLike(path).withNewBackendLike(ingressBackend);



This is replacing the existing path and backend.


apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: test-ingress
annotations:
nginx.ingress.kubernetes.io/rewrite-target: /
spec:
rules:
- http:
paths:
- path: /newPath
backend:
serviceName: newService
servicePort: 80



What am I missing?




1 Answer
1



I believe you need to use addToPaths(path) instead. Something like this:


addToPaths(path)


kubernetesClient.extensions().ingresses().inNamespace(my-env)
.withName(ingressName).edit().editOrNewSpec().editFirstRule().editHttp()
.addToPaths(path).withNewBackendLike(ingressBackend);



More info here






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Firebase Auth - with Email and Password - Check user already registered

Dynamically update html content plain JS

How to determine optimal route across keyboard