Skip to content

Commit

Permalink
Add a PDB to prevent cluster autoscaler from evicting test workloads
Browse files Browse the repository at this point in the history
  • Loading branch information
alvaroaleman committed Sep 21, 2020
1 parent d4301ac commit b3643eb
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 1 deletion.
9 changes: 9 additions & 0 deletions config/prow/cluster/BUILD.bazel
Expand Up @@ -77,6 +77,15 @@ release(
MULTI_KIND,
cluster = BUILD_CLUSTER,
),
component(
"test_pods",
"pdb",
),
component(
"test_pods",
"pdb",
cluster = BUILD_CLUSTER,
),
)

# TODO(fejta): do we want to auto-apply this?
Expand Down
12 changes: 12 additions & 0 deletions config/prow/cluster/starter-gcs.yaml
Expand Up @@ -1251,3 +1251,15 @@ spec:
resources:
requests:
storage: 100Gi
---
# Keep cluster-autoscaler from evicting running test workloads when scaling down
apiVersion: policy/v1beta1
kind: PodDisruptionBudget
metadata:
name: prow-pods
namespace: test-pods
spec:
maxUnavailable: 0
selector:
matchLabels:
created-by-prow: "true"
12 changes: 12 additions & 0 deletions config/prow/cluster/starter-s3.yaml
Expand Up @@ -1354,3 +1354,15 @@ spec:
protocol: TCP
selector:
app: minio
---
# Keep cluster-autoscaler from evicting running test workloads when scaling down
apiVersion: policy/v1beta1
kind: PodDisruptionBudget
metadata:
name: prow-pods
namespace: test-pods
spec:
maxUnavailable: 0
selector:
matchLabels:
created-by-prow: "true"
31 changes: 31 additions & 0 deletions config/prow/cluster/test_pods_pdb.yaml
@@ -0,0 +1,31 @@
# Copyright 2020 The Kubernetes Authors All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# The purpose of the PodDisruptionBudget here is to never allow evicting pods created by prow.
# Eviction of pods can happen for one of two reasons:
# * Cluster autoscaler downscaling
# * Someome/Something using `kubectl drain`
#
# It is still possible to delete the pods via a normal delete call. See https://kubernetes.io/docs/tasks/administer-cluster/safely-drain-node/#the-eviction-api

apiVersion: policy/v1beta1
kind: PodDisruptionBudget
metadata:
name: prow-pods
namespace: test-pods
spec:
maxUnavailable: 0
selector:
matchLabels:
created-by-prow: "true"
2 changes: 1 addition & 1 deletion prow/def.bzl
Expand Up @@ -159,7 +159,7 @@ def component(cmd, *kinds, **kwargs):
n = cmd
else:
n = "%s_%s" % (cmd, k)
kwargs["name"] = _basename(n)
kwargs["name"] = _basename(n) + kwargs["cluster"]
kwargs["kind"] = k
kwargs["template"] = ":%s.yaml" % n
object(**kwargs)
Expand Down

0 comments on commit b3643eb

Please sign in to comment.