Organiza tus páginas con colecciones
Guarda y categoriza el contenido según tus preferencias.
Usa esta guía para migrar tus cargas de trabajo a Cloud Run. En general, para migrar tus cargas de trabajo, debes transferir cualquiera de las funciones basadas en Kubernetes y, luego, volver a implementar cada uno de los servicios existentes en Cloud Run.
Puedes usar IAM en Cloud Run para lograr el mismo control sobre el acceso a tus recursos. También considera usar Service Identity.
Consideraciones sobre la migración
Debes revisar y comprender las siguientes diferencias entre los productos para asegurarte de que puedas transferir todas las dependencias y requisitos.
Secrets
En Cloud Run, puedes elegir activar Secrets como variables de entorno o volúmenes, pero los Secrets con información sensible se deben almacenar en Secret Manager.
Si tu Knative serving está configurado para una red interna privada y usa un balanceador de cargas interno (ILB), puedes configurar el servicio de Cloud Run como Ingress = Internal.
Configurar tus servicios como internal restringe el acceso a tu VPC o a otros servicios de Cloud Run.
Obtén más información sobre la comunicación de servicio a servicio.
Migra un servicio
Para migrar un servicio, debes exportar tu servicio de Knative serving, editar el archivo YAML exportado y, luego, implementar el servicio reconfigurado en Cloud Run.
Exporta tu servicio de Knative serving a un archivo YAML local mediante la ejecución del siguiente comando:
SERVICE por el nombre de tu servicio de Knative serving.
NAMESPACE por el espacio de nombres en el que se ejecuta el servicio.
CLUSTER por el nombre del clúster en el que se ejecuta el servicio.
FILENAME por un nombre de archivo único de tu elección.
Modifica el archivo FILENAME.yaml exportado para Cloud Run:
Debes buscar y reemplazar el espacio de nombres de Kubernetes con el ID de tu proyecto de Google Cloud. Por ejemplo, debes reemplazar namespace:default por namespace:my-unique-id.
Según la configuración predeterminada, un servicio de Cloud Run no es accesible de forma externa. Para exponer tu servicio de forma pública a Internet y permitir las solicitudes no autenticadas, debes permitir el acceso público (no autenticado).
Si deseas configurar este servicio para el acceso privado solo interno, como entre tus servicios de Cloud Run, consulta Autenticación de servicio a servicio.
En la consola de Google Cloud, dentro de la página de servicios, puedes hacer clic en el vínculo de la URL que se muestra para abrir el extremo único y estable del servicio implementado.
Después de probar los servicios recién implementados y estar listo para migrar todo el tráfico de producción, puedes configurar el dominio personalizado y actualizar los registros DNS con el registrador. Sigue las instrucciones de Asigna dominios personalizados.
[[["Fácil de comprender","easyToUnderstand","thumb-up"],["Resolvió mi problema","solvedMyProblem","thumb-up"],["Otro","otherUp","thumb-up"]],[["Difícil de entender","hardToUnderstand","thumb-down"],["Información o código de muestra incorrectos","incorrectInformationOrSampleCode","thumb-down"],["Faltan la información o los ejemplos que necesito","missingTheInformationSamplesINeed","thumb-down"],["Problema de traducción","translationIssue","thumb-down"],["Otro","otherDown","thumb-down"]],["Última actualización: 2025-04-22 (UTC)"],[],[],null,["# Migrating a Knative serving service to Cloud Run\n\nUse this guide to migrate your workloads to Cloud Run. In general,\nmigrating your workloads requires you to port over any of the Kubernetes-based\nfeatures and then redeploy each of your existing services to Cloud Run.\n\nKey benefits of migrating to Cloud Run:\n\n- Fully managed serverless product that implements the\n [Knative Serving API specification](https://github.com/knative/specs/blob/main/specs/serving/knative-api-specification-1.0.md)\n and adheres to the container contract.\n\n- The [v1 Admin API of Cloud Run](/run/docs/reference/rest) is designed\n to maximize portability with Knative serving.\n\n- The user experience is similar across Cloud Run and Knative serving:\n\n - The `gcloud run` command group is used across both products.\n - Similar user interface layout and behavior in Google Cloud console.\n\nBefore you begin\n----------------\n\nThe following Google Kubernetes Engine features are not supported in Cloud Run,\nincluding:\n\n- Cluster and pod features, for example [Startup, Liveness and Readiness\n probes, and Service Discovery](/kubernetes-engine/docs/concepts/kubernetes-engine-overview).\n- Configuration:\n - [ConfigMaps](/anthos/run/archive/docs/configuring/using-configmaps) - You can transform your ConfigMaps into secrets with Secret Manager.\n - [NVIDIA GPUs](/anthos/run/archive/docs/configuring/compute-power-gpu)\n- Access controls:\n\n - [GKE specific IAM\n roles](/anthos/run/docs/deploying#permissions_required_to_deploy)\n - [Workload Identity](/anthos/run/archive/docs/configuring/workload-identity)\n - [Cluster multi-tenancy](/anthos/run/archive/docs/multi-tenancy)\n\n You can use\n [IAM in Cloud Run](/run/docs/securing/managing-access)\n to achieve the same control over access to your resources. Also consider\n using [Service identity](/run/docs/securing/service-identity).\n\nMigration considerations\n------------------------\n\nYou must review and understand the following differences across the products to\nensure that you can port over all your dependencies and requirements.\n\n### Secrets\n\nIn Cloud Run, you can choose to mount secrets as environment variables\nor volumes, but secrets with sensitive information should be stored in\n[Secret Manager](/secret-manager).\n\nImportant differences between\n[secrets in Secret Manager](/secret-manager/docs/overview) and\n[Kubernetes secrets](https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names):\n\nLearn how to use Secret Manager to\n[create versioned secrets](/secret-manager/docs/creating-and-accessing-secrets#create)\nfor the secret keys of your Knative serving services.\n\n### Networking\n\nUse the following information to help you port over your existing network\nconfiguration to Cloud Run.\n\nService Endpoints\n: The\n [Kubernetes Endpoints](/kubernetes-engine/docs/concepts/service#service_endpoints)\n of your Knative serving services are not supported in Cloud Run.\n [Learn more about the unique endpoints in Cloud Run](/run/docs/resource-model).\n\nDomains Mappings\n: The Cloud Run\n [DomainMapping API](/run/docs/reference/rest/v1/namespaces.domainmappings#DomainMapping)\n is compatible with Knative serving. However, Cloud Run offers\n domain mapping in a subset of the available\n [Cloud Run locations](/run/docs/locations#domains).\n A recommended alternative is to leverage\n [Global HTTP(S) Load Balancer](/run/docs/mapping-custom-domains) for your\n custom domains.\n\nVPC connectivity\n: Cloud Run services reside outside your VPC. To communicate with\n resources within a VPC, you must use the\n [Serverless VPC Access Connector](/run/docs/securing/using-vpc-service-controls).\n\nIngress controls\n: If your Knative serving service is configured for a private internal\n network and uses an internal load balancer (ILB), you can configure your\n Cloud Run service to [`Ingress = Internal`](/run/docs/securing/ingress).\n Configuring your services to `internal` restricts access to within your VPC or\n other Cloud Run services.\n [Learn more about service to service communication](/run/docs/authenticating/service-to-service).\n\nMigrating a service\n-------------------\n\nTo migrate a service, you must export your Knative serving service, edit\nthe exported YAML file, and then deploy your reconfigured service to\nCloud Run.\n| **Note:** If you obtain and use the [original YAML configuration file](/anthos/run/docs/deploying#yaml) that you initially created for Knative serving, you can skip the export and modify steps. With the original YAML configuration file, you can simply [deploy it directly to Cloud Run](#deploy) to create your services.\n\n1. Export your Knative serving service to a local YAML file by running\n the following command:\n\n gcloud run services describe \u003cvar translate=\"no\"\u003eSERVICE\u003c/var\u003e --format export --namespace \u003cvar translate=\"no\"\u003eNAMESPACE\u003c/var\u003e --cluster \u003cvar translate=\"no\"\u003eCLUSTER\u003c/var\u003e --platform gke \u003e \u003cvar translate=\"no\"\u003eFILENAME\u003c/var\u003e.yaml\n\n Replace:\n - \u003cvar translate=\"no\"\u003eSERVICE\u003c/var\u003e with the name of your Knative serving service.\n - \u003cvar translate=\"no\"\u003eNAMESPACE\u003c/var\u003e with the namespace where your service is running.\n - \u003cvar translate=\"no\"\u003eCLUSTER\u003c/var\u003e with the name of the cluster where your service is running.\n - \u003cvar translate=\"no\"\u003eFILENAME\u003c/var\u003e with a unique filename of your choice.\n2. Modify the exported \u003cvar translate=\"no\"\u003eFILENAME\u003c/var\u003e`.yaml` file for\n Cloud Run:\n\n - You must search and replace the Kubernetes namespace with the ID of your Google Cloud project. For example, you must replace `namespace:`*`default`* with `namespace:`**`my-unique-id`**.\n - You must update all configurations for any of the [unsupported features](#before_you_begin).\n - You must delete any of the following attributes and their values:\n\n - `metadata.annotations.kubectl.kubernetes.io/last-applied-configuration`\n - `metadata.managedFields`\n - `spec.template.spec.containers.readinessProbes`\n - `spec.template.spec.enableServiceLinks`\n\n For example, you might need to remove the following configuration from\n under the `spec:` \\\u003e `template:` \\\u003e `spec:` \\\u003e `containers:` attributes: \n\n ...\n readinessProbe:\n successThreshold: 1\n tcpSocket: {}\n ...\n\n3. Deploy the modified `.yaml` file to Cloud Run using the\n `--platform managed` flag. [Learn more about deploying](/run/docs/deploying).\n\n Note that you can use the same Google Cloud project for Cloud Run. \n\n gcloud run services replace \u003cvar translate=\"no\"\u003eFILENAME\u003c/var\u003e.yaml --platform managed --region \u003cvar translate=\"no\"\u003eREGION\u003c/var\u003e\n\n Replace:\n - \u003cvar translate=\"no\"\u003eFILENAME\u003c/var\u003e with the name of the exported configuration file that you created.\n - \u003cvar translate=\"no\"\u003eREGION\u003c/var\u003e with a [supported\n Cloud Run location](/run/docs/locations). For example: `us-central1`\n4. Configure access to your Cloud Run service:\n\n - By default, a Cloud Run service is not externally accessible. To\n publicly expose your service to the internet and allow unauthenticated\n requests, you must\n [allow public (unauthenticated) access](/run/docs/authenticating/public).\n\n - To configure this service for private internal-only access like between\n your Cloud Run services, see\n [Authenticating service-to-service](/run/docs/authenticating/service-to-service).\n\n5. In the Google Cloud console, within your services page, you can click the\n displayed URL link to open the unique and stable endpoint of your deployed\n service.\n\n [Go to Cloud Run](https://console.cloud.google.com/run)\n\nMigrating traffic to your service\n---------------------------------\n\nAfter you have tested your newly deployed services and are ready to migrate all\nof your production traffic, you can configure your custom domain and update your\nDNS records with your registrar. Follow the instructions at\n[Mapping custom domains](/run/docs/mapping-custom-domains)."]]