Memigrasikan layanan penayangan Knative ke Cloud Run
Tetap teratur dengan koleksi
Simpan dan kategorikan konten berdasarkan preferensi Anda.
Gunakan panduan ini untuk memigrasikan workload Anda ke Cloud Run. Secara umum,
untuk memigrasikan workload, Anda harus melakukan port-over pada salah satu fitur berbasis Kubernetes,
lalu men-deploy ulang setiap layanan yang ada ke Cloud Run.
Anda dapat menggunakan IAM di Cloud Run untuk mendapatkan kontrol yang sama atas akses ke resource Anda. Pertimbangkan juga untuk menggunakan Identitas layanan.
Pertimbangan migrasi
Anda harus meninjau dan memahami perbedaan berikut di seluruh produk untuk
memastikan bahwa Anda dapat melakukan port semua dependensi dan persyaratan.
Rahasia
Di Cloud Run, Anda dapat memilih untuk memasang secret sebagai variabel atau volume lingkungan, tetapi secret dengan informasi sensitif harus disimpan di Secret Manager.
DomainMapping API Cloud Run kompatibel dengan layanan Knative. Namun, Cloud Run menawarkan pemetaan domain dalam subset dari lokasi Cloud Run yang tersedia.
Alternatif yang direkomendasikan adalah memanfaatkan
Global HTTP(S) Load Balancer untuk
domain kustom Anda.
Konektivitas VPC
Layanan Cloud Run berada di luar VPC Anda. Untuk berkomunikasi dengan
resource dalam VPC, Anda harus menggunakan
Konektor Akses VPC Serverless.
Kontrol traffic masuk
Jika layanan penayangan Knative Anda dikonfigurasi untuk jaringan internal
pribadi dan menggunakan load balancer internal (ILB), Anda dapat mengonfigurasi
layanan Cloud Run ke Ingress = Internal.
Mengonfigurasi layanan ke internal akan membatasi akses ke dalam VPC atau layanan Cloud Run lainnya.
Pelajari komunikasi layanan ke layanan lebih lanjut.
Memigrasikan layanan
Untuk memigrasikan layanan, Anda harus mengekspor layanan penayangan Knative, mengedit file YAML yang diekspor, lalu men-deploy layanan yang dikonfigurasi ulang ke Cloud Run.
Ekspor layanan penayangan Knative Anda ke file YAML lokal dengan menjalankan perintah berikut:
SERVICE dengan nama layanan penayangan
Knative Anda.
NAMESPACE dengan namespace tempat layanan Anda
berjalan.
CLUSTER dengan nama cluster tempat layanan Anda berjalan.
FILENAME dengan nama file unik pilihan Anda.
Ubah file FILENAME.yaml yang diekspor untuk Cloud Run:
Anda harus menelusuri dan mengganti namespace Kubernetes dengan ID projectGoogle Cloud Anda. Misalnya, Anda harus mengganti namespace:default
dengan namespace:my-unique-id.
Secara default, layanan Cloud Run tidak dapat diakses secara eksternal. Untuk
mengekspos layanan secara publik ke internet dan mengizinkan permintaan
yang tidak diautentikasi, Anda harus
mengizinkan akses publik (tidak diautentikasi).
Untuk mengonfigurasi layanan ini untuk akses khusus internal pribadi seperti antara layanan Cloud Run Anda, lihat Mengautentikasi layanan-ke-layanan.
Di konsol Google Cloud , dalam halaman layanan, Anda dapat mengklik
link URL yang ditampilkan untuk membuka endpoint yang unik dan stabil dari layanan
yang di-deploy.
Setelah menguji layanan yang baru di-deploy dan siap memigrasikan semua
traffic produksi, Anda dapat mengonfigurasi domain kustom dan memperbarui
data DNS dengan registrar. Ikuti petunjuk di
Memetakan domain kustom.
[[["Mudah dipahami","easyToUnderstand","thumb-up"],["Memecahkan masalah saya","solvedMyProblem","thumb-up"],["Lainnya","otherUp","thumb-up"]],[["Sulit dipahami","hardToUnderstand","thumb-down"],["Informasi atau kode contoh salah","incorrectInformationOrSampleCode","thumb-down"],["Informasi/contoh yang saya butuhkan tidak ada","missingTheInformationSamplesINeed","thumb-down"],["Masalah terjemahan","translationIssue","thumb-down"],["Lainnya","otherDown","thumb-down"]],["Terakhir diperbarui pada 2025-09-01 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)."]]