Skip to content

Commit

Permalink
Adapted dependency-watchdog component to work with DWD v0.7.0
Browse files Browse the repository at this point in the history
  • Loading branch information
ashwani2k committed Mar 1, 2022
1 parent 4e69680 commit 6e52ca2
Show file tree
Hide file tree
Showing 4 changed files with 105 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,17 @@ func (d *dependencyWatchdog) clusterRoleRules() []rbacv1.PolicyRule {
Resources: []string{"deployments", "deployments/scale"},
Verbs: []string{"get", "list", "watch", "update"},
},
{
APIGroups: []string{"coordination.k8s.io"},
Resources: []string{"leases"},
Verbs: []string{"create"},
},
{
APIGroups: []string{"coordination.k8s.io"},
ResourceNames: []string{"dependency-watchdog-probe"},
Resources: []string{"leases"},
Verbs: []string{"get", "watch", "update"},
},
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,22 @@ rules:`
- list
- watch
- update
- apiGroups:
- coordination.k8s.io
resources:
- leases
verbs:
- create
- apiGroups:
- coordination.k8s.io
resourceNames:
- dependency-watchdog-probe
resources:
- leases
verbs:
- get
- watch
- update
`
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
package kubeapiserver

import (
worker "github.com/gardener/gardener/extensions/pkg/controller/worker/genericactuator"
v1beta1constants "github.com/gardener/gardener/pkg/apis/core/v1beta1/constants"

restarterapi "github.com/gardener/dependency-watchdog/pkg/restarter/api"
Expand Down Expand Up @@ -70,12 +71,44 @@ func DependencyWatchdogProbeConfiguration() ([]scalerapi.ProbeDependants, error)
Internal: &scalerapi.ProbeDetails{KubeconfigSecretName: DependencyWatchdogInternalProbeSecretName},
PeriodSeconds: pointer.Int32(30),
},
DependantScales: []*scalerapi.DependantScaleDetails{{
ScaleRef: autoscalingv1.CrossVersionObjectReference{
APIVersion: appsv1.SchemeGroupVersion.String(),
Kind: "Deployment",
Name: v1beta1constants.DeploymentNameKubeControllerManager,
DependantScales: []*scalerapi.DependantScaleDetails{
{
ScaleRef: autoscalingv1.CrossVersionObjectReference{
APIVersion: appsv1.SchemeGroupVersion.String(),
Kind: "Deployment",
Name: v1beta1constants.DeploymentNameKubeControllerManager,
},
ScaleUpDelaySeconds: pointer.Int32(120),
},
{
ScaleRef: autoscalingv1.CrossVersionObjectReference{
APIVersion: appsv1.SchemeGroupVersion.String(),
Kind: "Deployment",
Name: worker.McmDeploymentName,
},
ScaleUpDelaySeconds: pointer.Int32(60),
ScaleRefDependsOn: []autoscalingv1.CrossVersionObjectReference{
{
APIVersion: appsv1.SchemeGroupVersion.String(),
Kind: "Deployment",
Name: v1beta1constants.DeploymentNameKubeControllerManager,
},
},
},
}},
{
ScaleRef: autoscalingv1.CrossVersionObjectReference{
APIVersion: appsv1.SchemeGroupVersion.String(),
Kind: "Deployment",
Name: v1beta1constants.DeploymentNameClusterAutoscaler,
},
ScaleRefDependsOn: []autoscalingv1.CrossVersionObjectReference{
{
APIVersion: appsv1.SchemeGroupVersion.String(),
Kind: "Deployment",
Name: worker.McmDeploymentName,
},
},
},
},
}}, nil
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
scalerapi "github.com/gardener/dependency-watchdog/pkg/scaler/api"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
appsv1 "k8s.io/api/apps/v1"
autoscalingv1 "k8s.io/api/autoscaling/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/utils/pointer"
Expand Down Expand Up @@ -67,13 +68,45 @@ var _ = Describe("DependencyWatchdog", func() {
Internal: &scalerapi.ProbeDetails{KubeconfigSecretName: "dependency-watchdog-internal-probe"},
PeriodSeconds: pointer.Int32(30),
},
DependantScales: []*scalerapi.DependantScaleDetails{{
ScaleRef: autoscalingv1.CrossVersionObjectReference{
APIVersion: "apps/v1",
Kind: "Deployment",
Name: "kube-controller-manager",
DependantScales: []*scalerapi.DependantScaleDetails{
{
ScaleRef: autoscalingv1.CrossVersionObjectReference{
APIVersion: "apps/v1",
Kind: "Deployment",
Name: "kube-controller-manager",
},
ScaleUpDelaySeconds: pointer.Int32(120),
},
{
ScaleRef: autoscalingv1.CrossVersionObjectReference{
APIVersion: "apps/v1",
Kind: "Deployment",
Name: "machine-controller-manager",
},
ScaleUpDelaySeconds: pointer.Int32(60),
ScaleRefDependsOn: []autoscalingv1.CrossVersionObjectReference{
{
APIVersion: appsv1.SchemeGroupVersion.String(),
Kind: "Deployment",
Name: "kube-controller-manager",
},
},
},
}},
{
ScaleRef: autoscalingv1.CrossVersionObjectReference{
APIVersion: "apps/v1",
Kind: "Deployment",
Name: "cluster-autoscaler",
},
ScaleRefDependsOn: []autoscalingv1.CrossVersionObjectReference{
{
APIVersion: appsv1.SchemeGroupVersion.String(),
Kind: "Deployment",
Name: "machine-controller-manager",
},
},
},
},
}))
Expect(err).NotTo(HaveOccurred())
})
Expand Down

0 comments on commit 6e52ca2

Please sign in to comment.