Stay organized with collections Save and categorize content based on your preferences.
This page shows you how to request extended run times for Pods before they're evicted by Google Kubernetes Engine (GKE).
About GKE-initiated Pod evictionPod evictions are a normal part of running workloads on Kubernetes. GKE evicts workloads during scheduled events, such as automatic node upgrades and autoscaling scale-downs, to ensure that your nodes are up-to-date and optimized for efficient resource usage. By default, GKE sends a termination signal to the container as soon as the event occurs, after which the container has a grace period to terminate before Kubernetes evicts the Pod. For automatic node upgrades, the grace period can be up to one hour. For scale-down events, the grace period can be up to 10 minutes.
Kubernetes has built-in features that containers can use to gracefully handle evictions, such as PodDisruptionBudgets and graceful termination periods. However, some workloads, such as batch queues or multiplayer game servers, need to run for a longer period of time before being evicted. The default grace period that GKE grants during GKE-initiated evictions might not be enough for these workloads. In these situations, you can tell Autopilot to avoid evicting specific workloads for up to 7 days.
Use casesSome situations in which you might want to tell GKE to avoid evicting workloads include the following:
You can request extended run times for your Pods at no additional charge. However, consider the following behavioral changes that might impact your pricing:
For pricing details, see Autopilot pricing.
Before you beginBefore you start, make sure that you have performed the following tasks:
gcloud components update
. Note: For existing gcloud CLI installations, make sure to set the compute/region
property. If you use primarily zonal clusters, set the compute/zone
instead. By setting a default location, you can avoid errors in the gcloud CLI like the following: One of [--zone, --region] must be supplied: Please specify location
. You might need to specify the location in certain commands if the location of your cluster differs from the default that you set.To request extended run time for a Pod, set the Kubernetes cluster-autoscaler.kubernetes.io/safe-to-evict
annotation to false
in the Pod specification.
Save the following manifest as extended-deployment.yaml
:
apiVersion: apps/v1
kind: Deployment
metadata:
name: extended-pods
labels:
duration: extended
spec:
selector:
matchLabels:
duration: extended
template:
metadata:
annotations:
cluster-autoscaler.kubernetes.io/safe-to-evict: "false"
labels:
duration: extended
spec:
containers:
- name: example-container
image: registry.k8s.io/pause
resources:
requests:
cpu: 200m
Create the Deployment:
kubectl create -f extended-deployment.yaml
The Pods continue to run for at least 7 days before a scale-down or a node auto-upgrade can occur.
Considerations and recommendationsWhen you use this functionality, consider the following:
cluster-autoscaler.kubernetes.io/safe-to-evict
annotation in Standard clusters, but the result is not the same. Pods run indefinitely even if a scale-down event occurs, preventing deletion of underutilized nodes and resulting in you continuing to pay for those nodes. Pods also aren't protected from evictions caused by node auto-upgrades.Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-08-12 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-12 UTC."],[],[]]
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4