<p>I try to use the master api to update resources.</p>

<p>In 1.2 to update a deployment resource I'm doing <code>kubectl apply -f new updateddeployment.yaml</code></p>

<p>How to do the same action with the api? </p>

<p>I checked the code in <code>pkg/kubectl/cmd/apply.go</code> and I think the following lines of code shows what's behind the scene when you run <code>kubectl apply -f</code>:</p>

<pre><code>// Compute a three way strategic merge patch to send to server.
patch, err := strategicpatch.CreateThreeWayMergePatch(original, modified, current, 
    versionedObject, true)
helper := resource.NewHelper(info.Client, info.Mapping)
_, err = helper.Patch(info.Namespace, info.Name, api.StrategicMergePatchType, patch)
</code></pre>

<p>And here is the code <code>helper.Patch</code>:</p>

<pre><code>func (m *Helper) Patch(namespace, name string, pt api.PatchType, data []byte) (runtime.Object, error) {
    return m.RESTClient.Patch(pt).
        NamespaceIfScoped(namespace, m.NamespaceScoped).
        Resource(m.Resource).
        Name(name).
        Body(data).
        Do().
        Get()
}
</code></pre>
