Skip to content

Add support for pod disruption budget #18547

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions install/installer/pkg/common/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -712,6 +712,10 @@ var (
APIVersion: "trust.cert-manager.io/v1alpha1",
Kind: "Bundle",
}
TypePodDisruptionBudget = metav1.TypeMeta{
APIVersion: "policy/v1",
Kind: "PodDisruptionBudget",
}
)

// validCookieChars contains all characters which may occur in an HTTP Cookie value (unicode \u0021 through \u007E),
Expand Down
29 changes: 29 additions & 0 deletions install/installer/pkg/common/pod_disruption_budget.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// Copyright (c) 2023 Gitpod GmbH. All rights reserved.
// Licensed under the GNU Affero General Public License (AGPL).
// See License.AGPL.txt in the project root for license information.

package common

import (
"fmt"

policy "k8s.io/api/policy/v1"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/intstr"
)

func PodDisruptionBudget(ctx *RenderContext, component string, maxUnavailable int, selector *v1.LabelSelector) *policy.PodDisruptionBudget {
muCount := intstr.FromInt(maxUnavailable)

return &policy.PodDisruptionBudget{
TypeMeta: TypePodDisruptionBudget,
ObjectMeta: v1.ObjectMeta{
Name: fmt.Sprintf("%v-pdb", component),
Namespace: ctx.Namespace,
},
Spec: policy.PodDisruptionBudgetSpec{
MaxUnavailable: &muCount,
Selector: selector,
},
}
}
1 change: 1 addition & 0 deletions install/installer/pkg/components/blobserve/objects.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ var Objects = common.CompositeRenderFunc(
deployment,
networkpolicy,
rolebinding,
pdb,
common.GenerateService(Component, []common.ServicePort{
{
Name: ServicePortName,
Expand Down
20 changes: 20 additions & 0 deletions install/installer/pkg/components/blobserve/pdb.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Copyright (c) 2021 Gitpod GmbH. All rights reserved.
// Licensed under the GNU Affero General Public License (AGPL).
// See License-AGPL.txt in the project root for license information.

package blobserve

import (
"github.com/gitpod-io/gitpod/installer/pkg/common"

metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
)

func pdb(ctx *common.RenderContext) ([]runtime.Object, error) {
return []runtime.Object{
common.PodDisruptionBudget(ctx, Component, 1, &metav1.LabelSelector{
MatchLabels: common.DefaultLabels(Component),
}),
}, nil
}
1 change: 1 addition & 0 deletions install/installer/pkg/components/dashboard/objects.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ var Objects = common.CompositeRenderFunc(
deployment,
networkpolicy,
rolebinding,
pdb,
common.GenerateService(Component, []common.ServicePort{
{
Name: PortName,
Expand Down
20 changes: 20 additions & 0 deletions install/installer/pkg/components/dashboard/pdb.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Copyright (c) 2021 Gitpod GmbH. All rights reserved.
// Licensed under the GNU Affero General Public License (AGPL).
// See License-AGPL.txt in the project root for license information.

package dashboard

import (
"github.com/gitpod-io/gitpod/installer/pkg/common"

metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
)

func pdb(ctx *common.RenderContext) ([]runtime.Object, error) {
return []runtime.Object{
common.PodDisruptionBudget(ctx, Component, 1, &metav1.LabelSelector{
MatchLabels: common.DefaultLabels(Component),
}),
}, nil
}
1 change: 1 addition & 0 deletions install/installer/pkg/components/node-labeler/objects.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ var Objects = common.CompositeRenderFunc(
deployment,
role,
rolebinding,
pdb,
common.DefaultServiceAccount(Component),
func(cfg *common.RenderContext) ([]runtime.Object, error) {
ports := []common.ServicePort{
Expand Down
20 changes: 20 additions & 0 deletions install/installer/pkg/components/node-labeler/pdb.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Copyright (c) 2021 Gitpod GmbH. All rights reserved.
// Licensed under the GNU Affero General Public License (AGPL).
// See License-AGPL.txt in the project root for license information.

package wsmanager

import (
"github.com/gitpod-io/gitpod/installer/pkg/common"

metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
)

func pdb(ctx *common.RenderContext) ([]runtime.Object, error) {
return []runtime.Object{
common.PodDisruptionBudget(ctx, Component, 1, &metav1.LabelSelector{
MatchLabels: common.DefaultLabels(Component),
}),
}, nil
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ var Objects = common.CompositeRenderFunc(
networkpolicy,
rolebinding,
statefulset,
pdb,
service,
common.DefaultServiceAccount(Component),
)
20 changes: 20 additions & 0 deletions install/installer/pkg/components/openvsx-proxy/pdb.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Copyright (c) 2023 Gitpod GmbH. All rights reserved.
// Licensed under the GNU Affero General Public License (AGPL).
// See License-AGPL.txt in the project root for license information.

package openvsx_proxy

import (
"github.com/gitpod-io/gitpod/installer/pkg/common"

metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
)

func pdb(ctx *common.RenderContext) ([]runtime.Object, error) {
return []runtime.Object{
common.PodDisruptionBudget(ctx, Component, 1, &metav1.LabelSelector{
MatchLabels: common.DefaultLabels(Component),
}),
}, nil
}
1 change: 1 addition & 0 deletions install/installer/pkg/components/proxy/objects.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ var Objects = common.CompositeRenderFunc(
deployment,
networkpolicy,
rolebinding,
pdb,
service,
common.DefaultServiceAccount(Component),
)
20 changes: 20 additions & 0 deletions install/installer/pkg/components/proxy/pdb.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Copyright (c) 2023 Gitpod GmbH. All rights reserved.
// Licensed under the GNU Affero General Public License (AGPL).
// See License-AGPL.txt in the project root for license information.

package proxy

import (
"github.com/gitpod-io/gitpod/installer/pkg/common"

metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
)

func pdb(ctx *common.RenderContext) ([]runtime.Object, error) {
return []runtime.Object{
common.PodDisruptionBudget(ctx, Component, 1, &metav1.LabelSelector{
MatchLabels: common.DefaultLabels(Component),
}),
}, nil
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ func Objects(ctx *common.RenderContext) ([]runtime.Object, error) {
configmap,
deployment,
rolebinding,
pdb,
common.DefaultServiceAccount(Component),
service,
networkpolicy,
Expand Down
20 changes: 20 additions & 0 deletions install/installer/pkg/components/public-api-server/pdb.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Copyright (c) 2023 Gitpod GmbH. All rights reserved.
// Licensed under the GNU Affero General Public License (AGPL).
// See License-AGPL.txt in the project root for license information.

package public_api_server

import (
"github.com/gitpod-io/gitpod/installer/pkg/common"

metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
)

func pdb(ctx *common.RenderContext) ([]runtime.Object, error) {
return []runtime.Object{
common.PodDisruptionBudget(ctx, Component, 1, &metav1.LabelSelector{
MatchLabels: common.CustomizeLabel(ctx, Component, common.TypeMetaDeployment),
}),
}, nil
}
1 change: 1 addition & 0 deletions install/installer/pkg/components/server/objects.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ var Objects = common.CompositeRenderFunc(
func(ctx *common.RenderContext) ([]runtime.Object, error) {
return Rolebinding(ctx, Component)
},
pdb,
common.GenerateService(Component, []common.ServicePort{
{
Name: ContainerPortName,
Expand Down
20 changes: 20 additions & 0 deletions install/installer/pkg/components/server/pdb.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Copyright (c) 2023 Gitpod GmbH. All rights reserved.
// Licensed under the GNU Affero General Public License (AGPL).
// See License-AGPL.txt in the project root for license information.

package server

import (
"github.com/gitpod-io/gitpod/installer/pkg/common"

metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
)

func pdb(ctx *common.RenderContext) ([]runtime.Object, error) {
return []runtime.Object{
common.PodDisruptionBudget(ctx, Component, 1, &metav1.LabelSelector{
MatchLabels: common.DefaultLabels(Component),
}),
}, nil
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ var Objects common.RenderFunc = func(cfg *common.RenderContext) ([]runtime.Objec
crd,
configmap,
deployment,
pdb,
networkpolicy,
role,
rolebinding,
Expand Down
20 changes: 20 additions & 0 deletions install/installer/pkg/components/ws-manager-mk2/pdb.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Copyright (c) 2023 Gitpod GmbH. All rights reserved.
// Licensed under the GNU Affero General Public License (AGPL).
// See License-AGPL.txt in the project root for license information.

package wsmanagermk2

import (
"github.com/gitpod-io/gitpod/installer/pkg/common"

metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
)

func pdb(ctx *common.RenderContext) ([]runtime.Object, error) {
return []runtime.Object{
common.PodDisruptionBudget(ctx, Component, 1, &metav1.LabelSelector{
MatchLabels: common.DefaultLabels(Component),
}),
}, nil
}
1 change: 1 addition & 0 deletions install/installer/pkg/components/ws-proxy/objects.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ var Objects = common.CompositeRenderFunc(
networkpolicy,
rolebinding,
role,
pdb,
func(cfg *common.RenderContext) ([]runtime.Object, error) {
ports := []common.ServicePort{
{
Expand Down
20 changes: 20 additions & 0 deletions install/installer/pkg/components/ws-proxy/pdb.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Copyright (c) 2023 Gitpod GmbH. All rights reserved.
// Licensed under the GNU Affero General Public License (AGPL).
// See License-AGPL.txt in the project root for license information.

package wsproxy

import (
"github.com/gitpod-io/gitpod/installer/pkg/common"

metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
)

func pdb(ctx *common.RenderContext) ([]runtime.Object, error) {
return []runtime.Object{
common.PodDisruptionBudget(ctx, Component, 1, &metav1.LabelSelector{
MatchLabels: common.DefaultLabels(Component),
}),
}, nil
}