Restez organisé à l'aide des collections
Enregistrez et classez les contenus selon vos préférences.
Cette page explique comment créer et gérer des charges de travail sans état dans un cluster Kubernetes Google Distributed Cloud (GDC) isolé. Les charges de travail sans état vous permettent de faire évoluer le déploiement de votre application en fonction des exigences de la charge de travail, sans avoir à gérer le stockage persistant dans un cluster Kubernetes pour stocker les données ou l'état de l'application. Cette page vous aide à vous lancer afin que vous puissiez optimiser et ajuster efficacement la disponibilité de votre application.
Cette page s'adresse aux développeurs du groupe des opérateurs d'applications, qui sont chargés de créer des charges de travail d'application pour leur organisation. Pour en savoir plus, consultez la documentation sur les audiences pour GDC en mode air-gapped.
Avant de commencer
Pour exécuter des commandes sur un cluster Kubernetes, assurez-vous de disposer des ressources suivantes :
Recherchez le nom du cluster Kubernetes ou demandez-le à votre administrateur de plate-forme.
Utilisez le chemin d'accès kubeconfig du cluster Kubernetes pour remplacer KUBERNETES_CLUSTER_KUBECONFIG dans ces instructions.
Pour obtenir les autorisations requises pour créer des charges de travail sans état, demandez à votre administrateur IAM de l'organisation de vous accorder le rôle d'administrateur de l'espace de noms (namespace-admin) dans l'espace de noms de votre projet.
Créer un déploiement
Pour créer un déploiement, écrivez un fichier manifeste Deployment et exécutez kubectl apply pour créer la ressource. Cette méthode conserve également les mises à jour apportées aux ressources actives sans fusionner les modifications dans les fichiers manifestes.
Pour créer un Deployment à partir de son fichier manifeste, exécutez la commande suivante :
kubectl--kubeconfigKUBERNETES_CLUSTER_KUBECONFIG-nNAMESPACE\apply-f-<<EOF
apiVersion:apps/v1
kind:Deployment
metadata:
name:DEPLOYMENT_NAME
spec:
replicas:NUMBER_OF_REPLICASselector:
matchLabels:
run:APP_NAMEtemplate:
metadata:
labels:# The labels given to each pod in the deployment, which are used# to manage all pods in the deployment.run:APP_NAMEspec:# The pod specification, which defines how each pod runs in the deployment.containers:
-name:CONTAINER_NAMEimage:CONTAINER_IMAGE
EOF
Remplacez les éléments suivants :
KUBERNETES_CLUSTER_KUBECONFIG : fichier kubeconfig du cluster Kubernetes sur lequel vous déployez des charges de travail de conteneurs.
NAMESPACE : espace de noms du projet dans lequel déployer les charges de travail du conteneur.
DEPLOYMENT_NAME : fichier kubeconfig du cluster sur lequel vous déployez des charges de travail de conteneur.
APP_NAME : nom de l'application à exécuter dans le déploiement.
NUMBER_OF_REPLICAS : nombre d'objets Pod répliqués gérés par le déploiement.
CONTAINER_NAME : nom du conteneur.
CONTAINER_IMAGE : nom de l'image du conteneur. Vous devez inclure le chemin d'accès au registre de conteneurs et la version de l'image, par exemple REGISTRY_PATH/hello-app:1.0.
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/04 (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/04 (UTC)."],[[["\u003cp\u003eStateless applications store data with the client, allowing for increased scalability and availability through the use of multiple replicas without needing unique identities.\u003c/p\u003e\n"],["\u003cp\u003eBefore deploying stateless workloads, you need to identify your Kubernetes cluster name, sign in and generate the kubeconfig file, and obtain the Namespace Admin role (\u003ccode\u003enamespace-admin\u003c/code\u003e) from your Organization IAM Admin.\u003c/p\u003e\n"],["\u003cp\u003eDeployments are created by writing a \u003ccode\u003eDeployment\u003c/code\u003e manifest and using \u003ccode\u003ekubectl apply\u003c/code\u003e, which retains updates made to live resources.\u003c/p\u003e\n"],["\u003cp\u003eWhen creating a \u003ccode\u003eDeployment\u003c/code\u003e, you must specify details such as the deployment name, number of replicas, application name, container name, and container image, along with the appropriate kubeconfig file and namespace.\u003c/p\u003e\n"],["\u003cp\u003eYou can use \u003ccode\u003ekubectl apply -f\u003c/code\u003e with either a manifest file or a directory of manifest files to create new resources within your cluster.\u003c/p\u003e\n"]]],[],null,["# Create stateless workloads\n\nThis page explains how to create and manage stateless workloads within a\nGoogle Distributed Cloud (GDC) air-gapped Kubernetes cluster. Stateless workloads let you\nscale your application deployment based on workload demands, all\nwithout having to manage persistent storage in a Kubernetes cluster to store\ndata or application state. This page helps you get started so you can\nefficiently optimize and adjust your application's availability.\n\nThis page is for developers within the application operator group, who are\nresponsible for creating application workloads for their organization. For more\ninformation, see\n[Audiences for GDC air-gapped documentation](/distributed-cloud/hosted/docs/latest/gdch/resources/audiences).\n\nBefore you begin\n----------------\n\nTo run commands against a\n[Kubernetes cluster](/distributed-cloud/hosted/docs/latest/gdch/platform/pa-user/clusters#cluster-architecture),\nmake sure you have the following resources:\n\n1. Locate the Kubernetes cluster name, or ask your Platform Administrator what\n the cluster name is.\n\n2. [Sign in and generate](/distributed-cloud/hosted/docs/latest/gdch/application/ao-user/iam/sign-in#zonal-cluster-kubeconfig)\n the kubeconfig file for the Kubernetes cluster if you don't have one.\n\n3. Use the kubeconfig path of the Kubernetes cluster to replace\n \u003cvar translate=\"no\"\u003eKUBERNETES_CLUSTER_KUBECONFIG\u003c/var\u003e in these instructions.\n\nTo get the required permissions to create stateless workloads, ask your\nOrganization IAM Admin to grant you the Namespace Admin role (`namespace-admin`)\nin your project namespace.\n\nCreate a deployment\n-------------------\n\nYou create a deployment by writing a `Deployment` manifest and running\n`kubectl apply` to create the resource. This method also retains updates made to\nlive resources without merging the changes back into the manifest files.\n\nTo create a `Deployment` from its manifest file, run: \n\n kubectl --kubeconfig \u003cvar translate=\"no\"\u003eKUBERNETES_CLUSTER_KUBECONFIG\u003c/var\u003e -n \u003cvar translate=\"no\"\u003eNAMESPACE\u003c/var\u003e \\\n apply -f - \u003c\u003cEOF\n apiVersion: apps/v1\n kind: Deployment\n metadata:\n name: \u003cvar translate=\"no\"\u003eDEPLOYMENT_NAME\u003c/var\u003e\n spec:\n replicas: \u003cvar translate=\"no\"\u003eNUMBER_OF_REPLICAS\u003c/var\u003e\n selector:\n matchLabels:\n run: \u003cvar translate=\"no\"\u003eAPP_NAME\u003c/var\u003e\n template:\n metadata:\n labels: # The labels given to each pod in the deployment, which are used\n # to manage all pods in the deployment.\n run: \u003cvar translate=\"no\"\u003eAPP_NAME\u003c/var\u003e\n spec: # The pod specification, which defines how each pod runs in the deployment.\n containers:\n - name: \u003cvar translate=\"no\"\u003eCONTAINER_NAME\u003c/var\u003e\n image: \u003cvar translate=\"no\"\u003eCONTAINER_IMAGE\u003c/var\u003e\n EOF\n\nReplace the following:\n\n- \u003cvar translate=\"no\"\u003eKUBERNETES_CLUSTER_KUBECONFIG\u003c/var\u003e: the kubeconfig file for the\n Kubernetes cluster to which you're deploying container workloads.\n\n- \u003cvar translate=\"no\"\u003eNAMESPACE\u003c/var\u003e: the project namespace in which to deploy the container workloads.\n\n- \u003cvar translate=\"no\"\u003eDEPLOYMENT_NAME\u003c/var\u003e: the kubeconfig file for the\n cluster to which you're deploying container workloads.\n\n- \u003cvar translate=\"no\"\u003eAPP_NAME\u003c/var\u003e: the name of the application to run within\n the deployment.\n\n- \u003cvar translate=\"no\"\u003eNUMBER_OF_REPLICAS\u003c/var\u003e: the number of replicated `Pod`\n objects that the deployment manages.\n\n- \u003cvar translate=\"no\"\u003eCONTAINER_NAME\u003c/var\u003e: the name of the container.\n\n- \u003cvar translate=\"no\"\u003eCONTAINER_IMAGE\u003c/var\u003e: the name of the container image. You\n must include the container registry path and version of the image, such as\n \u003cvar class=\"readonly\" translate=\"no\"\u003eREGISTRY_PATH\u003c/var\u003e`/hello-app:1.0`.\n\n| **Note:** You can also use `kubectl apply -f `\u003cvar translate=\"no\"\u003eDIRECTORY\u003c/var\u003e to create new objects defined by manifest files stored in a directory.\n\nFor example: \n\n apiVersion: apps/v1\n kind: Deployment\n metadata:\n name: my-app\n spec:\n replicas: 3\n selector:\n matchLabels:\n run: my-app\n template:\n metadata:\n labels:\n run: my-app\n spec:\n containers:\n - name: hello-app\n image: \u003cvar class=\"readonly\" translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-l devsite-syntax-l-Scalar devsite-syntax-l-Scalar-Plain\"\u003eREGISTRY_PATH\u003c/span\u003e\u003c/var\u003e/hello-app:1.0\n\nIf you're deploying GPU workloads to your containers, see\n[Manage GPU container workloads](/distributed-cloud/hosted/docs/latest/gdch/application/ao-user/containers/deploy-gpu-container-workloads)\nfor more information."]]