Mantieni tutto organizzato con le raccolte
Salva e classifica i contenuti in base alle tue preferenze.
Questa pagina descrive la creazione di un servizio e la visualizzazione delle informazioni su un servizio.
I servizi sono le risorse principali di Knative serving.
crea un servizio
Puoi creare un nuovo servizio e la relativa revisione eseguendo per la prima volta il deployment di un'immagine container. Per scoprire di più sulla creazione dei servizi, consulta
Eseguire il deployment di un nuovo servizio.
Visualizzare l'elenco dei servizi nel progetto
Puoi visualizzare un elenco dei servizi disponibili nel tuo progetto utilizzando laGoogle Cloud console o Google Cloud CLI:
Console
Per visualizzare l'elenco dei servizi:
Vai alla pubblicazione Knative nella Google Cloud console:
Esamina l'elenco di servizi visualizzato per il tuo progetto:
Riga di comando
Per elencare i servizi nel tuo progetto:
gcloud run services list
Puoi filtrare questo elenco in base alle proprietà della definizione del servizio, ad esempio un'etichetta assegnata.
Copiare un servizio
Puoi creare una copia di un servizio esistente utilizzando la Google Cloud console o YAML.
Puoi modificare qualsiasi elemento della copia, inclusi nome e regione.
Console
Per copiare un servizio:
Vai alla pubblicazione Knative nella Google Cloud console:
Seleziona il servizio da copiare dall'elenco visualizzato dei servizi per il tuo progetto:
Fai clic su Copia.
Nella pagina della copia del servizio, imposta o modifica i valori che vuoi modificare, come la regione e così via. Se mantieni la stessa regione, devi fornire un nuovo nome per il servizio.
Fai clic su Crea per creare una copia e implementarla utilizzando il nuovo nome del servizio.
YAML
.
Puoi scaricare la configurazione di un servizio esistente in un
file YAML con il comando gcloud run services describe utilizzando il
--format=export flag.
Puoi quindi modificare il file YAML e implementare queste modifiche con il comando gcloud run services replace.
Devi assicurarti di modificare solo gli attributi specificati.
Scarica la configurazione del servizio in un file denominato
service.yaml nello spazio di lavoro locale:
Se esegui il deployment della copia nello stesso cluster Kubernetes, sostituisci
SERVICE con il nome che vuoi utilizzare per la copia. Se stai eseguendo il deployment della copia in un altro cluster Kubernetes, puoi utilizzare lo stesso nome.
Assicurati che il valore di REVISION-NAME inizi con il nome del servizio (SERVICE). Ad esempio, se il nuovo nome del servizio è mynewfoo, il nome della revisione deve essere nel formato mynewfoo-whatever.
Se vuoi, elimina del tutto il valore e verrà creato automaticamente un nuovo nome di revisione.
Copia il servizio utilizzando il seguente comando:
gcloudrunservicesreplaceservice.yaml
Utilizza il flag --region per eseguire il deployment della copia in un'altra regione.
Visualizzare ulteriori dettagli su un servizio
Per visualizzare ulteriori dettagli su un servizio,
Console
Per visualizzare i dettagli di un servizio:
Vai alla pubblicazione Knative nella Google Cloud console:
Fai clic sul servizio desiderato nell'elenco visualizzato dei servizi per il progetto per aprire la visualizzazione dei dettagli del servizio:
Tieni presente le schede REVISIONI, LOG e Dettagli. La scheda Revisioni mostra l'elenco delle revisioni, la scheda Log mostra i log del servizio e la scheda Dettagli mostra le impostazioni correnti di autenticazione o connettività.
Riga di comando
Per visualizzare i dettagli di un servizio:
gcloudrunservicesdescribeSERVICE
Sostituisci SERVICE con il nome del servizio.
Puoi utilizzare il flag --format per formattare
l'output. Ad esempio, come file YAML:
gcloudrunservicesdescribeSERVICE--formatyaml
Puoi utilizzare --format export per esportare in formato YAML senza etichette o stato generati automaticamente:
gcloudrunservicesdescribeSERVICE--formatexport
Puoi anche utilizzare il flag --format per ottenere
l'URL del servizio:
Fai clic sul servizio desiderato nell'elenco visualizzato dei servizi per il tuo progetto per aprire la visualizzazione dei dettagli del servizio.
Fai clic sulla scheda Attivatori.
Seleziona l'impostazione che preferisci e fai clic su Salva.
Riga di comando
Per modificare le impostazioni di connettività del servizio, aggiorna il servizio con l'impostazione di connettività che preferisci:
gcloud run services update [SERVICE] --connectivity=[OPTION]
Sostituisci [SERVICE] con il nome del servizio che stai aggiornando.
Puoi omettere del tutto questo parametro, ma se lo fai ti verrà chiesto il nome del servizio.
Sostituisci [OPTION] con internal o external.
Eliminazione dei servizi esistenti
L'eliminazione di un servizio comporta l'eliminazione di tutte le risorse correlate, incluse tutte le revisioni del servizio, indipendentemente dal fatto che gestiscano o meno il traffico.
Quando elimini un servizio, le immagini container utilizzate dalle revisioni eliminate non vengono eliminate automaticamente da Container Registry. Per eliminare le immagini container da
Container Registry, consulta Eliminare le immagini.
Tieni presente che l'eliminazione di un servizio è definitiva: non è possibile annullare l'operazione o ripristinare il servizio.
Tuttavia, se dopo aver eliminato un servizio ne esegui il deployment con lo stesso nome nello stesso cluster, avrà lo stesso URL endpoint.
Console
Per eliminare un servizio:
Vai alla pubblicazione Knative nella Google Cloud console:
[[["Facile da capire","easyToUnderstand","thumb-up"],["Il problema è stato risolto","solvedMyProblem","thumb-up"],["Altra","otherUp","thumb-up"]],[["Difficile da capire","hardToUnderstand","thumb-down"],["Informazioni o codice di esempio errati","incorrectInformationOrSampleCode","thumb-down"],["Mancano le informazioni o gli esempi di cui ho bisogno","missingTheInformationSamplesINeed","thumb-down"],["Problema di traduzione","translationIssue","thumb-down"],["Altra","otherDown","thumb-down"]],["Ultimo aggiornamento 2025-09-01 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."]]