Skip to content

Commit 2a49036

Browse files
[CASCL-610] Add require RBAC for ArgoRollout support (#2221)
* [CASCL-610] Add require RBAC ArgoRollout support * Add container-autoscaling in CODEOWNERS config --------- Co-authored-by: Fanny Jiang <fanny.jiang@datadoghq.com>
1 parent 977f372 commit 2a49036

5 files changed

Lines changed: 18 additions & 2 deletions

File tree

.github/CODEOWNERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ README.md @DataDog/documentation @DataDog/container-ecosystems
1919
/internal/controller/datadogagent/feature/clusterchecks/* @DataDog/container-platform
2020
/internal/controller/datadogagent/feature/kubernetesstatecore/* @DataDog/container-integrations
2121
/internal/controller/datadogagent/feature/helmcheck/* @DataDog/container-integrations
22+
/internal/controller/datadogagent/feature/autoscaling/* @DataDog/container-autoscaling
2223

2324

2425
/api/**/datadogpodautoscaler*.go @DataDog/container-autoscaling

config/rbac/role.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ rules:
129129
- rollouts
130130
verbs:
131131
- list
132+
- patch
132133
- watch
133134
- apiGroups:
134135
- authentication.k8s.io

internal/controller/datadogagent/feature/autoscaling/feature_test.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,11 @@ func testRBACResources(t testing.TB, store store.StoreClient) {
121121
APIGroups: []string{"apps"},
122122
Resources: []string{"deployments"},
123123
},
124+
{
125+
Verbs: []string{"patch"},
126+
APIGroups: []string{"argoproj.io"},
127+
Resources: []string{"rollouts"},
128+
},
124129
}),
125130
"ClusterRole Policy Rules \ndiff = %s", cmp.Diff(cr.Rules, ""),
126131
)

internal/controller/datadogagent/feature/autoscaling/rbac.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ func getDCAClusterPolicyRules() []rbacv1.PolicyRule {
5050
// Patching POD to add annotations. TODO: Remove when we have a better way to generate single event
5151
APIGroups: []string{rbac.CoreAPIGroup},
5252
Resources: []string{
53-
"pods",
53+
rbac.PodsResource,
5454
},
5555
Verbs: []string{
5656
rbac.PatchVerb,
@@ -60,11 +60,18 @@ func getDCAClusterPolicyRules() []rbacv1.PolicyRule {
6060
// Patching Deployment to trigger rollout.
6161
APIGroups: []string{rbac.AppsAPIGroup},
6262
Resources: []string{
63-
"deployments",
63+
rbac.DeploymentsResource,
6464
},
6565
Verbs: []string{
6666
rbac.PatchVerb,
6767
},
6868
},
69+
{
70+
APIGroups: []string{rbac.ArgoProjAPIGroup},
71+
Resources: []string{rbac.Rollout},
72+
Verbs: []string{
73+
rbac.PatchVerb,
74+
},
75+
},
6976
}
7077
}

internal/controller/datadogagent_controller.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,8 @@ type DatadogAgentReconciler struct {
8888
// +kubebuilder:rbac:groups=datadoghq.com,resources=datadogpodautoscalers,verbs=*
8989
// +kubebuilder:rbac:groups=datadoghq.com,resources=datadogpodautoscalers/status,verbs=*
9090
// +kubebuilder:rbac:groups=*,resources=*/scale,verbs=get;update
91+
// +kubebuilder:rbac:groups=apps,resources=deployments,verbs=patch
92+
// +kubebuilder:rbac:groups=argoproj.io,resources=rollouts,verbs=patch
9193

9294
// Use ExtendedDaemonSet
9395
// +kubebuilder:rbac:groups=datadoghq.com,resources=extendeddaemonsets,verbs=get;list;watch;create;update;patch;delete

0 commit comments

Comments
 (0)