[[["容易理解","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-07-14 (世界標準時間)。"],[],[],null,["# Isolate workloads in dedicated node pools\n=========================================\n\nThis page shows you how to reduce the risk of privilege escalation\nattacks in your cluster by configuring GKE on Azure to schedule your\nworkloads on a separate, dedicated node pool away from privileged managed\nworkloads.\n\nOverview\n--------\n\nGKE on Azure clusters use privileged workloads that we manage to\nenable specific cluster functionality and features, such as metrics gathering.\nThese workloads are given special permissions to run correctly in the cluster.\n\nWorkloads that you deploy to your nodes might have the potential to be\ncompromised by a malicious entity. Running these workloads alongside privileged\nsystem workloads means that an attacker who breaks out of a compromised\ncontainer can use the credentials of the privileged workload on the node to\nescalate privileges in your cluster.\n\n### Preventing container breakouts\n\nYour primary defense should be your applications. GKE on Azure has\nmultiple features that you can use to harden your clusters and Pods. In most\ncases, we **strongly recommend** using\n[Policy Controller](/anthos-config-management/docs/how-to/installing-policy-controller)\nand kernel security features to harden your workloads. For more security\nrecommendations, see the\n[Security overview](/kubernetes-engine/multi-cloud/docs/azure/concepts/security).\n\n### Avoiding privilege escalation attacks\n\nIf you want an extra layer of isolation in addition to other hardening measures,\nyou can use\n[node taints](https://kubernetes.io/docs/concepts/scheduling-eviction/taint-and-toleration/)\nand\n[node affinity](https://kubernetes.io/docs/tasks/configure-pod-container/assign-pods-nodes-using-node-affinity/)\nto schedule your workloads on a dedicated node pool.\n\nA node taint tells GKE on Azure to avoid scheduling workloads without\na corresponding toleration (such as GKE on Azure-managed workloads) on\nthose nodes. The node affinity on your own workloads tells\nGKE on Azure to schedule your Pods on the dedicated nodes.\n| **Caution:** Node isolation is an advanced defence-in-depth mechanism that you should **only** use alongside other isolation features such as minimally-privileged containers and service accounts. Node isolation might not cover all escalation paths, and should never be used as a primary security boundary.\n\n### Limitations of node isolation\n\n- Attackers can still initiate Denial-of-Service (DoS) attacks from the compromised node.\n- Compromised nodes can still read many resources, including all Pods and namespaces in the cluster.\n- Compromised nodes can access Secrets and credentials used by every Pod running on that node.\n- Using a separate node pool to isolate your workloads can affect your cost efficiency, autoscaling, and resource utilization.\n- Compromised nodes can still bypass egress network policies.\n- Some GKE on Azure-managed workloads must run on every node in your cluster, and are configured to tolerate all taints.\n- If you deploy DaemonSets that have elevated permissions and can tolerate any taint, those Pods might be a pathway for privilege escalation from a compromised node.\n\nHow node isolation works\n------------------------\n\nTo implement node isolation for your workloads, you must do the following:\n\n1. Taint and label a node pool for your workloads.\n2. Update your workloads with the corresponding toleration and node affinity rule.\n\nThis guide assumes that you start with one node pool in your cluster. Using node\naffinity in addition to node taints isn't mandatory, but we recommend it because\nyou benefit from greater control over scheduling.\n\nBefore you begin\n----------------\n\nTo perform the steps on this page, first complete the following:\n\n- [Create a cluster](/kubernetes-engine/multi-cloud/docs/azure/how-to/create-cluster).\n- [Create a node pool](/kubernetes-engine/multi-cloud/docs/azure/how-to/create-node-pool).\n- [Configure cluster access for kubectl](/kubernetes-engine/multi-cloud/docs/azure/how-to/configure-cluster-access-for-kubectl).\n\n- Choose a name for the node taint and the node label that you want\n to use for the dedicated node pools. For this example, we use `workloadType=untrusted`.\n\nTaint and label a node pool for your workloads\n----------------------------------------------\n\nCreate a new node pool for your workloads and apply a node taint and\na node label. When you apply a taint or a label at the node pool\nlevel, any new nodes, such as those created by autoscaling, will automatically\nget the specified taints and labels.\n\nYou can also add node taints and node labels to existing node pools. If you use\nthe `NoExecute` effect, GKE on Azure evicts any Pods running on those\nnodes that don't have a toleration for the new taint.\n\nTo add a taint and a label to a new node pool, run the following command: \n\n gcloud container azure node-pools create \u003cvar translate=\"no\"\u003ePOOL_NAME\u003c/var\u003e \\\n --cluster \u003cvar translate=\"no\"\u003eCLUSTER_NAME\u003c/var\u003e \\\n --node-taints \u003cvar translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-nv\"\u003eTAINT_KEY\u003c/span\u003e\u003c/var\u003e=\u003cvar translate=\"no\"\u003eTAINT_VALUE\u003c/var\u003e:\u003cvar translate=\"no\"\u003eTAINT_EFFECT\u003c/var\u003e \\\n --node-labels \u003cvar translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-nv\"\u003eLABEL_KEY\u003c/span\u003e\u003c/var\u003e=\u003cvar translate=\"no\"\u003eLABEL_VALUE\u003c/var\u003e\n\nReplace the following:\n\n- \u003cvar translate=\"no\"\u003ePOOL_NAME\u003c/var\u003e: the name of the new node pool for your workloads.\n- \u003cvar translate=\"no\"\u003eCLUSTER_NAME\u003c/var\u003e: the name of your GKE on Azure cluster.\n- \u003cvar translate=\"no\"\u003eTAINT_KEY\u003c/var\u003e`=`\u003cvar translate=\"no\"\u003eTAINT_VALUE\u003c/var\u003e: a key-value pair associated with a scheduling \u003cvar translate=\"no\"\u003eTAINT_EFFECT\u003c/var\u003e. For example, `workloadType=untrusted`.\n- \u003cvar translate=\"no\"\u003eTAINT_EFFECT\u003c/var\u003e: one of the following [effect values](/kubernetes-engine/docs/how-to/node-taints#effects): `NoSchedule`, `PreferNoSchedule`, or `NoExecute`. `NoExecute` provides a better eviction guarantee than `NoSchedule`.\n- \u003cvar translate=\"no\"\u003eLABEL_KEY\u003c/var\u003e=\u003cvar translate=\"no\"\u003eLABEL_VALUE\u003c/var\u003e: key-value pairs for the node labels, which correspond to the selectors that you specify in your workload manifests.\n\nAdd a toleration and a node affinity rule to your workloads\n-----------------------------------------------------------\n\nAfter you taint the dedicated node pool, no workloads can schedule on it unless\nthey have a toleration corresponding to the taint you added. Add the toleration\nto the specification for your workloads to let those Pods schedule on your\ntainted node pool.\n\nIf you labelled the dedicated node pool, you can also add a node affinity rule\nto tell GKE on Azure to only schedule your workloads on that node pool.\n\nThe following example adds a toleration for the\n`workloadType=untrusted:NoExecute` taint and a node affinity rule for the\n`workloadType=untrusted` node label. \n\n kind: Deployment\n apiVersion: apps/v1\n metadata:\n name: my-app\n namespace: default\n labels:\n app: my-app\n spec:\n replicas: 1\n selector:\n matchLabels:\n app: my-app\n template:\n metadata:\n labels:\n app: my-app\n spec:\n tolerations:\n - key: \u003cvar translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-l devsite-syntax-l-Scalar devsite-syntax-l-Scalar-Plain\"\u003eTAINT_KEY\u003c/span\u003e\u003c/var\u003e\n operator: Equal\n value: \u003cvar translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-l devsite-syntax-l-Scalar devsite-syntax-l-Scalar-Plain\"\u003eTAINT_VALUE\u003c/span\u003e\u003c/var\u003e\n affinity:\n nodeAffinity:\n requiredDuringSchedulingIgnoredDuringExecution:\n nodeSelectorTerms:\n - matchExpressions:\n - key: \u003cvar translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-l devsite-syntax-l-Scalar devsite-syntax-l-Scalar-Plain\"\u003eLABEL_KEY\u003c/span\u003e\u003c/var\u003e\n operator: In\n values:\n - \"\u003cvar translate=\"no\"\u003eLABEL_VALUE\u003c/var\u003e\"\n containers:\n - name: sleep\n image: ubuntu\n command: [\"/bin/sleep\", \"inf\"]\n\nReplace the following:\n\n- \u003cvar translate=\"no\"\u003eTAINT_KEY\u003c/var\u003e: the taint key that you applied to your dedicated node pool.\n- \u003cvar translate=\"no\"\u003eTAINT_VALUE\u003c/var\u003e: the taint value that you applied to your dedicated node pool.\n- \u003cvar translate=\"no\"\u003eLABEL_KEY\u003c/var\u003e: the node label key that you applied to your dedicated node pool.\n- \u003cvar translate=\"no\"\u003eLABEL_VALUE\u003c/var\u003e: the node label value that you applied to your dedicated node pool.\n\nWhen you update your Deployment with `kubectl apply`, GKE on Azure\nrecreates the affected Pods. The node affinity rule forces the Pods onto the\ndedicated node pool that you created. The toleration allows only those Pods to be\nplaced on the nodes.\n\nVerify that the separation works\n--------------------------------\n\nTo verify that the scheduling works correctly, run the following command and\ncheck whether your workloads are on the dedicated node pool: \n\n kubectl get pods -o=wide\n\nRecommendations and best practices\n----------------------------------\n\nAfter setting up node isolation, we recommend that you do the following:\n\n- Restrict specific node pools to GKE on Azure-managed workloads only by adding the `components.gke.io/gke-managed-components` taint. Adding this taint prevents your own Pods from scheduling on those nodes, improving the isolation.\n- When creating new node pools, prevent most GKE on Azure-managed workloads from running on those nodes by adding your own taint to those node pools.\n- Whenever you deploy new workloads to your cluster, such as when installing third-party tooling, audit the permissions that the Pods require. When possible, avoid deploying workloads that use elevated permissions to shared nodes.\n\nWhat's next\n-----------\n\n- [Read the GKE on Azure security overview](/kubernetes-engine/multi-cloud/docs/azure/concepts/security)."]]