Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

317
Views
Airflow KubernetesPodOperator: uso de un valor de ConfigMap como variable ambiental

Tengo un Kubernetes ConfigMap llamado test que contiene una tecla foobar con algún valor. Me gustaría usar el valor de esa clave en una variable ambiental.

 import datetime import os from airflow import models from airflow.contrib.kubernetes.volume import Volume from airflow.contrib.kubernetes.volume_mount import VolumeMount from airflow.contrib.operators import kubernetes_pod_operator YESTERDAY = datetime.datetime.now() - datetime.timedelta(days=1) cm_test = ['test'] volume_mount = VolumeMount('test', mount_path='/config/', sub_path=None, read_only=False) volume_config = { 'configMap': { 'name': 'test' } } volume = Volume(name='test', configs=volume_config) with models.DAG( dag_id="test_env", schedule_interval=datetime.timedelta(days=1), start_date=YESTERDAY) as dag: kubenetes_template_ex = kubernetes_pod_operator.KubernetesPodOperator( task_id="test_env", name="test_env", namespace="foobar", image="bash", cmds=["printenv"], arguments=[], volumes=[volume], volume_mounts=[volume_mount], configmaps=cm_test, env_vars={ 'MY_ENV_VAR': '/config/foobar' } )

Qué funciona : el ConfigMap está disponible en el volumen montado, por lo que puedo hacer ls /config y se muestra foobar .

Lo que no funciona : me gustaría establecer una variable ambiental con el valor de foobar del mapa de configuración montado. El código actual no funciona, ya que el valor de cadena literal /config/foobar se asigna a la variable env.

over 4 years ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!