[[["容易理解","easyToUnderstand","thumb-up"],["確實解決了我的問題","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["難以理解","hardToUnderstand","thumb-down"],["資訊或程式碼範例有誤","incorrectInformationOrSampleCode","thumb-down"],["缺少我需要的資訊/範例","missingTheInformationSamplesINeed","thumb-down"],["翻譯問題","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["上次更新時間:2025-09-04 (世界標準時間)。"],[[["\u003cp\u003eYou can update a \u003ccode\u003eDeployment\u003c/code\u003e object's pod specification, including its image, resource usage, requests, or configuration, by applying a new or updated manifest file.\u003c/p\u003e\n"],["\u003cp\u003eUpdating a container image within a deployment involves using the \u003ccode\u003ekubectl set image\u003c/code\u003e command, which is useful for changing selector fields or resources like requests and limits.\u003c/p\u003e\n"],["\u003cp\u003eTo update a \u003ccode\u003eDeployment\u003c/code\u003e object you will use the \u003ccode\u003ekubectl apply\u003c/code\u003e command by providing a \u003ccode\u003eDEPLOYMENT_FILE\u003c/code\u003e to the command along with the proper kubeconfig and namespace.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003ekubectl rollout undo\u003c/code\u003e command enables you to roll back a \u003ccode\u003eDeployment\u003c/code\u003e object update to its previous revision or to a specific revision number, preserving the deployment's rollout history for easy recovery.\u003c/p\u003e\n"]]],[],null,["# Update stateless workloads\n\nThis page explains how to update existing stateless workloads running in a\nGoogle Distributed Cloud (GDC) air-gapped Kubernetes cluster. As your application evolves\nbased on resource usage and configuration optimizations, you must update your\nunderlying pod specification in the Kubernetes cluster to reflect those workload\nchanges.\n\nThis page is for developers within the application operator group, who are\nresponsible for updating 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 update stateless workloads, ask your\nOrganization IAM Admin to grant you the Namespace Admin role (`namespace-admin`)\nin your project namespace.\n\nUpdate the deployment\n---------------------\n\nTo update a `Deployment` object, 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 \u003cvar translate=\"no\"\u003eDEPLOYMENT_FILE\u003c/var\u003e\n\nReplace the following:\n\n- \u003cvar translate=\"no\"\u003eKUBERNETES_CLUSTER_KUBECONFIG\u003c/var\u003e: the kubeconfig file for the\n cluster running the deployment.\n\n- \u003cvar translate=\"no\"\u003eNAMESPACE\u003c/var\u003e: the project namespace.\n\n- \u003cvar translate=\"no\"\u003eDEPLOYMENT_FILE\u003c/var\u003e: the name of the `Deployment`\n manifest file to update.\n\nThe `kubectl apply` command applies a manifest file to a resource. If the\nspecified resource does not exist, it is created by the command.\n\nThere are also several other ways to update resources within your deployment.\n\n### Update a container image\n\nTo change the image of a `Deployment` object, run: \n\n kubectl --kubeconfig \u003cvar translate=\"no\"\u003eKUBERNETES_CLUSTER_KUBECONFIG\u003c/var\u003e -n \u003cvar translate=\"no\"\u003eNAMESPACE\u003c/var\u003e \\\n set image deployment \u003cvar translate=\"no\"\u003eDEPLOYMENT_NAME\u003c/var\u003e \\\n \u003cvar translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-nv\"\u003eIMAGE\u003c/span\u003e\u003c/var\u003e=\u003cvar translate=\"no\"\u003eIMAGE\u003c/var\u003e:\u003cvar translate=\"no\"\u003eTAG\u003c/var\u003e\n\nReplace the following:\n\n- \u003cvar translate=\"no\"\u003eKUBERNETES_CLUSTER_KUBECONFIG\u003c/var\u003e: the kubeconfig file for the\n cluster running the deployment.\n\n- \u003cvar translate=\"no\"\u003eNAMESPACE\u003c/var\u003e: the project namespace.\n\n- \u003cvar translate=\"no\"\u003eDEPLOYMENT_NAME\u003c/var\u003e: the name of the `Deployment` object\n containing the image.\n\n- \u003cvar translate=\"no\"\u003eIMAGE\u003c/var\u003e: the name of the container image.\n\n- \u003cvar translate=\"no\"\u003eTAG\u003c/var\u003e: the tag to update for the container image.\n\nUpdating the image of a deployment is useful to change selector fields or\nresources, such as requests or limits.\n\nFor example, to update a `Deployment` object named `nginx` to use version\n`1.9.1`, run: \n\n kubectl --kubeconfig /tmp/kubeconfig.yaml -n my-namespace \\\n set image deployment nginx nginx=nginx:1.9.1\n\n### Roll back an update\n\nIf you want to roll back an update, such as when your deployment becomes\nunstable, use the `kubectl` CLI. A `Deployment` object's rollout history is\npreserved in the system so you can roll back at any time.\n\nTo roll back an in-progress or completed update to its previous revision,\nrun: \n\n kubectl --kubeconfig \u003cvar translate=\"no\"\u003eKUBERNETES_CLUSTER_KUBECONFIG\u003c/var\u003e \\\n -n \u003cvar translate=\"no\"\u003eNAMESPACE\u003c/var\u003e \\\n rollout undo deployment \u003cvar translate=\"no\"\u003eDEPLOYMENT_NAME\u003c/var\u003e\n\nReplace the following:\n\n- \u003cvar translate=\"no\"\u003eKUBERNETES_CLUSTER_KUBECONFIG\u003c/var\u003e: the kubeconfig file for the\n cluster running the deployment.\n\n- \u003cvar translate=\"no\"\u003eNAMESPACE\u003c/var\u003e: the project namespace.\n\n- \u003cvar translate=\"no\"\u003eDEPLOYMENT_NAME\u003c/var\u003e: the name of the `Deployment` object\n to roll back.\n\nTo roll back to a specific revision, run: \n\n kubectl --kubeconfig \u003cvar translate=\"no\"\u003eKUBERNETES_CLUSTER_KUBECONFIG\u003c/var\u003e \\\n -n \u003cvar translate=\"no\"\u003eNAMESPACE\u003c/var\u003e \\\n rollout undo deployment \u003cvar translate=\"no\"\u003eDEPLOYMENT_NAME\u003c/var\u003e \\\n --to-revision=\u003cvar translate=\"no\"\u003eREVISION_NUMBER\u003c/var\u003e\n\nReplace the following:\n\n- \u003cvar translate=\"no\"\u003eKUBERNETES_CLUSTER_KUBECONFIG\u003c/var\u003e: the kubeconfig file for the\n cluster running the deployment.\n\n- \u003cvar translate=\"no\"\u003eNAMESPACE\u003c/var\u003e: the project namespace.\n\n- \u003cvar translate=\"no\"\u003eDEPLOYMENT_NAME\u003c/var\u003e: the name of the `Deployment` object\n to roll back.\n\n- \u003cvar translate=\"no\"\u003eREVISION_NUMBER\u003c/var\u003e: the integer that defines the\n revision to roll back to, such as `3`."]]