title: Python scripts executes Kubernetes command: kubectl apply -f config_file.yaml
body: <p>I have generated a python script that opens a deployment config_file.yaml, modifies some parameters and saves it again, using pyyaml. This python script will be executed in the master node of a Kubernetes cluster.</p>
  
  <p>Once is generated the new file, my intention is to execute </p>
  
  <pre><code>kubectl apply -f config_file.yaml
  </code></pre>
  
  <p>in the python script to apply the modifications to the deployment. </p>
  
  <p>I have  been reading how to do it using kubernetes python client, but it seems it is not prepare to execute kubectl apply.</p>
  
  <p>So the other option is to create a bash script and execute it from python script.</p>
  
  <p>Bash scripts:</p>
  
  <pre><code>#!/bin/bash
  sudo kubectl apply -f config_file.yaml
  </code></pre>
  
  <p>I give it permissions 
  chmod +x shell_scipt.sh</p>
  
  <p>Python script: </p>
  
  <pre><code>import subprocess
  subprocess.call(['./shell_script.sh'])
  </code></pre>
  
  <p>But an error appears:
    File "/usr/lib/python2.7/subprocess.py", line 1047, in _execute_child
      raise child_exception
  OSError: [Errno 13] Permission denied</p>
  
  <p>I don't know how to resolve this error, I have tested givin permissions to the bash script, but nothing worked.</p>