<p>Im attempting to create an python script to evict nodes based on some criteria and im having trouble getting the <a href="https://github.com/kubernetes-client/python/blob/master/kubernetes/docs/CoreV1Api.md#create_namespaced_pod_eviction" rel="nofollow noreferrer">create_namespaced_pod_eviction</a>
 to behave properly. From what I can tell from the api documentation my syntax looks pretty correct. Any help is appreciated. I'll also mention that the kubernetes cluster is 1.10 on AWS EKS</p>

<pre><code>    for i in pods.items:
        print("Deleting pod: ", i.metadata.name, i.metadata.namespace, node)
        body = kubernetes.client.V1beta1Eviction()
        api_response = v1.create_namespaced_pod_eviction(i.metadata.name, i.metadata.namespace, body, dry_run='All', include_uninitialized='True', pretty='True')
</code></pre>

<p>This is the output:</p>

<pre><code>('Deleting pod: ', 'ambassador-5d86576878-4kv6w', 'istio-system', 'ip-10-72-20-161.ec2.internal')
Traceback (most recent call last):
  File "src/update_workernodes.py", line 105, in &lt;module&gt;
    main()
  File "src/update_workernodes.py", line 99, in main
    evict_pods(old_worker_dns)
  File "src/update_workernodes.py", line 82, in evict_pods
    api_response = v1.create_namespaced_pod_eviction(name=i.metadata.name, namespace=i.metadata.namespace,     body=body, dry_run='All', include_uninitialized='True', pretty='True')
  File "/usr/local/lib/python2.7/site-packages/kubernetes/client/apis/core_v1_api.py", line 6353, in     create_namespaced_pod_eviction
    (data) = self.create_namespaced_pod_eviction_with_http_info(name, namespace, body, **kwargs)
  File "/usr/local/lib/python2.7/site-packages/kubernetes/client/apis/core_v1_api.py", line 6450, in     create_namespaced_pod_eviction_with_http_info
    collection_formats=collection_formats)
  File "/usr/local/lib/python2.7/site-packages/kubernetes/client/api_client.py", line 321, in call_api
    _return_http_data_only, collection_formats, _preload_content, _request_timeout)
  File "/usr/local/lib/python2.7/site-packages/kubernetes/client/api_client.py", line 155, in __call_api
    _request_timeout=_request_timeout)
  File "/usr/local/lib/python2.7/site-packages/kubernetes/client/api_client.py", line 364, in request
    body=body)
  File "/usr/local/lib/python2.7/site-packages/kubernetes/client/rest.py", line 266, in POST
    body=body)
  File "/usr/local/lib/python2.7/site-packages/kubernetes/client/rest.py", line 222, in request
    raise ApiException(http_resp=r)
kubernetes.client.rest.ApiException: (400)
Reason: Bad Request
HTTP response headers: HTTPHeaderDict({'Date': 'Tue, 13 Nov 2018 02:34:52 GMT', 'Audit-Id':     '7a3725ac-5b1c-470b-a743-0af202a56f7c', 'Content-Length': '175', 'Content-Type': 'application/json'})
HTTP response body: {
  "kind": "Status",
  "apiVersion": "v1",
  "metadata": {


  },
  "status": "Failure",
  "message": "Name parameter required.",
  "reason": "BadRequest",
  "code": 400
}
</code></pre>

<p>For those who stumble across this, I was able to get this working by doing the following:</p>

<pre><code>podName = 'insert-name-of-pod'
podNamespace = 'insert-namespace-of-pod'
body = client.V1beta1Eviction(metadata=client.V1ObjectMeta(name=podName, namespace=podNamespace))
api_response = v1.create_namespaced_pod_eviction(name=podName, namespace=podNamespace, body=body)
</code></pre>
