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

[Action Platform PAR] Use actionsAllowlist to configure RBAC #1518

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
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 charts/private-action-runner/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Datadog changelog

### 0.9.1
Copy link
Contributor

@dd-gplassard dd-gplassard Sep 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you merge / rebase from main ? there was another release in the meantime


* Simplified user configuration for Private Action Runner RBAC using `actionsAllowlist```

### 0.9.0

* Update private action image version to `v0.0.1-alpha29`.
Expand Down
2 changes: 1 addition & 1 deletion charts/private-action-runner/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: private-action-runner
description: A Helm chart to deploy the private action runner

type: application
version: 0.9.0
version: 0.9.1
appVersion: "1.22.0"
keywords:
- app builder
Expand Down
42 changes: 42 additions & 0 deletions charts/private-action-runner/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,45 @@
{{- define "chart.roleBindingName" }} "private-action-runner-{{.}}-rolebinding" {{ end }}
{{- define "chart.serviceName" }} "private-action-runner-{{.}}-service" {{ end }}
{{- define "chart.secretName" }} "private-action-runner-{{.}}-secrets" {{ end }}

{{/*
Defines an RBAC rule for provided apiGroup, resource type and allowed verbs
*/}}
{{- define "rbacRule" }}
- apiGroups:
- {{ .apiGroup }}
resources:
- {{ .resource }}
verbs:
{{- range $_, $verb := .verbs }}
- {{ $verb }}
{{- end }}
{{- end }}

{{/*
Defines an RBAC "get" rule for provided apiGroup and resource type
*/}}
{{- define "rbacGetRule" }}
{{- include "rbacRule" (dict "apiGroup" .apiGroup "resource" .resource "verbs" (list "get"))}}
{{- end }}

{{/*
Defines an RBAC "list" rule for provided apiGroup and resource type
*/}}
{{- define "rbacListRule" }}
{{- include "rbacRule" (dict "apiGroup" .apiGroup "resource" .resource "verbs" (list "list"))}}
{{- end }}
Comment on lines +22 to +34
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It depends how much granularity you want, but maybe get and list can be define together. Same for patch and update


{{/*
Defines an RBAC "update" rule for provided apiGroup and resource type
*/}}
{{- define "rbacUpdateRule" }}
{{- include "rbacRule" (dict "apiGroup" .apiGroup "resource" .resource "verbs" (list "update"))}}
{{- end }}

{{/*
Defines an RBAC "patch" rule for provided apiGroup and resource type
*/}}
{{- define "rbacPatchRule" }}
{{- include "rbacRule" (dict "apiGroup" .apiGroup "resource" .resource "verbs" (list "patch"))}}
{{- end }}
17 changes: 16 additions & 1 deletion charts/private-action-runner/templates/role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,20 @@ kind: ClusterRole
metadata:
namespace: {{ $.Release.Namespace }}
name: {{ include "chart.roleName" $runner.name }}
rules: {{ $runner.kubernetesPermissions | toJson }}
rules:
{{- if $runner.kubernetesPermissions }}
{{ $runner.kubernetesPermissions | toYaml}}
{{- end }}
{{- if has "com.datadoghq.kubernetes.apps.getDeployment" $runner.config.actionsAllowlist }}
{{- include "rbacGetRule" (dict "apiGroup" "apps" "resource" "deployments")}}
{{- end }}
{{- if has "com.datadoghq.kubernetes.apps.listDeployment" $runner.config.actionsAllowlist }}
{{- include "rbacListRule" (dict "apiGroup" "apps" "resource" "deployments")}}
{{- end }}
{{- if has "com.datadoghq.kubernetes.apps.patchDeployment" $runner.config.actionsAllowlist }}
{{- include "rbacPatchRule" (dict "apiGroup" "apps" "resource" "deployments")}}
{{- end }}
{{- if has "com.datadoghq.kubernetes.apps.restartDeployment" $runner.config.actionsAllowlist }}
{{- include "rbacUpdateRule" (dict "apiGroup" "apps" "resource" "deployments")}}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

restartDeployment is actually using patch under the hood

{{- end }}
{{- end }}
1 change: 1 addition & 0 deletions charts/private-action-runner/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ runners:
# - com.datadoghq.kubernetes.apps.listStatefulSet
# - com.datadoghq.kubernetes.apps.restartDeployment
# - com.datadoghq.kubernetes.apps.updateDeployment
# - com.datadoghq.kubernetes.apps.patchDeployment
# - com.datadoghq.kubernetes.apps.updateReplicaSet
# - com.datadoghq.kubernetes.core.createNode
# - com.datadoghq.kubernetes.core.createPod
Expand Down
Loading