Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
gitpod-io
GitHub Repository: gitpod-io/gitpod
Path: blob/main/install/installer/pkg/common/pod_disruption_budget.go
2500 views
1
// Copyright (c) 2023 Gitpod GmbH. All rights reserved.
2
// Licensed under the GNU Affero General Public License (AGPL).
3
// See License.AGPL.txt in the project root for license information.
4
5
package common
6
7
import (
8
"fmt"
9
10
policy "k8s.io/api/policy/v1"
11
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
12
"k8s.io/apimachinery/pkg/util/intstr"
13
)
14
15
func PodDisruptionBudget(ctx *RenderContext, component string, maxUnavailable int, selector *v1.LabelSelector) *policy.PodDisruptionBudget {
16
muCount := intstr.FromInt(maxUnavailable)
17
18
return &policy.PodDisruptionBudget{
19
TypeMeta: TypePodDisruptionBudget,
20
ObjectMeta: v1.ObjectMeta{
21
Name: fmt.Sprintf("%v-pdb", component),
22
Namespace: ctx.Namespace,
23
},
24
Spec: policy.PodDisruptionBudgetSpec{
25
MaxUnavailable: &muCount,
26
Selector: selector,
27
},
28
}
29
}
30
31