Utilisez le chemin d'accès kubeconfig du cluster Kubernetes pour remplacer KUBERNETES_CLUSTER_KUBECONFIG dans ces instructions.
Pour obtenir les autorisations requises pour mettre à l'échelle des charges de travail avec état, demandez à votre administrateur IAM de l'organisation de vous attribuer le rôle Administrateur de l'espace de noms (namespace-admin) dans l'espace de noms de votre projet.
Faire évoluer une ressource StatefulSet
Exploitez la fonctionnalité de scaling de Kubernetes pour ajuster le nombre de pods exécutés dans votre ressource StatefulSet.
Effectuer manuellement le scaling des pods d'une ressource StatefulSet
Pour effectuer manuellement le scaling de votre ressource StatefulSet, exécutez la commande suivante :
KUBERNETES__CLUSTER_KUBECONFIG : fichier kubeconfig du cluster.
NAMESPACE : espace de noms du projet.
STATEFULSET_NAME : nom de l'objet StatefulSet dans lequel effectuer la mise à l'échelle.
NUMBER_OF_REPLICAS : nombre souhaité d'objets Pod répliqués dans l'objet StatefulSet.
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\u003eThis document guides users on how to scale stateful workloads within a Kubernetes cluster to meet evolving container requirements.\u003c/p\u003e\n"],["\u003cp\u003eBefore scaling, you need to locate your Kubernetes cluster name, sign in to generate the kubeconfig file, and obtain the Namespace Admin role.\u003c/p\u003e\n"],["\u003cp\u003eYou can manually scale a \u003ccode\u003eStatefulSet\u003c/code\u003e resource by running the \u003ccode\u003ekubectl scale statefulset\u003c/code\u003e command, specifying the cluster's kubeconfig, namespace, \u003ccode\u003eStatefulSet\u003c/code\u003e name, and desired number of replicas.\u003c/p\u003e\n"],["\u003cp\u003eAlternatively, scale the pods by making an in-place update to the \u003ccode\u003eStatefulSet\u003c/code\u003e manifest file using the \u003ccode\u003ekubectl patch statefulsets\u003c/code\u003e command, indicating the kubeconfig, namespace, \u003ccode\u003eStatefulSet\u003c/code\u003e name, and new replica count.\u003c/p\u003e\n"]]],[],null,["# Scale stateful workloads\n\nScale your stateful workloads to your evolving container workload requirements.\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 scale stateful workloads, ask your\nOrganization IAM Admin to grant you the Namespace Admin role (`namespace-admin`)\nin your project namespace.\n\nScale a `StatefulSet` resource\n------------------------------\n\nLeverage the scaling functionality of Kubernetes to appropriately scale the\namount of pods running in your `StatefulSet` resource.\n\n### Manually scale the pods of a `StatefulSet` resource\n\nTo manually scale your `StatefulSet` resource, run: \n\n kubectl --kubeconfig \u003cvar translate=\"no\"\u003eKUBERNETES__CLUSTER_KUBECONFIG\u003c/var\u003e -n \u003cvar translate=\"no\"\u003eNAMESPACE\u003c/var\u003e \\\n scale statefulset \u003cvar translate=\"no\"\u003eSTATEFULSET_NAME\u003c/var\u003e \\\n --replicas \u003cvar translate=\"no\"\u003eNUMBER_OF_REPLICAS\u003c/var\u003e\n\nReplace the following:\n\n- \u003cvar translate=\"no\"\u003eKUBERNETES_CLUSTER_KUBECONFIG\u003c/var\u003e: the kubeconfig file for\n the cluster.\n\n- \u003cvar translate=\"no\"\u003eNAMESPACE\u003c/var\u003e: the project namespace.\n\n- \u003cvar translate=\"no\"\u003eSTATEFULSET_NAME\u003c/var\u003e: the name of the `StatefulSet`\n object in which to scale.\n\n- \u003cvar translate=\"no\"\u003eNUMBER_OF_REPLICAS\u003c/var\u003e: the desired number of replicated\n `Pod` objects in the `StatefulSet` object.\n\n### Scale the pods by making an in-place update\n\nTo scale the pods of a `StatefulSet` resource directly in the manifest file,\nrun: \n\n kubectl --kubeconfig \u003cvar translate=\"no\"\u003eKUBERNETES__CLUSTER_KUBECONFIG\u003c/var\u003e -n \u003cvar translate=\"no\"\u003eNAMESPACE\u003c/var\u003e \\\n patch statefulsets \u003cvar translate=\"no\"\u003eSTATEFULSET_NAME\u003c/var\u003e \\\n -p '{\"spec\":{\"replicas\":\u003cvar translate=\"no\"\u003eNUMBER_OF_REPLICAS\u003c/var\u003e}}'\n\nReplace the following:\n\n- \u003cvar translate=\"no\"\u003eKUBERNETES__CLUSTER_KUBECONFIG\u003c/var\u003e: the kubeconfig file for\n the cluster.\n\n- \u003cvar translate=\"no\"\u003eNAMESPACE\u003c/var\u003e: the project namespace.\n\n- \u003cvar translate=\"no\"\u003eSTATEFULSET_NAME\u003c/var\u003e: the name of the `StatefulSet`\n object in which to scale.\n\n- \u003cvar translate=\"no\"\u003eNUMBER_OF_REPLICAS\u003c/var\u003e: the desired number of replicated\n `Pod` objects in the `StatefulSet` object."]]