<p>I'm building a Kubernetes application that Dockerizes code and runs it on the cluster. In order for users to be able to invoke their Dockerized code, I need to modify the Istio configuration to expose the service they've created.</p>
<p>I'm trying to create Istio virtual services using the Python API. I'm able to <em>list</em> existing Istio resources:</p>
<pre><code>group = 'networking.istio.io' 
version = 'v1alpha3' 
plural = 'destinationrules' 

from kubernetes import client, config
config.load_kube_config()

myclient = client.CustomObjectsApi()
api_response = myclient.list_cluster_custom_object(group, version, plural)

</code></pre>
<p>but when I use the same parameters to create, I get a <strong>404 not found</strong> error.</p>
<pre><code>with open('destination-rule.yaml', 'r') as file_reader:
    file_content = file_reader.read()

deployment_template = yaml.safe_load(file_content)

api_response = myclient.create_cluster_custom_object(
   group=group, version=version, plural=plural, body=body)
</code></pre>
<p>The destination-rule.yaml file looks like:</p>
<pre><code>apiVersion: networking.istio.io/v1alpha3
kind: DestinationRule
metadata:
  name: test
spec:
  host: test
  subsets:
  - name: v1
    labels:
      run: test
</code></pre>
<p>What am I doing wrong here?</p>

gkv
<p>My problem was that I was doing <code>create_cluster_custom_object</code> instead of <code>create_namespaced_custom_object</code>. When I switched over, it started working.</p>
