Tetap teratur dengan koleksi
Simpan dan kategorikan konten berdasarkan preferensi Anda.
Halaman ini menjelaskan pembuatan layanan dan menampilkan informasi tentang layanan.
Layanan adalah resource utama penayangan Knative.
Membuat service
Anda membuat layanan baru dan revisi-nya dengan
men-deploy image container ke layanan tersebut untuk pertama kalinya. Lihat
Men-deploy layanan baru untuk mempelajari lebih lanjut cara membuat layanan.
Melihat daftar layanan di project Anda
Anda dapat melihat daftar layanan yang tersedia di project Anda menggunakan
konsolGoogle Cloud atau Google Cloud CLI:
Periksa daftar layanan yang ditampilkan untuk project Anda:
Command line
Untuk mencantumkan layanan dalam project Anda:
gcloud run services list
Anda dapat memfilter daftar ini berdasarkan properti definisi layanan, seperti
label yang ditetapkan.
Menyalin layanan
Anda dapat membuat salinan layanan yang ada menggunakan konsol Google Cloud atau YAML.
Anda dapat mengubah apa pun yang Anda inginkan di salinan, termasuk nama dan region.
Pilih layanan yang akan disalin dari daftar layanan yang ditampilkan untuk
project Anda:
Klik Copy.
Di halaman salinan layanan, tetapkan atau ubah nilai apa pun yang ingin Anda ubah,
seperti region, dll. Jika Anda mempertahankan region yang sama, Anda harus memberikan
nama baru untuk layanan tersebut.
Klik Buat untuk membuat salinan dan men-deploy-nya menggunakan
nama layanan baru.
YAML
Anda dapat mendownload konfigurasi layanan yang ada ke dalam
file YAML dengan perintah gcloud run services describe menggunakan
tanda --format=export.
Kemudian, Anda dapat mengubah file YAML tersebut dan men-deploy
perubahan tersebut dengan perintah gcloud run services replace.
Anda harus memastikan bahwa Anda hanya mengubah atribut yang ditentukan.
Download konfigurasi layanan Anda ke dalam file bernama
service.yaml di ruang kerja lokal:
Jika Anda men-deploy salinan ke cluster Kubernetes yang sama, ganti
SERVICE dengan nama yang ingin Anda gunakan untuk salinan tersebut. Jika Anda
men-deploy salinan ke cluster Kubernetes yang berbeda, Anda dapat menggunakan
nama yang sama.
Pastikan nilai untuk REVISION-NAME dimulai dengan nama
layanan (SERVICE). Misalnya, jika nama layanan baru adalah
mynewfoo, nama revisi harus dalam format mynewfoo-whatever.
Anda juga dapat menghapus nilai secara keseluruhan dan nama revisi baru akan dibuat secara otomatis.
Salin layanan menggunakan perintah berikut:
gcloudrunservicesreplaceservice.yaml
Gunakan flag --region
untuk men-deploy salinan ke region yang berbeda.
Melihat detail lengkap mengenai layanan
Untuk melihat detail selengkapnya mengenai layanan,
Klik layanan yang diinginkan dalam daftar layanan yang ditampilkan untuk
project Anda guna membuka tampilan detail layanan:
Perhatikan tab REVISIONS, LOGS, dan DETAILS. Tab revisi menampilkan daftar revisi, tab log menampilkan log layanan, dan tab detail menampilkan setelan autentikasi atau konektivitas saat ini.
Command line
Untuk melihat detail layanan:
gcloudrunservicesdescribeSERVICE
Ganti SERVICE dengan nama layanan.
Anda dapat menggunakan tanda --format untuk memformat
output. Contohnya sebagai YAML:
gcloudrunservicesdescribeSERVICE--formatyaml
Anda dapat menggunakan --format export untuk mengekspor sebagai YAML tanpa
label atau status yang dibuat secara otomatis:
gcloudrunservicesdescribeSERVICE--formatexport
Anda juga dapat menggunakan flag --format untuk mendapatkan
URL layanan:
Klik layanan yang diinginkan dalam daftar layanan yang ditampilkan untuk
project Anda guna membuka tampilan detail layanan.
Klik tab Trigger.
Pilih setelan yang diinginkan, lalu klik Simpan.
Command line
Untuk mengubah setelan konektivitas layanan, perbarui layanan dengan setelan konektivitas yang diinginkan:
gcloud run services update [SERVICE] --connectivity=[OPTION]
Ganti [SERVICE] dengan nama layanan yang sedang Anda update.
Anda dapat menghilangkan parameter ini sepenuhnya, tetapi Anda akan diminta untuk memasukkan nama layanan jika mengabaikannya.
Mengganti [OPTION] dengan internal atau external.
Menghapus layanan yang ada
Menghapus layanan akan menghapus semua resource yang terkait dengan layanan ini, termasuk semua
revisi layanan ini, terlepas dari apakah layanan tersebut melayani traffic atau tidak.
Saat menghapus layanan, image container yang digunakan oleh revisi yang dihapus tidak akan
dihapus secara otomatis dari Container Registry. Untuk menghapus image container dari
Container Registry, lihat Menghapus image.
Perhatikan bahwa penghapusan layanan bersifat permanen: tidak dapat diurungkan atau dipulihkan.
Namun, jika setelah menghapus layanan, Anda men-deploy layanan baru dengan nama yang sama di cluster yang sama, layanan tersebut akan memiliki URL endpoint yang sama.
[[["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-07-31 UTC."],[],[],null,["# Managing services\n\nThis page describes creating a service and viewing information about a service.\nServices are the main resources of Knative serving.\n\nCreating a service\n------------------\n\nYou create a new service and its [revision](/kubernetes-engine/enterprise/knative-serving/docs/managing/revisions) by\ndeploying a container image to it for the first time. See\n[Deploying a new service](/kubernetes-engine/enterprise/knative-serving/docs/deploying#service) to learn more about\ncreating services.\n\nViewing the list of services in your project\n--------------------------------------------\n\nYou can view a list of the available services in your project using\nGoogle Cloud console or the Google Cloud CLI: \n\n### Console\n\nTo view the services list:\n\n1. Go to Knative serving in the Google Cloud console:\n\n [Go to Knative serving](https://console.cloud.google.com/kubernetes/run)\n2. Examine the displayed list of services for your project:\n\n### Command line\n\nTo list the services in your project: \n\n gcloud run services list\n\nYou can filter this list by properties of the service definition, such as an\n[assigned label](/kubernetes-engine/enterprise/knative-serving/docs/configuring/labels#label-listing).\n\nCopying a service\n-----------------\n\nYou can make a copy of an existing service using Google Cloud console or YAML.\nYou can change anything you want in the copy, including name and region. \n\n### Console\n\nTo copy a service:\n\n1. Go to Knative serving in the Google Cloud console:\n\n [Go to Knative serving](https://console.cloud.google.com/kubernetes/run)\n2. Select the service to copy from the displayed list of services for your\n project:\n\n 1. Click **Copy**.\n\n 2. In the service copy page, set or change any values you want to change,\n such as region, etc. If you are keeping the same region, you must provide a\n new name for the service.\n\n 3. Click **Create** to make a copy and deploy it using the new service\n name.\n\n### YAML\n\n| **Caution:** Deploying configuration changes using YAML files replaces the configuration of your existing services. Since a YAML file completely overwrites all configurations, you should avoid using multiple methods to modify your services. For example, do not use YAML files in conjunction with the Google Cloud console or `gcloud` commands.\n\nYou can download the configuration of an existing service into a\nYAML file with the `gcloud run services describe` command by using the\n[`--format=export`](/sdk/gcloud/reference/run/services/describe) flag.\nYou can then modify that YAML file and deploy\nthose changes with the `gcloud run services replace` command.\nYou must ensure that you modify only the specified attributes.\n\n1. Download the configuration of your service into a file named\n `service.yaml` on local workspace:\n\n ```bash\n gcloud run services describe SERVICE --format export \u003e service.yaml\n ```\n\n Replace \u003cvar translate=\"no\"\u003eSERVICE\u003c/var\u003e with the name of your\n Knative serving service.\n2. Make any desired configuration changes to the service as described in the\n various [configuration pages](/kubernetes-engine/enterprise/knative-serving/docs/how-to#configure).\n\n apiVersion: serving.knative.dev/v1\n kind: Service\n metadata:\n annotations:\n ...\n name: \u003cvar translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-l devsite-syntax-l-Scalar devsite-syntax-l-Scalar-Plain\"\u003eSERVICE\u003c/span\u003e\u003c/var\u003e\n ...\n spec:\n template:\n metadata:\n annotations:\n ...\n name: \u003cvar translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-l devsite-syntax-l-Scalar devsite-syntax-l-Scalar-Plain\"\u003eREVISION-NAME\u003c/span\u003e\u003c/var\u003e\n\n - If you are deploying the copy to the same Kubernetes cluster, replace\n \u003cvar translate=\"no\"\u003eSERVICE\u003c/var\u003e with the name you want to use for the copy. If you are\n deploying the copy to a different Kubernetes cluster, you can use the\n same name.\n\n - Make sure the value for \u003cvar translate=\"no\"\u003eREVISION-NAME\u003c/var\u003e starts with the service\n name (\u003cvar translate=\"no\"\u003eSERVICE\u003c/var\u003e). For example, if the new service name is\n `mynewfoo`, then the revision name must be in the format `mynewfoo-whatever`.\n Optionally delete the value altogether and a new revision name is created\n automatically.\n\n3. Copy the service using the following command:\n\n ```bash\n gcloud run services replace service.yaml\n ```\n\n Use the [`--region`](/sdk/gcloud/reference/run/services/replace#--region)\n flag to deploy the copy to a different region.\n\nViewing more details about a service\n------------------------------------\n\nTo see more details about a service, \n\n### Console\n\nTo view a service's details:\n\n1. Go to Knative serving in the Google Cloud console:\n\n [Go to Knative serving](https://console.cloud.google.com/kubernetes/run)\n2. Click on the desired service in the displayed list of services for your\n project to open the service details view:\n\n3. Note the **REVISIONS** , **LOGS** and **DETAILS** tabs. The revisions tab\n shows the list of revisions, the logs tab shows the [service logs](/kubernetes-engine/enterprise/knative-serving/docs/logging),\n and the details tab shows the current\n [authentication](/kubernetes-engine/enterprise/knative-serving/docs/deploying#service) or\n [connectivity](#connectivity) settings.\n\n### Command line\n\nTo view details about a service: \n\n```bash\ngcloud run services describe SERVICE\n```\nReplace \u003cvar translate=\"no\"\u003eSERVICE\u003c/var\u003e with the name of the service.\n\n\u003cbr /\u003e\n\nYou can use the [`--format` flag](/sdk/gcloud/reference#--format) to format\nthe output. For example as YAML: \n\n```bash\ngcloud run services describe SERVICE --format yaml\n```\n\nYou can use `--format export` to export as YAML without automatically\ngenerated labels or status: \n\n```bash\ngcloud run services describe SERVICE --format export\n```\n\nYou can also use the [`--format` flag](/sdk/gcloud/reference#--format) to get\nthe URL of the service: \n\n```bash\ngcloud run services describe SERVICE --format='value(status.url)'\n```\n\n\u003cbr /\u003e\n\nFor details about the revisions of a service, see\n[Managing Revisions](/kubernetes-engine/enterprise/knative-serving/docs/managing/revisions).\n\nChanging service connectivity settings\n--------------------------------------\n\nA Knative serving service can have either of two connection options:\n\n- *external*, which allows external access to your service\n\n- *internal* which restricts access only to other services in your cluster.\n\nYou can use the console or the Google Cloud CLI to change the settings. \n\n### Console\n\nTo change service connectivity settings:\n\n1. Go to Knative serving in the Google Cloud console:\n\n [Go to Knative serving](https://console.cloud.google.com/kubernetes/run)\n2. Click on the desired service in the displayed list of services for your\n project to open the service details view.\n\n3. Click the **Triggers** tab.\n\n4. Select the desired setting and click **Save**.\n\n### Command line\n\nTo change service connectivity settings, update the service with the desired\nconnectivity setting: \n\n gcloud run services update [SERVICE] --connectivity=[OPTION]\n\n- Replace `[SERVICE]` with the name of the service you are updating.\n You can omit this parameter entirely, but you will be prompted for the\n service name if you omit it.\n\n- Replace `[OPTION]` with `internal` or `external`.\n\nDeleting existing services\n--------------------------\n\nDeleting a service deletes all resources related to this service, including all\nrevisions of this service whether they are serving traffic or not.\n\nWhen deleting a service, the container images used by the deleted revisions are not\ndeleted automatically from Container Registry. To delete container images from\nContainer Registry see [Deleting images](/container-registry/docs/managing#deleting_images).\n\nNote that deleting a service is permanent: there is no undo or restore.\nHowever, if after deleting a service, you deploy a new service with the same\nname in the same cluster, it will have the same endpoint URL. \n\n### Console\n\nTo delete a service:\n\n1. Go to Knative serving in the Google Cloud console:\n\n [Go to Knative serving](https://console.cloud.google.com/kubernetes/run)\n2. Locate the service you want to delete in the services list, and click\n its checkbox to select it.\n\n3. Click **DELETE**. This deletes all revisions of the service.\n\n### Command line\n\nTo delete a service, use the command: \n\n gcloud run services delete [SERVICE]\n\nReplace `[SERVICE]` with the name of your service."]]