Skip to content

Commit 44ab5ea

Browse files
committed
Add support for pod disruption budget
1 parent 2838b78 commit 44ab5ea

File tree

3 files changed

+49
-0
lines changed

3 files changed

+49
-0
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// Copyright (c) 2021 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(context *RenderContext, component string, maxUnavailable int, selector *v1.LabelSelector) *policy.PodDisruptionBudget {
16+
muCount := intstr.FromInt(maxUnavailable)
17+
18+
return &policy.PodDisruptionBudget{
19+
ObjectMeta: v1.ObjectMeta{
20+
Name: fmt.Sprintf("%v-pdb", component),
21+
Namespace: context.Namespace,
22+
},
23+
Spec: policy.PodDisruptionBudgetSpec{
24+
MaxUnavailable: &muCount,
25+
Selector: selector,
26+
},
27+
}
28+
}

install/installer/pkg/components/ws-manager-mk2/objects.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ var Objects common.RenderFunc = func(cfg *common.RenderContext) ([]runtime.Objec
1515
crd,
1616
configmap,
1717
deployment,
18+
pdb,
1819
networkpolicy,
1920
role,
2021
rolebinding,
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// Copyright (c) 2021 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 wsmanagermk2
6+
7+
import (
8+
"github.com/gitpod-io/gitpod/installer/pkg/common"
9+
10+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
11+
"k8s.io/apimachinery/pkg/runtime"
12+
)
13+
14+
func pdb(ctx *common.RenderContext) ([]runtime.Object, error) {
15+
return []runtime.Object{
16+
common.PodDisruptionBudget(ctx, Component, 1, &metav1.LabelSelector{
17+
MatchLabels: common.DefaultLabels(Component),
18+
}),
19+
}, nil
20+
}

0 commit comments

Comments
 (0)