Stay organized with collections
Save and categorize content based on your preferences.
Use this guide to migrate your workloads to Cloud Run. In general,
migrating your workloads requires you to port over any of the Kubernetes-based
features and then redeploy each of your existing services to Cloud Run.
You must review and understand the following differences across the products to
ensure that you can port over all your dependencies and requirements.
Secrets
In Cloud Run, you can choose to mount secrets as environment variables
or volumes, but secrets with sensitive information should be stored in
Secret Manager.
Cloud Run services reside outside your VPC. To communicate with
resources within a VPC, you must use the
Serverless VPC Access Connector.
Ingress controls
If your Knative serving service is configured for a private internal
network and uses an internal load balancer (ILB), you can configure your
Cloud Run service to Ingress = Internal.
Configuring your services to internal restricts access to within your VPC or
other Cloud Run services.
Learn more about service to service communication.
Migrating a service
To migrate a service, you must export your Knative serving service, edit
the exported YAML file, and then deploy your reconfigured service to
Cloud Run.
Export your Knative serving service to a local YAML file by running
the following command:
SERVICE with the name of your
Knative serving service.
NAMESPACE with the namespace where your
service is running.
CLUSTER with the name of the cluster where
your service is running.
FILENAME with a unique filename of your
choice.
Modify the exported FILENAME.yaml file for
Cloud Run:
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.
By default, a Cloud Run service is not externally accessible. To
publicly expose your service to the internet and allow unauthenticated
requests, you must
allow public (unauthenticated) access.
To configure this service for private internal-only access like between
your Cloud Run services, see
Authenticating service-to-service.
In the Google Cloud console, within your services page, you can click the
displayed URL link to open the unique and stable endpoint of your deployed
service.
After you have tested your newly deployed services and are ready to migrate all
of your production traffic, you can configure your custom domain and update your
DNS records with your registrar. Follow the instructions at
Mapping custom domains.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-29 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)."]]