raphaelauv opened a new issue, #44325:
URL: https://github.com/apache/airflow/issues/44325

   ### Apache Airflow version
   
   2.10.3
   
   ### If "Other Airflow 2 version" selected, which one?
   
   _No response_
   
   ### What happened?
   
   
   
   ```log
   [2024-10-30, 16:03:51 UTC] {base.py:84} INFO - Retrieving connection 
'kubernetes_default'
   [2024-10-30, 16:03:51 UTC] {pod.py:1138} INFO - Building pod 
airflow-test-pod-xb472z6z with labels: {'dag_id': 'kubernetes_dag', 'task_id': 
'task-one', 'run_id': 'manual__2024-10-30T160350.5676190000-e2f6ac7ec', 
'kubernetes_pod_operator': 'True', 'try_number': '1'}
   [2024-10-30, 16:03:51 UTC] {taskinstance.py:288} INFO - Pausing task as 
DEFERRED. dag_id=kubernetes_dag, task_id=task-one, 
run_id=manual__2024-10-30T16:03:50.567619+00:00, 
execution_date=20241030T160350, start_date=20241030T160351
   [2024-10-30, 16:03:51 UTC] {taskinstance.py:340} ▼ Post task execution logs
   [2024-10-30, 16:03:51 UTC] {local_task_job_runner.py:260} INFO - Task exited 
with return code 100 (task deferral)
   [2024-10-30, 16:03:51 UTC] {local_task_job_runner.py:245} ▲▲▲ Log group end
   [2024-10-30, 16:03:52 UTC] {pod.py:160} INFO - Checking pod 
'airflow-test-pod-xb472z6z' in namespace 'default'.
   [2024-10-30, 16:03:52 UTC] {base.py:84} INFO - Retrieving connection 
'kubernetes_default'
   [2024-10-30, 16:03:52 UTC] {kube_config.py:515} WARNING - Config not found: 
/home/airflow/.kube/config
   [2024-10-30, 16:03:52 UTC] {triggerer_job_runner.py:631} INFO - Trigger 
kubernetes_dag/manual__2024-10-30T16:03:50.567619+00:00/task-one/-1/1 (ID 10) 
fired: TriggerEvent<{'name': 'airflow-test-pod-xb472z6z', 'namespace': 
'default', 'status': 'error', 'message': 'Invalid kube-config file. Expected 
key contexts in kube-config', 'stack_trace': 'Traceback (most recent call 
last):\n  File 
"/home/airflow/.local/lib/python3.12/site-packages/airflow/providers/cncf/kubernetes/triggers/pod.py",
 line 162, in run\n    state = await self._wait_for_pod_start()\n            
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n  File 
"/home/airflow/.local/lib/python3.12/site-packages/airflow/providers/cncf/kubernetes/triggers/pod.py",
 line 223, in _wait_for_pod_start\n    pod = await 
self.hook.get_pod(self.pod_name, self.pod_namespace)\n          
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n  File 
"/home/airflow/.local/lib/python3.12/site-packages/airflow/providers/cncf/kubernetes/hooks/kubernetes.py
 ", line 754, in get_pod\n    async with self.get_conn() as connection:\n       
        ^^^^^^^^^^^^^^^\n  File "/usr/local/lib/python3.12/contextlib.py", line 
210, in __aenter__\n    return await anext(self.gen)\n           
^^^^^^^^^^^^^^^^^^^^^\n  File 
"/home/airflow/.local/lib/python3.12/site-packages/airflow/providers/cncf/kubernetes/hooks/kubernetes.py",
 line 741, in get_conn\n    kube_client = await self._load_config() or 
async_client.ApiClient()\n                  ^^^^^^^^^^^^^^^^^^^^^^^^^\n  File 
"/home/airflow/.local/lib/python3.12/site-packages/airflow/providers/cncf/kubernetes/hooks/kubernetes.py",
 line 711, in _load_config\n    await async_config.load_kube_config(\n  File 
"/home/airflow/.local/lib/python3.12/site-packages/kubernetes_asyncio/config/kube_config.py",
 line 603, in load_kube_config\n    loader = 
_get_kube_config_loader_for_yaml_file(\n             
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n  File 
"/home/airflow/.local/lib/python3.12/site-packages/kubernetes_async
 io/config/kube_config.py", line 567, in 
_get_kube_config_loader_for_yaml_file\n    return KubeConfigLoader(\n           
^^^^^^^^^^^^^^^^^\n  File 
"/home/airflow/.local/lib/python3.12/site-packages/kubernetes_asyncio/config/kube_config.py",
 line 150, in __init__\n    self.set_active_context(active_context)\n  File 
"/home/airflow/.local/lib/python3.12/site-packages/kubernetes_asyncio/config/kube_config.py",
 line 162, in set_active_context\n    self._current_context = 
self._config[\'contexts\'].get_with_name(\n                            
~~~~~~~~~~~~^^^^^^^^^^^^\n  File 
"/home/airflow/.local/lib/python3.12/site-packages/kubernetes_asyncio/config/kube_config.py",
 line 448, in __getitem__\n    raise 
ConfigException(\nkubernetes_asyncio.config.config_exception.ConfigException: 
Invalid kube-config file. Expected key contexts in kube-config\n'}>
   [2024-10-30, 16:03:54 UTC] {local_task_job_runner.py:123} ▼ Pre task 
execution logs
   
   ```
   
   
   ### What you think should happen instead?
   
   _No response_
   
   ### How to reproduce
   
   [kind](https://github.com/kubernetes-sigs/kind/) 0.24.0
   
   ```
   kind get kubeconfig --internal > conf/kube_conf
   ```
   
   airflow connection
   
   ```json
     "kubernetes_default": {
       "conn_type": "kubernetes",
       "extra": "{\"extra__kubernetes__in_cluster\": false, 
\"extra__kubernetes__kube_config_path\": \"/opt/airflow/include/.kube/config\", 
\"extra__kubernetes__namespace\": \"default\", 
\"extra__kubernetes__cluster_context\": \"kind-kind\", 
\"extra__kubernetes__disable_verify_ssl\": false, 
\"extra__kubernetes__disable_tcp_keepalive\": false, 
\"xcom_sidecar_container_image\": \"alpine:3.16.2\"}"
     }
   ```
   
   
   ```python
   from airflow import DAG
   from airflow.utils.dates import days_ago
   from airflow.providers.cncf.kubernetes.operators.pod import 
KubernetesPodOperator
   
   dag = DAG(
       dag_id="kubernetes_dag",
       schedule_interval=None,
       start_date=days_ago(1),
   )
   
   with dag:
       cmd = "echo toto && sleep 4 && echo finish"
   
       KubernetesPodOperator(
           task_id="task-one",
           namespace="default",
           kubernetes_conn_id="kubernetes_default",
           image="alpine:3.16.2",
           cmds=["sh", "-c", cmd],
           deferrable=True,
       )
   
   ```
   
   ### Operating System
   
   ubuntu 22.04
   
   ### Versions of Apache Airflow Providers
   
   apache-airflow-providers-cncf-kubernetes==10.0.0
   
   ### Deployment
   
   Docker-Compose
   
   ### Deployment details
   
   _No response_
   
   ### Anything else?
   
   _No response_
   
   ### Are you willing to submit PR?
   
   - [ ] Yes I am willing to submit a PR!
   
   ### Code of Conduct
   
   - [X] I agree to follow this project's [Code of 
Conduct](https://github.com/apache/airflow/blob/main/CODE_OF_CONDUCT.md)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to