<p>I have below configmap.yml i want to patch/update date field from python script from container in kubernates deployment i searched various side but couldn't get any reference to do that. Any reference or code sample would be a great help</p>
<pre><code>apiVersion: v1
kind: ConfigMap
metadata:
  name: sample-configmap
  labels:
    app: test
    parameter-type: sample
data:
  storage.ini: |
    [DateInfo]
    date=1970-01-01T00:00:00.01Z
</code></pre>
<p>I went through this reference code but couldn't figure out what will be content of <code>body</code> and which parameter i should use and which parameter i should neglect</p>
<p>partially update the specified ConfigMap</p>
<pre><code>from __future__ import print_function
import time
import kubernetes.client
from kubernetes.client.rest
import ApiException
from pprint import pprint

configuration = kubernetes.client.Configuration()
# Configure API key authorization: BearerToken configuration.api_key['authorization'] = 'YOUR_API_KEY'
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
# configuration.api_key_prefix['authorization'] = 'Bearer'
    
# Defining host is optional and default to http://localhost configuration.host = &quot;http://localhost&quot;
    
# Enter a context with an instance of the API kubernetes.client
with kubernetes.client.ApiClient(configuration) as api_client:
    # Create an instance of the API class
    api_instance = kubernetes.client.CoreV1Api(api_client)
    name = 'name_example' # str | name of the ConfigMap
    namespace = 'namespace_example' # str | object name and auth scope, such as for teams and projects
    body = None # object |
    pretty = 'pretty_example'
    dry_run = 'dry_run_example'
    field_manager = 'field_manager_example'
    force = True 
    
try:
    api_response = api_instance.patch_namespaced_config_map(name, namespace, body, pretty=pretty, dry_run=dry_run, field_manager=field_manager, force=force)
    pprint(api_response)
except ApiException as e:
    print(&quot;Exception when calling CoreV1Api-&gt;patch_namespaced_config_map: %s\n&quot; % e)
</code></pre>

Sahil Saxena
<p>The <code>body</code> parameter in <code>patch_namespaced_config_map</code> is the actual <code>configmap</code>  data that you want to patch and needs to be first obtained with <code>read_namespaced_config_map</code>.</p>
<p>Following steps are required for all the operations that have the <code>body</code> argument:</p>
<ol>
<li>Get the data using the <code>read_*/get_*</code>method</li>
<li>Use the data returned in the first step in the API modifying the object.</li>
</ol>
<p>Further, for most cases, it is enough to pass the required arguments namely
<code>name</code>, <code>namespace</code> and <code>body</code> but here is the info about each:</p>
<h3>Parameters</h3>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Description</th>
<th>Notes</th>
</tr>
</thead>
<tbody>
<tr>
<td><strong>name</strong></td>
<td><strong>str</strong></td>
<td>name of the ConfigMap</td>
<td></td>
</tr>
<tr>
<td><strong>namespace</strong></td>
<td><strong>str</strong></td>
<td>object name and auth scope, such as for teams and projects</td>
<td></td>
</tr>
<tr>
<td><strong>body</strong></td>
<td><strong>object</strong></td>
<td></td>
<td></td>
</tr>
<tr>
<td><strong>pretty</strong></td>
<td><strong>str</strong></td>
<td>If 'true', then the output is pretty printed.</td>
<td>[optional]</td>
</tr>
<tr>
<td><strong>dry_run</strong></td>
<td><strong>str</strong></td>
<td>When present, indicates that modifications should not be persisted. An invalid or unrecognized dryRun directive will result in an error response and no further processing of the request. Valid values are: - All: all dry run stages will be processed</td>
<td>[optional]</td>
</tr>
<tr>
<td><strong>field_manager</strong></td>
<td><strong>str</strong></td>
<td>fieldManager is a name associated with the actor or entity that is making these changes. The value must be less than or 128 characters long, and only contain printable characters, as defined by <a href="https://golang.org/pkg/unicode/#IsPrint" rel="noreferrer">https://golang.org/pkg/unicode/#IsPrint</a>. This field is required for apply requests (application/apply-patch) but optional for non-apply patch types (JsonPatch, MergePatch, StrategicMergePatch).</td>
<td>[optional]</td>
</tr>
<tr>
<td><strong>force</strong></td>
<td><strong>bool</strong></td>
<td>Force is going to &amp;quot;force&amp;quot; Apply requests. It means user will re-acquire conflicting fields owned by other people. Force flag must be unset for non-apply patch requests.</td>
<td>[optional]</td>
</tr>
</tbody>
</table>
</div>
<p>Review the <a href="https://github.com/kubernetes-client/python/blob/master/kubernetes/README.md" rel="noreferrer">K8s python client README</a> for the list of all supported APIs and their usage.</p>
