Migrer le connecteur VPC standard vers la sortie VPC directe
Restez organisé à l'aide des collections
Enregistrez et classez les contenus selon vos préférences.
Cette page s'adresse aux spécialistes de la mise en réseau qui souhaitent migrer le trafic d'un réseau VPC standard utilisant des connecteurs d'accès au VPC sans serveur vers une sortie VPC directe lors de l'envoi du trafic vers un réseau VPC.
La sortie VPC directe est plus rapide et peut gérer plus de trafic que les connecteurs. Elle offre ainsi une latence plus faible et un débit plus élevé, car elle utilise un nouveau chemin réseau direct au lieu d'instances de connecteur.
Migrer progressivement les services vers la sortie VPC directe
Lorsque vous migrez des services Cloud Run depuis des connecteurs d'accès au VPC sans serveur vers la sortie VPC directe, nous vous recommandons de le faire dans le cadre d'une transition progressive.
Pour effectuer une transition progressive :
Suivez les instructions de cette section pour mettre à jour votre service afin d'utiliser la sortie VPC directe.
Cliquez sur le service que vous souhaitez migrer depuis un connecteur vers la sortie VPC directe, puis sur Modifier et déployer la nouvelle révision.
Cliquez sur l'onglet Mise en réseau.
Dans le champ Se connecter à un VPC pour le trafic sortant, cliquez sur Envoyer le trafic directement vers un VPC.
Dans le champ Réseau, sélectionnez le réseau VPC vers lequel vous souhaitez envoyer du trafic.
Dans le champ Sous-réseau, sélectionnez le sous-réseau à partir duquel votre service reçoit des adresses IP. Vous pouvez déployer plusieurs services sur le même sous-réseau.
Facultatif : saisissez les noms des tags réseau que vous souhaitez associer à votre ou vos services. Les tags réseau sont spécifiés au niveau de la révision. Chaque révision de service peut avoir des tags réseau différents, tels que network-tag-2.
Dans le champ Routage du trafic, sélectionnez l'une des options suivantes :
N'acheminez que les requêtes adressées à des adresses IP privées vers le VPC pour envoyer uniquement le trafic vers des adresses internes via le réseau VPC.
Acheminez tout le trafic vers le VPC pour envoyer tout le trafic sortant via le réseau VPC.
Cliquez sur Déployer.
Pour vérifier que votre service se trouve sur votre réseau VPC, cliquez sur le service, puis sur l'onglet Mise en réseau. Le réseau et le sous-réseau sont répertoriés dans la fiche VPC.
Vous pouvez désormais envoyer des requêtes directement à partir de votre service Cloud Run vers n'importe quelle ressource du réseau VPC, conformément à vos règles de pare-feu.
gcloud
Pour migrer un service Cloud Run d'un connecteur vers la sortie VPC directe à l'aide de Google Cloud CLI, procédez comme suit :
Déployez votre service Cloud Run à l'aide de la commande suivante :
SUBNET par le nom de votre sous-réseau. Vous pouvez déployer ou exécuter plusieurs services ou jobs sur le même sous-réseau.
Facultatif : NETWORK_TAG_NAMES par les noms des tags réseau séparés par une virgule que vous souhaitez associer à un service. Pour les services, les tags réseau sont spécifiés au niveau de la révision. Chaque révision de service peut avoir des tags réseau différents, tels que network-tag-2.
Vous pouvez désormais envoyer des requêtes à partir de votre service Cloud Run vers n'importe quelle ressource du réseau VPC, conformément à vos règles de pare-feu.
Migrer des jobs vers la sortie VPC directe
Vous pouvez migrer le trafic avec la sortie VPC directe pour un job à l'aide de la console Google Cloud ou de Google Cloud CLI.
Console
Dans la console Google Cloud, accédez à la page Cloud Run.
Cliquez sur le job que vous souhaitez migrer d'un connecteur vers la sortie VPC directe, puis sur Modifier.
Cliquez sur l'onglet Mise en réseau.
Cliquez sur Conteneur, variables et secrets, connexions, sécurité pour développer la page des propriétés du job.
Cliquez sur l'onglet Connexions.
Dans le champ Se connecter à un VPC pour le trafic sortant, cliquez sur Envoyer le trafic directement vers un VPC.
Dans le champ Réseau, sélectionnez le réseau VPC vers lequel vous souhaitez envoyer du trafic.
Dans le champ Sous-réseau, sélectionnez le sous-réseau à partir duquel votre job reçoit des adresses IP. Vous pouvez déployer plusieurs jobs sur le même sous-réseau.
Facultatif : saisissez les noms des tags réseau que vous souhaitez associer à votre ou vos services. Les tags réseau sont spécifiés au niveau de la révision. Chaque révision de service peut avoir des tags réseau différents, tels que network-tag-2.
Dans le champ Routage du trafic, sélectionnez l'une des options suivantes :
N'acheminez que les requêtes adressées à des adresses IP privées vers le VPC pour envoyer uniquement le trafic vers des adresses internes via le réseau VPC.
Acheminez tout le trafic vers le VPC pour envoyer tout le trafic sortant via le réseau VPC.
Cliquez sur Mettre à jour.
Pour vérifier que votre job se trouve sur votre réseau VPC, cliquez sur le job, puis sur l'onglet Configuration. Le réseau et le sous-réseau sont répertoriés dans la fiche VPC.
Vous pouvez maintenant exécuter votre job Cloud Run et envoyer des requêtes à partir du job vers n'importe quelle ressource du réseau VPC, conformément à vos règles de pare-feu.
gcloud
Pour migrer un job Cloud Run d'un connecteur vers la sortie VPC directe à l'aide de Google Cloud CLI, procédez comme suit :
Mettez à jour votre job Cloud Run à l'aide de la commande suivante :
SUBNET par le nom de votre sous-réseau. Vous pouvez déployer ou exécuter plusieurs services ou jobs sur le même sous-réseau.
Facultatif : NETWORK_TAG_NAMES par les noms des tags réseau que vous souhaitez associer à un job. Pour les jobs, les tags réseau sont spécifiés au niveau de l'exécution. Chaque exécution de job peut avoir des tags réseau différents, tels que network-tag-2.
Vous pouvez désormais envoyer des requêtes à partir de votre job Cloud Run vers n'importe quelle ressource du réseau VPC, conformément à vos règles de pare-feu.
Sauf indication contraire, le contenu de cette page est régi par une licence Creative Commons Attribution 4.0, et les échantillons de code sont régis par une licence Apache 2.0. Pour en savoir plus, consultez les Règles du site Google Developers. Java est une marque déposée d'Oracle et/ou de ses sociétés affiliées.
Dernière mise à jour le 2024/12/05 (UTC).
[[["Facile à comprendre","easyToUnderstand","thumb-up"],["J'ai pu résoudre mon problème","solvedMyProblem","thumb-up"],["Autre","otherUp","thumb-up"]],[["Difficile à comprendre","hardToUnderstand","thumb-down"],["Informations ou exemple de code incorrects","incorrectInformationOrSampleCode","thumb-down"],["Il n'y a pas l'information/les exemples dont j'ai besoin","missingTheInformationSamplesINeed","thumb-down"],["Problème de traduction","translationIssue","thumb-down"],["Autre","otherDown","thumb-down"]],["Dernière mise à jour le 2024/12/05 (UTC)."],[],[],null,["# Migrate standard VPC connector to Direct VPC egress\n\nThis page is for networking specialists who want to migrate standard VPC\nnetwork traffic from using [Serverless VPC Access connectors](/run/docs/configuring/vpc-connectors)\nto using [Direct VPC egress](/run/docs/configuring/vpc-direct-vpc)\nwhen sending traffic to a VPC network.\n\nDirect VPC egress is faster and can handle more traffic than connectors,\ndelivering lower latency and higher throughput because it uses a new, direct\nnetwork path rather than connector instances.\n\nBefore migration, we recommend that you familiarize yourself with Direct VPC\negress [prerequisites](/run/docs/configuring/vpc-direct-vpc#before_you_begin),\n[limitations](/run/docs/configuring/vpc-direct-vpc#limitations),\n[IP address allocation](/run/docs/configuring/vpc-direct-vpc#direct-vpc-ip-allocation),\nand [IAM permissions](/run/docs/configuring/vpc-direct-vpc#set_up_iam_permissions).\n\nMigrate services to Direct VPC egress\n-------------------------------------\n\n| **Important:** Connectors continue to incur charges even if they have no traffic and are disconnected. For details, see [pricing](/vpc/pricing#serverless-vpc-pricing). If you no longer need your connector, be sure to [delete](/run/docs/configuring/vpc-connectors#delete) it to avoid continued billing.\n\nMigrate services to Direct VPC egress gradually\n-----------------------------------------------\n\nWhen you migrate Cloud Run services from Serverless VPC Access\nconnectors to Direct VPC egress, we recommend that you do so in a gradual\ntransition.\n\nTo transition gradually:\n\n1. Follow the instructions in this section to update your service to use Direct VPC egress.\n2. [Split a small percentage of traffic](/run/docs/rollouts-rollbacks-traffic-migration#split-traffic) to determine whether the traffic works correctly.\n3. Update the traffic split to send all traffic to the new revision using Direct VPC egress.\n\nTo migrate traffic with Direct VPC egress for a service, use the\nGoogle Cloud console or Google Cloud CLI: \n\n### Console\n\n1. In the Google Cloud console, go to the **Cloud Run** page.\n\n [Go to Cloud Run](https://console.cloud.google.com/run)\n2. Click the service that you want to migrate from a connector to Direct\n VPC egress, then click **Edit and deploy new revision**.\n\n3. Click the **Networking** tab.\n\n4. From **Connect to a VPC for outbound traffic** , click **Send traffic directly to a VPC**.\n\n5. In the **Network** field, select the VPC\n network that you want to send traffic to.\n\n6. In the **Subnet** field, select the subnet where your service receives IP\n addresses from. You can deploy multiple services on the same subnet.\n\n7. Optional: Enter the names of the [network tags](/vpc/docs/add-remove-network-tags#restrictions)\n that you want to associate with your service or services. Network tags are\n specified at the revision-level. Each service revision can have different\n network tags, such as `network-tag-2`.\n\n8. For **Traffic routing**, select one of the following:\n\n - **Route only requests to private IPs to the VPC** to send only traffic to internal addresses through the VPC network.\n - **Route all traffic to the VPC** to send all outbound traffic through the VPC network.\n9. Click **Deploy**.\n\n10. To verify that your service is on your VPC network, click\n the service, then click the **Networking** tab. The network and subnet\n are listed in the **VPC** card.\n\n You can now send requests directly from your Cloud Run service to\n any resource on the VPC network, as allowed by your\n firewall rules.\n\n### gcloud\n\n\nTo migrate a Cloud Run service from a connector to Direct VPC\negress using the Google Cloud CLI:\n\n1. Update your Cloud Run service with the following command:\n\n ```bash\n gcloud run services update SERVICE_NAME \\\n --clear-vpc-connector \\\n --network=NETWORK \\\n --subnet=SUBNET \\\n --network-tags=NETWORK_TAG_NAMES \\\n --vpc-egress=EGRESS_SETTING \\\n --region=REGION\n ```\n\n Replace:\n - \u003cvar translate=\"no\"\u003eSERVICE_NAME\u003c/var\u003e with the name of your service.\n - \u003cvar translate=\"no\"\u003eNETWORK\u003c/var\u003e with the name of your VPC network.\n - \u003cvar translate=\"no\"\u003eSUBNET\u003c/var\u003e with the name of your subnet. You can deploy or execute multiple services or jobs on the same subnet.\n - Optional: \u003cvar translate=\"no\"\u003eNETWORK_TAG_NAMES\u003c/var\u003e with the comma-separated names of the [network tags](/vpc/docs/add-remove-network-tags#restrictions) you want to associate with a service. For services, network tags are specified at the revision-level. Each service revision can have different network tags, such as `network-tag-2`.\n - \u003cvar translate=\"no\"\u003eEGRESS_SETTING\u003c/var\u003e with an [egress setting value](/sdk/gcloud/reference/run/deploy#--vpc-egress):\n - `all-traffic`: Sends all outbound traffic through the VPC network.\n - `private-ranges-only`: Sends only traffic to internal addresses through the VPC network.\n - \u003cvar translate=\"no\"\u003eREGION\u003c/var\u003e with a region for your service.\n2. To verify that your service is on your VPC network, run\n the following command:\n\n ```bash\n gcloud run services describe SERVICE_NAME \\\n --region=REGION\n ```\n\n Replace:\n - \u003cvar translate=\"no\"\u003eSERVICE_NAME\u003c/var\u003e with the name of your service.\n - \u003cvar translate=\"no\"\u003eREGION\u003c/var\u003e with the region for your service that you specified in the previous step.\n\n The output should contain the name of your network, subnet, and egress\n setting, for example: \n\n VPC access:\n Network: default\n Subnet: subnet\n Egress: private-ranges-only\n\nYou can now send requests from your Cloud Run service to any\nresource on the VPC network, as allowed by your firewall\nrules.\n\nMigrate jobs to Direct VPC egress\n---------------------------------\n\n| **Important:** Connectors continue to incur charges even if they have no traffic and are disconnected. For details, see [pricing](/vpc/pricing#serverless-vpc-pricing). If you no longer need your connector, be sure to [delete](/run/docs/configuring/vpc-connectors#delete) it to avoid continued billing.\n\nYou can migrate traffic with Direct VPC egress for a job by using the\nGoogle Cloud console or Google Cloud CLI. \n\n### Console\n\n1. In the Google Cloud console, go to the **Cloud Run** page.\n\n [Go to Cloud Run](https://console.cloud.google.com/run)\n2. Click the job that you want to migrate from a connector to Direct\n VPC egress, then click **Edit**.\n\n3. Click the **Networking** tab.\n\n4. Click **Container, Variables \\& Secrets, Connections, Security** to\n expand the job properties page.\n\n5. Click the **Connections** tab.\n\n6. From **Connect to a VPC for outbound traffic** , click **Send traffic directly to a VPC**.\n\n7. In the **Network** field, select the VPC\n network that you want to send traffic to.\n\n8. In the **Subnet** field, select the subnet where your job receives IP\n addresses from. You can deploy multiple jobs on the same subnet.\n\n9. Optional: Enter the names of the [network tags](/vpc/docs/add-remove-network-tags#restrictions)\n that you want to associate with your service or services. Network tags are\n specified at the revision-level. Each service revision can have different\n network tags, such as `network-tag-2`.\n\n10. For **Traffic routing**, select one of the following:\n\n - **Route only requests to private IPs to the VPC** to send only traffic to internal addresses through the VPC network.\n - **Route all traffic to the VPC** to send all outbound traffic through the VPC network.\n11. Click **Update**.\n\n12. To verify that your job is on your VPC network, click\n the job, then click the **Configuration** tab. The network and subnet are\n listed in the **VPC** card.\n\nYou can now execute your Cloud Run job and send requests from the\njob to any resource on the VPC network, as allowed by your\nfirewall rules.\n\n### gcloud\n\n\nTo migrate a Cloud Run job from a connector to Direct VPC\negress using the Google Cloud CLI:\n\n1. Update your Cloud Run job with the following command:\n\n ```bash\n gcloud run jobs update JOB_NAME \\\n --clear-network \\\n --image=IMAGE_URL \\\n --network=NETWORK \\\n --subnet=SUBNET \\\n --network-tags=NETWORK_TAG_NAMES \\\n --vpc-egress=EGRESS_SETTING \\\n --region=REGION\n ```\n\n Replace:\n - \u003cvar translate=\"no\"\u003eJOB_NAME\u003c/var\u003e with the name of your job.\n - \u003cvar translate=\"no\"\u003eNETWORK\u003c/var\u003e with the name of your VPC network.\n - \u003cvar translate=\"no\"\u003eSUBNET\u003c/var\u003e with the name of your subnet. You can deploy or execute multiple services or jobs on the same subnet.\n - Optional: \u003cvar translate=\"no\"\u003eNETWORK_TAG_NAMES\u003c/var\u003e with the names of the [network tags](/vpc/docs/add-remove-network-tags#restrictions) you want to associate with a job. For jobs, network tags are specified at the execution-level. Each job execution can have different network tags, such as `network-tag-2`.\n - \u003cvar translate=\"no\"\u003eEGRESS_SETTING\u003c/var\u003e with an [egress setting value](/sdk/gcloud/reference/run/deploy#--vpc-egress):\n - `all-traffic`: Sends all outbound traffic through the VPC network.\n - `private-ranges-only`: Sends only traffic to internal addresses through the VPC network.\n - \u003cvar translate=\"no\"\u003eREGION\u003c/var\u003e with a region for your job.\n2. To verify that your job is on your VPC network, run\n the following command:\n\n ```bash\n gcloud run jobs describe JOB_NAME \\\n --region=REGION\n ```\n\n Replace:\n - \u003cvar translate=\"no\"\u003eJOB_NAME\u003c/var\u003e with the name of your job.\n - \u003cvar translate=\"no\"\u003eREGION\u003c/var\u003e with the region for your job that you specified in the previous step.\n\n The output should contain the name of your network, subnet, and egress\n setting, for example: \n\n VPC access:\n Network: default\n Subnet: subnet\n Egress: private-ranges-only\n\nYou can now send requests from your Cloud Run job to any\nresource on the VPC network, as allowed by your firewall\nrules."]]