The KubernetesPodOperator in my Airflow dag is trying to launch a pod using the following pod spec (replaced some config values with xxx
):
{
"apiVersion": "v1",
"kind": "Pod",
"metadata": {
"annotations": {
"sidecar.istio.io/inject": "false",
"azureDisk": {
"kind": "Managed",
"diskName": "airflow-buffer",
"diskURI": "xxx",
"cachingMode": "None"
}
},
"labels": {
"airflow_version": "1.10.15",
"kubernetes_pod_operator": "True",
"dag_id": "cxf-main",
"task_id": "cxf-main",
"execution_date": "2021-11-20T0300000000-d97e9064f",
"try_number": "3"
},
"name": "xxx",
"namespace": "airflow"
},
"spec": {
"affinity": {},
"containers": [
{
"args": [],
"command": [
"python",
"src/main.py"
],
"env": [
{
"name": "xxx",
"value": "xxx"
},
{
"name": "xxx",
"value": "production"
}
],
"envFrom": [],
"image": "xxx",
"imagePullPolicy": "IfNotPresent",
"name": "base",
"resources": {
"limits": {},
"requests": {}
},
"volumeMounts": [
{
"mountPath": "/mnt/buffer",
"name": "xxx",
"readOnly": true
}
]
}
],
"hostNetwork": false,
"imagePullSecrets": [
{
"name": "xxx"
}
],
"initContainers": [],
"nodeSelector": {},
"restartPolicy": "Never",
"securityContext": {},
"serviceAccountName": "default",
"tolerations": [],
"volumes": [
{
"name": "xxx",
"persistentVolumeClaim": {
"claimName": "xxx"
}
}
]
}
}
However, the Kubernetes API is returning an exception and I can't figure out why:
Pod in version \"v1\" cannot be handled as a Pod: v1.Pod.ObjectMeta:
v1.ObjectMeta.Annotations: ReadString: expects \" or n, but found {,
error found in #10 byte of ...|reDisk\": {\"kind\": \"M|..., bigger context ...|\"sidecar.istio.io/inject\": \"false\", \"azureDisk\": {\"kind\": \"Managed\", \"diskName\": \"airflow-buffer\", \"|...
CodePudding user response:
You have nested annotations and thats also what the error is telling you.
v1.ObjectMeta.Annotations: ReadString: expects \" or n, but found {,
You are not allowed to do this.
"annotations": {
"sidecar.istio.io/inject": "false",
// cannot nest azureDisk inside annotations
"azureDisk": {
"kind": "Managed",
"diskName": "airflow-buffer",
"diskURI": "xxx",
"cachingMode": "None"
}
}
This object belongs in the volumes array.
"volumes": [
{
"name": "mydisk",
"azureDisk": {
"kind": "Managed",
"diskName": "airflow-buffer",
"diskURI": "xxx",
"cachingMode": "None"
}
}
]
You can also see this in this documentation for example, in YAML format.
https://docs.microsoft.com/en-us/azure/aks/azure-disks-dynamic-pv