<p>I'm looking for a way to set service/status/loadBalance/ingress-ip after creating k8s service of type=loadbalancer (as appears in  'Type LoadBalancer' section at the next link  <a href="https://kubernetes.io/docs/concepts/services-networking/service/" rel="nofollow noreferrer">https://kubernetes.io/docs/concepts/services-networking/service/</a>  ).</p>

<p>My problem is similiar to the issue described in following link (<a href="https://stackoverflow.com/questions/43339050/is-it-possible-to-update-a-kubernetes-service-external-ip-while-watching-for-t">Is it possible to update a kubernetes service &#39;External IP&#39; while watching for the service?</a> ) but couldn't find the answer.</p>

<p>Thanks in advance</p>

<p>There's two ways to do this. With a <a href="http://jsonpatchjs.com/" rel="nofollow noreferrer">json patch</a> or with a merge patch. Here's how you do the latter:</p>

<pre><code>[centos@ost-controller ~]$ cat patch.json
{
    "status": {
        "loadBalancer": {
            "ingress": [
                {"ip": "8.3.2.1"}
            ]
        }
    }
}
</code></pre>

<p>Now, here you can see the for merge patches, you have to make a dictionary containing all the Object tree (begins at status) that will need some change to be merged. If you wanted to replace something, then you'd have to use the json patch strategy.</p>

<p>Once we have this file we send the request and if all goes well, we'll receive a response consisting on the object with the merge already applied:</p>

<pre><code>[centos@ost-controller ~]$ curl --request PATCH --data "$(cat patch.json)" -H "Content-Type:application/merge-patch+json" http://localhost:8080/api/v1/namespaces/default/services/kubernetes/status{
  "kind": "Service",
  "apiVersion": "v1",
  "metadata": {
    "name": "kubernetes",
    "namespace": "default",
    "selfLink": "/api/v1/namespaces/default/services/kubernetes/status",
    "uid": "b8ece320-76c1-11e7-b468-fa163ea3fb09",
    "resourceVersion": "2142242",
    "creationTimestamp": "2017-08-01T14:00:06Z",
    "labels": {
      "component": "apiserver",
      "provider": "kubernetes"
    }
  },
  "spec": {
    "ports": [
      {
        "name": "https",
        "protocol": "TCP",
        "port": 443,
        "targetPort": 6443
      }
    ],
    "clusterIP": "10.0.0.129",
    "type": "ClusterIP",
    "sessionAffinity": "ClientIP"
  },
  "status": {
    "loadBalancer": {
      "ingress": [
        {
          "ip": "8.3.2.1"
        }
      ]
    }
  }
</code></pre>
