<p>I want to edit an ingress to have another path as follows</p>

<p>Existing Ingress :</p>

<pre><code>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
</code></pre>

<p>Updated Ingress:</p>

<pre><code>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
</code></pre>

<p>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</p>

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

<p>This is replacing the existing path and backend.</p>

<pre><code>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
</code></pre>

<p>What am I missing?</p>

user_mda
<p>I believe you need to use <code>addToPaths(path)</code> instead. Something like this:</p>

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

<p>More info <a href="http://static.javadoc.io/io.fabric8/kubernetes-model/1.1.4/io/fabric8/kubernetes/api/model/extensions/HTTPIngressRuleValueFluent.html#addToPaths-io.fabric8.kubernetes.api.model.extensions.HTTPIngressPath...-" rel="nofollow noreferrer">here</a></p>
