<p>The KubernetesPodOperator in my Airflow dag is trying to launch a pod using the following pod spec (replaced some config values with <code>xxx</code>):</p>
<pre><code>{
  &quot;apiVersion&quot;: &quot;v1&quot;,
  &quot;kind&quot;: &quot;Pod&quot;,
  &quot;metadata&quot;: {
    &quot;annotations&quot;: {
      &quot;sidecar.istio.io/inject&quot;: &quot;false&quot;,
      &quot;azureDisk&quot;: {
        &quot;kind&quot;: &quot;Managed&quot;,
        &quot;diskName&quot;: &quot;airflow-buffer&quot;,
        &quot;diskURI&quot;: &quot;xxx&quot;,
        &quot;cachingMode&quot;: &quot;None&quot;
      }
    },
    &quot;labels&quot;: {
      &quot;airflow_version&quot;: &quot;1.10.15&quot;,
      &quot;kubernetes_pod_operator&quot;: &quot;True&quot;,
      &quot;dag_id&quot;: &quot;cxf-main&quot;,
      &quot;task_id&quot;: &quot;cxf-main&quot;,
      &quot;execution_date&quot;: &quot;2021-11-20T0300000000-d97e9064f&quot;,
      &quot;try_number&quot;: &quot;3&quot;
    },
    &quot;name&quot;: &quot;xxx&quot;,
    &quot;namespace&quot;: &quot;airflow&quot;
  },
  &quot;spec&quot;: {
    &quot;affinity&quot;: {},
    &quot;containers&quot;: [
      {
        &quot;args&quot;: [],
        &quot;command&quot;: [
          &quot;python&quot;,
          &quot;src/main.py&quot;
        ],
        &quot;env&quot;: [
          {
            &quot;name&quot;: &quot;xxx&quot;,
            &quot;value&quot;: &quot;xxx&quot;
          },
          {
            &quot;name&quot;: &quot;xxx&quot;,
            &quot;value&quot;: &quot;production&quot;
          }
        ],
        &quot;envFrom&quot;: [],
        &quot;image&quot;: &quot;xxx&quot;,
        &quot;imagePullPolicy&quot;: &quot;IfNotPresent&quot;,
        &quot;name&quot;: &quot;base&quot;,
        &quot;resources&quot;: {
          &quot;limits&quot;: {},
          &quot;requests&quot;: {}
        },
        &quot;volumeMounts&quot;: [
          {
            &quot;mountPath&quot;: &quot;/mnt/buffer&quot;,
            &quot;name&quot;: &quot;xxx&quot;,
            &quot;readOnly&quot;: true
          }
        ]
      }
    ],
    &quot;hostNetwork&quot;: false,
    &quot;imagePullSecrets&quot;: [
      {
        &quot;name&quot;: &quot;xxx&quot;
      }
    ],
    &quot;initContainers&quot;: [],
    &quot;nodeSelector&quot;: {},
    &quot;restartPolicy&quot;: &quot;Never&quot;,
    &quot;securityContext&quot;: {},
    &quot;serviceAccountName&quot;: &quot;default&quot;,
    &quot;tolerations&quot;: [],
    &quot;volumes&quot;: [
      {
        &quot;name&quot;: &quot;xxx&quot;,
        &quot;persistentVolumeClaim&quot;: {
          &quot;claimName&quot;: &quot;xxx&quot;
        }
      }
    ]
  }
}
</code></pre>
<p>However, the Kubernetes API is returning an exception and I can't figure out why:</p>
<pre><code>Pod in version \&quot;v1\&quot; cannot be handled as a Pod: v1.Pod.ObjectMeta:
v1.ObjectMeta.Annotations: ReadString: expects \&quot; or n, but found {, 
error found in #10 byte of ...|reDisk\&quot;: {\&quot;kind\&quot;: \&quot;M|..., bigger context ...|\&quot;sidecar.istio.io/inject\&quot;: \&quot;false\&quot;, \&quot;azureDisk\&quot;: {\&quot;kind\&quot;: \&quot;Managed\&quot;, \&quot;diskName\&quot;: \&quot;airflow-buffer\&quot;, \&quot;|...
</code></pre>

DSteman
<p>You have nested annotations and thats also what the error is telling you.</p>
<pre><code>v1.ObjectMeta.Annotations: ReadString: expects \&quot; or n, but found {,
</code></pre>
<p>You are not allowed to do this.</p>
<pre class="lang-json prettyprint-override"><code>&quot;annotations&quot;: {
      &quot;sidecar.istio.io/inject&quot;: &quot;false&quot;,
      // cannot nest azureDisk inside annotations
      &quot;azureDisk&quot;: {
        &quot;kind&quot;: &quot;Managed&quot;,
        &quot;diskName&quot;: &quot;airflow-buffer&quot;,
        &quot;diskURI&quot;: &quot;xxx&quot;,
        &quot;cachingMode&quot;: &quot;None&quot;
      }
}
</code></pre>
<p>This object belongs in the volumes array.</p>
<pre class="lang-json prettyprint-override"><code>&quot;volumes&quot;: [
    {
        &quot;name&quot;: &quot;mydisk&quot;,
        &quot;azureDisk&quot;: {
          &quot;kind&quot;: &quot;Managed&quot;,
          &quot;diskName&quot;: &quot;airflow-buffer&quot;,
          &quot;diskURI&quot;: &quot;xxx&quot;,
          &quot;cachingMode&quot;: &quot;None&quot;
        }
    }
]
</code></pre>
<p>You can also see this in this documentation for example, in YAML format.</p>
<p><a href="https://learn.microsoft.com/en-us/azure/aks/azure-disks-dynamic-pv" rel="nofollow noreferrer">https://learn.microsoft.com/en-us/azure/aks/azure-disks-dynamic-pv</a></p>
