Skip to content
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

[CONTINT-4500] Add EKS Clusterrole Rule for EKS control plane metrics #1651

Closed
16 changes: 16 additions & 0 deletions internal/controller/datadogagent/feature/enabledefault/rbac.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ func getDefaultAgentClusterRolePolicyRules(excludeNonResourceRules bool) []rbacv
getKubeletPolicyRule(),
getEndpointsPolicyRule(),
getLeaderElectionPolicyRule(),
getEKSControlPlaneMetricsPolicyRule(),
}

if !excludeNonResourceRules {
Expand All @@ -35,6 +36,19 @@ func getDefaultAgentClusterRolePolicyRules(excludeNonResourceRules bool) []rbacv
return policyRule
}

func getEKSControlPlaneMetricsPolicyRule() rbacv1.PolicyRule {
return rbacv1.PolicyRule{
APIGroups: []string{rbac.EKSMetricsAPIGroup},
Resources: []string{
rbac.EKSKubeControllerManagerMetrics,
rbac.EKSKubeSchedulerMetrics,
},
Verbs: []string{
rbac.GetVerb,
},
}
}

func getMetricsEndpointPolicyRule() rbacv1.PolicyRule {
return rbacv1.PolicyRule{
NonResourceURLs: []string{
Expand Down Expand Up @@ -286,6 +300,8 @@ func getDefaultClusterChecksRunnerClusterRolePolicyRules(dda metav1.Object, excl
rbac.GetVerb,
},
},
// EKS kube_scheduler and kube_controller_manager control plane metrics
getEKSControlPlaneMetricsPolicyRule(),
}

if !excludeNonResourceRules {
Expand Down
4 changes: 3 additions & 1 deletion pkg/kubernetes/rbac/const.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ const (
RbacAPIGroup = "rbac.authorization.k8s.io"
RegistrationAPIGroup = "apiregistration.k8s.io"
StorageAPIGroup = "storage.k8s.io"
EKSMetricsAPIGroup = "metrics.eks.amazonaws.com"

// Resources

Expand Down Expand Up @@ -85,7 +86,8 @@ const (
VolumeAttachments = "volumeattachments"
VPAResource = "verticalpodautoscalers"
WpaResource = "watermarkpodautoscalers"

EKSKubeControllerManagerMetrics = "kcm/metrics"
EKSKubeSchedulerMetrics = "ksh/metrics"
// Non resource URLs

HealthzURL = "/healthz"
Expand Down
Loading