Em 15 de setembro de 2026, todos os ambientes do Cloud Composer 1 e da versão 2.0.x do Cloud Composer 2 vão atingir o fim da vida útil planejado e não poderão mais ser usados. Recomendamos planejar a migração para o Cloud Composer 3.
Mascaramento de IP é uma forma de conversão de endereços de rede (NAT, na sigla em inglês) usada para
realizar conversões de endereço IP de muitos para um. Isso permite a vários clientes
acessar um destino usando um único endereço IP.
O Cloud Composer executa suas cargas de trabalho no GKE. Para
a função correta, ela requer intervalos de IP para nós (VMs), além de
pods e serviços do GKE. Quando os DAGs e as tarefas do Airflow
se comunicam com outros serviços, eles usam IPs de pod, e esses intervalos precisam
ser roteáveis de e para qualquer destino com que as tarefas interajam.
Com o agente de mascaramento de IP, você tem a opção de traduzir endereços
IP do pod para endereços IP do nó. Assim, os destinos e serviços segmentados
pelos DAGs e as tarefas do Airflow só recebem pacotes dos endereços IP do nó
e não dos endereços IP do pod. Isso é útil em ambientes que esperam receber
somente pacotes de endereços IP de nós ou em que os intervalos de IP do pod não sejam
roteáveis fora do cluster.
Além disso, é possível usar o agente de mascaramento de IP para salvar intervalos de rede na
configuração de rede. Por exemplo, é possível usar um intervalo de rede
separado para os pods dentro do cluster do ambiente e mascarar esse tráfego
como proveniente do intervalo de endereços IP do nó. Desse modo, você economiza espaço de endereço IP
em um intervalo usando endereços IP de um intervalo diferente para pods no
cluster do seu ambiente.
Exemplo:
Você usa o intervalo 10.0.0.0/8 para VMs e somente esse intervalo é permitido pelas
regras de firewall.
Para salvar intervalos de rede, use um intervalo diferente (por exemplo,
192.168.0.0/16) para pods no cluster do ambiente.
Para se conectar a qualquer serviço de um pod (worker do Airflow), o
mascaramento de IP é necessário. Caso contrário, o serviço receberá o tráfego de
192.168.0.0/16 e o descartará devido a uma regra de firewall. Com o agente
de mascaramento de IP ativado e configurado, o serviço recebe solicitações de
10.0.0.0/8, que são aceitas.
Antes de começar
Não é possível ativar o agente de mascaramento de IP no console Google Cloud .
Para usar esse recurso, crie um ambiente com o GKE
1.22.7 ou uma versão mais recente.
O agente de mascaramento de IP não está disponível para ambientes criados
em versões anteriores do GKE, mesmo que o GKE tenha sido
atualizado para a versão 1.22.7 e mais recentes.
Se você ativar o agente de mascaramento de IP, a EgressNatPolicy do GKE padrão será substituída pela definição do Cloud Composer. Se o agente de mascaramento de IP
não estiver ativado, o tráfego de saída não será mascarado e
usará a EgressNatPolicy padrão do GKE.
Ativar o agente de mascaramento de IP para um ambiente
Não é possível ativar o agente de mascaramento de IP para um ambiente
existente.
Ativar o agente de mascaramento de IP ao criar um ambiente
É possível ativar o agente de mascaramento de IP ao criar um ambiente.
Para mais informações sobre como criar ambientes do Cloud Composer,
consulte Criar ambiente.
Console
Não é possível ativar o agente de mascaramento de IP no console Google Cloud .
gcloud
Quando um ambiente é criado, o argumento --enable-ip-masq-agent
ativa o agente de mascaramento de IP.
LOCATION pela região em que o ambiente está localizado;
ENVIRONMENT_NAME pelo nome do ambiente.
Exemplo:
// POST https://composer.googleapis.com/v1/{parent=projects/*/locations/*}/environments{"name":"projects/example-project/locations/us-central1/environments/example-environment","config":{"softwareConfig":{"imageVersion":"composer-2.13.9-airflow-2.10.5"},"nodeConfig":{"enableIpMasqAgent":true}}}
Terraform
Ao criar um ambiente, o campo enable_ip_masq_agent
no bloco node_config ativa o agente de mascaramento de IP.
[[["Fácil de entender","easyToUnderstand","thumb-up"],["Meu problema foi resolvido","solvedMyProblem","thumb-up"],["Outro","otherUp","thumb-up"]],[["Difícil de entender","hardToUnderstand","thumb-down"],["Informações incorretas ou exemplo de código","incorrectInformationOrSampleCode","thumb-down"],["Não contém as informações/amostras de que eu preciso","missingTheInformationSamplesINeed","thumb-down"],["Problema na tradução","translationIssue","thumb-down"],["Outro","otherDown","thumb-down"]],["Última atualização 2025-08-26 UTC."],[[["\u003cp\u003eThe IP Masquerade agent in Cloud Composer allows multiple clients to access a destination from a single IP address, translating Pod IP addresses to node IP addresses.\u003c/p\u003e\n"],["\u003cp\u003eEnabling the IP Masquerade agent is recommended to manage IP address shortages and ensure that services only receive packets from node IP addresses, which is useful when Pod IP ranges are not routable outside of the cluster.\u003c/p\u003e\n"],["\u003cp\u003eYou can only enable the IP Masquerade agent during the creation of a new environment with GKE version 1.22.7 or later, and it cannot be enabled for existing environments.\u003c/p\u003e\n"],["\u003cp\u003eThe IP Masquerade agent can be enabled via the \u003ccode\u003egcloud\u003c/code\u003e command-line tool, the API, or Terraform, using specific configurations for each method, but not through the Google Cloud console.\u003c/p\u003e\n"],["\u003cp\u003eWhen configuring the IP Masquerade agent, non-masquerade destinations must at least include the cluster's node and Pod IP address ranges due to Cloud Composer enabling intranode visibility.\u003c/p\u003e\n"]]],[],null,["# Enable the IP Masquerade agent in Cloud Composer environments\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\n[Cloud Composer 3](/composer/docs/composer-3/change-networking-type#comparison \"View this page for Cloud Composer 3\") \\| **Cloud Composer 2** \\| [Cloud Composer 1](/composer/docs/composer-1/enable-ip-masquerade-agent \"View this page for Cloud Composer 1\")\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\nThis page describes how to enable the IP Masquerade agent for your environment.\n| **Important:** Consider using the IP Masquerade agent if your project is impacted by the shortage of IP addresses. By enabling the IP Masquerade agent, you can use your environment's cluster IP addresses to communicate with external services.\n\nAbout the IP Masquerade agent in Cloud Composer\n-----------------------------------------------\n\nCloud Composer supports\nthe [IP Masquerade agent](/kubernetes-engine/docs/how-to/ip-masquerade-agent) for your environments.\n\n*IP masquerading* is a form of network address translation (NAT) used to\nperform many-to-one IP address translations. This allows multiple clients to\naccess a destination from a single IP address.\n\nCloud Composer runs your workloads on GKE. For\ncorrect function, it requires IP ranges for nodes (VMs) as well as\nGKE Pods and Services. When Airflow DAGs and tasks\ncommunicate with other services, they use Pod IPs and these Pod IP ranges need\nto be routable to and from any destinations that the tasks interact with.\n\nWith the IP Masquerade agent, you have the option to translate Pod IP\naddresses to node IP addresses, so that destinations and services targeted\nfrom Airflow DAGs and tasks only receive packets from node IP addresses\ninstead of Pod IP addresses. This is useful in environments that expect to\nonly receive packets from node IP addresses or where Pod IP ranges are not\nroutable outside of the cluster.\n\nIn addition, you can use the IP Masquerade agent to save network ranges in\nyour networking configuration. For example, you can use a separate network\nrange for Pods inside your environment's cluster and masquerade this traffic\nas coming from the node IP address range. In this way, you save IP address\nspace in one range by using IP addresses from a different range for Pods in\nyour environment's cluster.\n\nFor example:\n\n1. You use the `10.0.0.0/8` range for VMs and only this range is allowed by\n your firewall rules.\n\n2. To save network ranges, you use a different range (for example,\n `192.168.0.0/16`) for Pods in your environment's cluster.\n\n3. To be able to connect to any service from a Pod (Airflow worker), IP\n masquerading is needed; otherwise the service receives traffic from\n `192.168.0.0/16` and drops it because of a firewall rule. With the IP\n Masquerade agent enabled and configured, the service gets requests from\n `10.0.0.0/8`, which are accepted.\n\nBefore you begin\n----------------\n\n- It is not possible to enable the IP Masquerade agent in Google Cloud console.\n\n- To use this feature, you must create an environment with GKE\n 1.22.7 or later version.\n\n- The IP Masquerade agent is not available for environments that were created\n in earlier GKE versions, even if GKE was\n upgraded to 1.22.7 and later versions.\n\n- If you enable the IP Masquerade agent, the default\n [GKE's EgressNatPolicy](/kubernetes-engine/docs/how-to/egress-nat-policy-ip-masq-autopilot) will be\n replaced with Cloud Composer's definition. If the IP Masquerade\n agent is not enabled, the outgoing traffic won't be masqueraded and will\n use the default GKE's EgressNatPolicy.\n\nEnable the IP Masquerade agent for an existing environment\n----------------------------------------------------------\n\nIt is not possible to enable the IP Masquerade agent for an existing\nenvironment.\n\nEnable the IP Masquerade agent when creating an environment\n-----------------------------------------------------------\n\nYou can enable the IP Masquerade agent when you create an environment.\n\nFor more information about creating Cloud Composer environments,\nsee [Create environment](/composer/docs/composer-2/create-environments). \n\n### Console\n\nIt is not possible to enable the IP Masquerade agent in Google Cloud console.\n\n### gcloud\n\nWhen you create an environment, the `--enable-ip-masq-agent` argument\nenables the IP Masqerade agent. \n\n gcloud composer environments create \u003cvar translate=\"no\"\u003eENVIRONMENT_NAME\u003c/var\u003e \\\n --location \u003cvar translate=\"no\"\u003eLOCATION\u003c/var\u003e \\\n --image-version composer-2.14.0-airflow-2.10.5 \\\n --enable-ip-masq-agent\n\nReplace:\n\n- `ENVIRONMENT_NAME` with the name of the environment.\n- `LOCATION` with the region where the environment is located.\n\nExample: \n\n gcloud composer environments create example-environment \\\n --location us-central1 \\\n --image-version composer-2.14.0-airflow-2.10.5 \\\n --enable-ip-masq-agent\n\n### API\n\nConstruct an [`environments.create`](/composer/docs/reference/rest/v1/projects.locations.environments/create) API request.\nSpecify the configuration in the [`Environment`](/composer/docs/reference/rest/v1/projects.locations.environments#Environment)\nresource. \n\n {\n \"name\": \"projects/\u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e/locations/\u003cvar translate=\"no\"\u003eLOCATION\u003c/var\u003e/environments/\u003cvar translate=\"no\"\u003eENVIRONMENT_NAME\u003c/var\u003e\",\n \"config\": {\n \"softwareConfig\": {\n \"imageVersion\": \"composer-2.14.0-airflow-2.10.5\"\n },\n \"nodeConfig\": {\n \"enableIpMasqAgent\": true\n }\n }\n }\n\nReplace:\n\n- `PROJECT_ID` with the [Project ID](/resource-manager/docs/creating-managing-projects).\n- `LOCATION` with the region where the environment is located.\n- `ENVIRONMENT_NAME` with the environment name.\n\nExample: \n\n // POST https://composer.googleapis.com/v1/{parent=projects/*/locations/*}/environments\n\n {\n \"name\": \"projects/example-project/locations/us-central1/environments/example-environment\",\n \"config\": {\n \"softwareConfig\": {\n \"imageVersion\": \"composer-2.14.0-airflow-2.10.5\"\n },\n \"nodeConfig\": {\n \"enableIpMasqAgent\": true\n }\n }\n }\n\n### Terraform\n\nWhen you create an environment, the `enable_ip_masq_agent`\nfield in the `node_config` block enables the IP Masqerade agent. \n\n resource \"google_composer_environment\" \"example_environment\" {\n provider = google-beta\n name = \"\u003cvar translate=\"no\"\u003eENVIRONMENT_NAME\u003c/var\u003e\"\n region = \"\u003cvar translate=\"no\"\u003eLOCATION\u003c/var\u003e\"\n\n config {\n software_config {\n image_version = \"composer-2.14.0-airflow-2.10.5\"\n }\n node_config {\n enable_ip_masq_agent = true\n }\n }\n\nReplace:\n\n- `ENVIRONMENT_NAME` with the name of the environment.\n- `LOCATION` with the region where the environment is located.\n\nExample: \n\n resource \"google_composer_environment\" \"example_environment\" {\n provider = google-beta\n name = \"example-environment\"\n region = \"us-central1\"\n\n config {\n software_config {\n image_version = \"composer-2.14.0-airflow-2.10.5\"\n }\n node_config {\n enable_ip_masq_agent = true\n }\n }\n }\n\nConfigure the IP Masquerade agent\n---------------------------------\n\n| **Caution:** Cloud Composer enables [intranode visibility](/kubernetes-engine/docs/how-to/intranode-visibility) on GKE clusters. Therefore, non-masquerade destinations must at least include the cluster's node and Pod IP address range(s).\n\nFor more information about using and configuring the IP Masquerade agent in\nCloud Composer 2, see\n[Use Egress NAT Policy to configure IP masquerade in Autopilot clusters](/kubernetes-engine/docs/how-to/egress-nat-policy-ip-masq-autopilot).\n\n\nWhat's next\n-----------\n\n- [Create an environment](/composer/docs/composer-2/create-environments)\n- [Configure Shared VPC networking](/composer/docs/composer-2/configure-shared-vpc)\n- [Configure Private IP networking](/composer/docs/composer-2/configure-private-ip)"]]