Conseil : Consultez le tutoriel GKE Enterprise pour en savoir plus sur le chemin le plus court pour configurer un environnement GKE Enterprise incluant un cluster GKE et Cloud Service Mesh.
Déployer un exemple de conteneur
Utilisez la console Google Cloud pour déployer un exemple de conteneur et créer un service dans votre cluster:
Dans la console Google Cloud , accédez à la page Knative serving.
Sélectionnez le Google Cloud projet dans lequel réside votre cluster GKE.
Dans la liste des clusters disponibles, cliquez sur Connexion pour vous connecter.
Ouvrez le formulaire Créer un service en cliquant sur Créer un service.
Dans le menu déroulant des clusters disponibles, sélectionnez votre cluster.
Laissez default comme nom de l'espace de noms dans lequel vous souhaitez exécuter votre service.
Saisissez le nom de service de votre choix. Par exemple, hello.
Cliquez sur Suivant.
Sélectionnez Déployer une révision à partir d'une image de conteneur existante, puis sélectionnez hello dans la liste Conteneurs de démonstration.
Cliquez sur Suivant.
Sélectionnez Externe sous Connectivité pour accéder à votre service depuis le Web.
Cliquez sur Créer pour déployer l'image hello sur Knative serving et attendez la fin du déploiement.
Félicitations ! Vous venez de déployer un service sur un cluster avec Knative serving activé.
Accéder à votre service déployé
Maintenant que votre service est en cours d'exécution, vous pouvez lui envoyer des requêtes. Dans cette section, en supposant que votre cluster utilise le nom par défaut de la passerelle d'entrée, le domaine de test par défaut permet de montrer comment accéder à votre service et vérifier qu'il fonctionne:
Dans la console Google Cloud , accédez à la page Knative serving.
Cliquez sur le nom de votre nouveau service Knative serving pour ouvrir la page Informations sur le service. Par exemple, hello.
En haut de la page, cliquez sur l'URL pour accéder à votre service déployé via votre navigateur Web. Par exemple, si vous avez nommé votre service hello, l'URL ressemble à la suivante, mais inclut l'adresse IP externe de votre cluster : http://hello.default.kuberun.11.111.11.111.nip.io
Félicitations ! Votre service Knative serving est actif et traite les requêtes.
Effectuer un nettoyage
Vous pouvez supprimer le service Knative serving afin d'éviter d'avoir à payer les coûts d'exécution de ces ressources.
Les points suivants doivent être pris en compte lors de la suppression d'un service :
La suppression d'un service supprime toutes les ressources associées à ce service, y compris toutes les révisions de ce service, qu'elles diffusent du trafic ou non.
La suppression d'un service ne supprime pas automatiquement les images de conteneurs de Container Registry.
Pour supprimer de Container Registry les images de conteneur utilisées par des versions supprimées, reportez-vous à la section Supprimer des images.
La suppression d'un service avec un ou plusieurs déclencheurs Eventarc ne supprime pas automatiquement ces déclencheurs. Pour supprimer les déclencheurs, consultez la page Gérer les déclencheurs.
Après la suppression, le service reste visible dans la console Google Cloud et dans l'interface de ligne de commande jusqu'à la fin effective de sa suppression. Toutefois, vous ne pouvez pas mettre à jour le service.
La suppression d'un service est définitive : il n'y a aucune possibilité d'annulation ni de restauration.
Toutefois, si après avoir supprimé un service, vous déployez un nouveau service portant le même nom dans la même région, il aura la même URL de point de terminaison.
Pour supprimer définitivement le service et toutes ses ressources, procédez comme suit :
Dans la console Google Cloud , accédez à la page Knative serving.
Dans la liste des services, recherchez le service Knative serving que vous avez créé, puis cochez la case correspondante pour le sélectionner.
Cliquez sur SUPPRIMER.
Étapes suivantes
Pour savoir comment créer un conteneur à partir d'un code source, le transférer dans Container Registry, puis le déployer, reportez-vous à cette page :
Sauf indication contraire, le contenu de cette page est régi par une licence Creative Commons Attribution 4.0, et les échantillons de code sont régis par une licence Apache 2.0. Pour en savoir plus, consultez les Règles du site Google Developers. Java est une marque déposée d'Oracle et/ou de ses sociétés affiliées.
Dernière mise à jour le 2025/09/01 (UTC).
[[["Facile à comprendre","easyToUnderstand","thumb-up"],["J'ai pu résoudre mon problème","solvedMyProblem","thumb-up"],["Autre","otherUp","thumb-up"]],[["Difficile à comprendre","hardToUnderstand","thumb-down"],["Informations ou exemple de code incorrects","incorrectInformationOrSampleCode","thumb-down"],["Il n'y a pas l'information/les exemples dont j'ai besoin","missingTheInformationSamplesINeed","thumb-down"],["Problème de traduction","translationIssue","thumb-down"],["Autre","otherDown","thumb-down"]],["Dernière mise à jour le 2025/09/01 (UTC)."],[],[],null,["# Quickstart: Deploy an application to Knative serving\n\nDeploy an application to Knative serving\n========================================\n\nLearn how to use the Google Cloud console to deploy a prebuilt sample\ncontainer to run as a Knative serving service.\n\nBefore you begin\n----------------\n\nYou must have access to the Google Cloud project and cluster\nwhere Knative serving is installed. For details, see\n[Knative serving fleet installation overview](/kubernetes-engine/enterprise/knative-serving/docs/install).\n\n**Tip** : See the [GKE Enterprise tutorial](/anthos/docs/tutorials/explore-anthos)\nfor details about the shortest path to setting up a GKE Enterprise environment\nthat includes a GKE cluster and Cloud Service Mesh.\n\nDeploying a sample container\n----------------------------\n\nUse the Google Cloud console to deploy a sample container and create a service\nin your cluster:\n\n1. In the Google Cloud console, go to the **Knative serving** page.\n\n [Go to Knative serving](https://console.cloud.google.com/projectselector2/kubernetes/run)\n2. Select the Google Cloud project in which your GKE cluster resides.\n\n3. In the list of available clusters, click **Login** to connect.\n\n4. Open the **Create service** form by clicking **Create service**.\n\n5. In the available clusters dropdown menu, select your cluster.\n\n6. Leave `default` as the name of the\n [namespace](https://kubernetes.io/docs/concepts/overview/working-with-objects/namespaces/)\n where you want your service to run.\n\n7. Enter a service name of your choice. For example, `hello`.\n\n8. Click **Next**.\n\n9. Select **Deploy one revision from an existing container image** , then\n select **hello** from in the **Demo containers** list.\n\n10. Click **Next**.\n\n11. Select **External** under *Connectivity*, so that you can access your\n service from the web.\n\n12. Click **Create** to deploy the `hello` image to Knative serving\n and wait for the deployment to finish.\n\nCongratulations! You have just deployed a service to a\nKnative serving enabled cluster.\n\nAccessing your deployed service\n-------------------------------\n\nNow that you have a service running, you can send requests to it. In this\nsection, assuming that your cluster uses default name of the ingress gateway,\nthe default test domain is used to demonstrate how to access your\nservice and verify that it's working:\n\n1. In the Google Cloud console, go to the **Knative serving** page.\n\n [Go to Knative serving](https://console.cloud.google.com/kubernetes/run)\n2. Click the name of your new Knative serving service to open the\n **Service details** page. For example, **hello**.\n\n3. At the top of the page, click the **URL** to access your deployed service\n through your web browser. For example, if you named your service `hello`, the\n URL is similar to the following but includes your cluster's external IP\n address: `http://hello.default.kuberun.11.111.11.111.nip.io`\n\nCongratulations! Your Knative serving service is live and handling requests.\n\nClean up\n--------\n\nYou can delete the Knative serving service to avoid incurring costs from\nrunning those resources.\n\nThe following considerations apply to deleting a service:\n\n- Deleting a service deletes all resources related to this service, including all revisions of this service whether they are serving traffic or not.\n- Deleting a service does not automatically remove container images from Container Registry.\n To delete container images used by the deleted revisions from Container Registry,\n refer to [Deleting images](/container-registry/docs/managing#deleting_images).\n\n | **Caution:** Container Registry is deprecated. Effective March 18, 2025,\n | Container Registry is shut down, and writing images to Container Registry is unavailable. For\n | details on the deprecation and how to migrate to Artifact Registry, see\n | [Container Registry deprecation](/container-registry/docs/deprecations/container-registry-deprecation).\n- Deleting a service with one or more Eventarc triggers does not automatically\n delete these triggers. To delete the triggers refer to [Manage triggers](/eventarc/docs/managing-triggers#trigger-delete).\n\n- After deletion, the service remains visible in the Google Cloud console and in the command line interface\n until the deletion is fully complete. However, you cannot update the service.\n\n- Deleting a service is permanent: there is no undo or restore.\n However, if after deleting a service, you deploy a new service with the same\n name in the same region, it will have the same endpoint URL.\n\nTo permanently delete the service and all its resources:\n\n1. In the Google Cloud console, go to the **Knative serving** page.\n\n [Go to Knative serving](https://console.cloud.google.com/kubernetes/run)\n2. In the services list, locate the Knative serving service that you created\n and click its checkbox to select it.\n\n3. Click **DELETE**.\n\nWhat's next\n-----------\n\nTo learn how to build a container from code source, push to Container Registry,\nand then deploy, see:\n\n- [Building containers](/kubernetes-engine/enterprise/knative-serving/docs/building/containers)\n- [Deploying container images](/kubernetes-engine/enterprise/knative-serving/docs/deploying)\n\nTo learn more about how Knative serving works, see the\n[Architectural overview](/kubernetes-engine/enterprise/knative-serving/docs/architecture-overview)."]]