Skip to content

Commit 7fff5f6

Browse files
authored
feat(appProjectRBAC)[#36]: add support for managing AppProject RBAC (#37)
* feat(appProjectRBAC)[#36]: add ArgoCDProjectRole and ArgoCDProjectRoleBinding CRDs + APIs Signed-off-by: Georgy Khromov <[email protected]> * feat(appProjectRBAC)[#36]: add ArgoCDProjectRole Controller Signed-off-by: Georgy Khromov <[email protected]> * feat(appProjectRBAC)[#36]: add logic for reconciling AppProject's projectRoles Signed-off-by: Georgy Khromov <[email protected]> * feat(appProjectRBAC)[#36]: add logic for reconciling ArgoCDProjectRoleBindings Signed-off-by: Georgy Khromov <[email protected]> * feat(appProjectRBAC)[#36]: added unit tests for ArgoCDProjectRole and ArgoCDProjectRoleBinding + updated docs Signed-off-by: Georgy Khromov <[email protected]> * feat(appProjectRBAC)[#36]: bump golangci-lint version in GitHub CI Pipeline Signed-off-by: Georgy Khromov <[email protected]> * feat(appProjectRBAC)[#36]: bump golangci-lint version in GitHub CI Pipeline Signed-off-by: Georgy Khromov <[email protected]> * feat(appProjectRBAC)[#36]: fix typo in readme, make subjects required again Signed-off-by: Georgy Khromov <[email protected]> * feat(appProjectRBAC)[#36]: fix observedGeneration update logic Signed-off-by: Georgy Khromov <[email protected]> --------- Signed-off-by: Georgy Khromov <[email protected]>
1 parent 849edce commit 7fff5f6

File tree

57 files changed

+3851
-235
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+3851
-235
lines changed

.github/workflows/golangci-lint.yaml

Lines changed: 3 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -23,33 +23,7 @@ jobs:
2323
go-version: '1.24'
2424
cache: false
2525
- name: golangci-lint
26-
uses: golangci/golangci-lint-action@3a919529898de77ec3da873e3063ca4b10e7f5cc # pin@v3
26+
uses: golangci/golangci-lint-action@v8
2727
with:
28-
# Require: The version of golangci-lint to use.
29-
# When `install-mode` is `binary` (default) the value can be v1.2 or v1.2.3 or `latest` to use the latest version.
30-
# When `install-mode` is `goinstall` the value can be v1.2.3, `latest`, or the hash of a commit.
31-
version: v1.64.8
32-
# Optional: working directory, useful for monorepos
33-
# working-directory: somedir
34-
35-
# Optional: golangci-lint command line arguments.
36-
#
37-
# Note: By default, the `.golangci.yml` file should be at the root of the repository.
38-
# The location of the configuration file can be changed by using `--config=`
39-
# args: --timeout=30m --config=/my/path/.golangci.yml --issues-exit-code=0
40-
41-
# Optional: show only new issues if it's a pull request. The default value is `false`.
42-
# only-new-issues: true
43-
44-
# Optional: if set to true, then all caching functionality will be completely disabled,
45-
# takes precedence over all other caching options.
46-
# skip-cache: true
47-
48-
# Optional: if set to true, then the action won't cache or restore ~/go/pkg.
49-
# skip-pkg-cache: true
50-
51-
# Optional: if set to true, then the action won't cache or restore ~/.cache/go-build.
52-
# skip-build-cache: true
53-
54-
# Optional: The mode to install golangci-lint. It can be 'binary' or 'goinstall'.
55-
# install-mode: "goinstall"
28+
version: v2.1.6
29+

.golangci.yml

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,41 @@
1+
version: "2"
12
run:
23
timeout: 5m
34
allow-parallel-runners: true
4-
5-
issues:
6-
# don't skip warning about doc comments
7-
# don't exclude the default set of lint
8-
exclude-use-default: false
9-
# restore some of the defaults
10-
# (fill in the rest as needed)
11-
exclude-rules:
12-
- path: "api/*"
13-
linters:
14-
- lll
15-
- path: "internal/*"
16-
linters:
17-
- dupl
18-
- lll
195
linters:
20-
disable-all: true
6+
default: none
217
enable:
228
- dupl
239
- errcheck
2410
- ginkgolinter
2511
- goconst
2612
- gocyclo
27-
- gofmt
28-
- goimports
29-
- gosimple
3013
- govet
3114
- ineffassign
3215
- lll
3316
- misspell
3417
- nakedret
3518
- prealloc
3619
- staticcheck
37-
- typecheck
3820
- unconvert
3921
- unparam
4022
- unused
23+
exclusions:
24+
rules:
25+
- path: "api/*"
26+
linters:
27+
- lll
28+
- path: "internal/*"
29+
linters:
30+
- dupl
31+
- lll
32+
formatters:
33+
enable:
34+
- gofmt
35+
- goimports
36+
settings:
37+
gofmt:
38+
simplify: true
39+
goimports:
40+
local-prefixes:
41+
- github.com/argoproj-labs/argocd-rbac-operator

Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# VERSION defines the project version for the bundle.
22
# Update this value when you upgrade the version of your project.
3-
VERSION ?= 0.1.9
3+
VERSION ?= 0.2.0
44

55
# Try to detect Docker or Podman
66
CONTAINER_TOOL := $(shell command -v docker 2> /dev/null)
@@ -176,7 +176,7 @@ GOLANGCI_LINT = $(LOCALBIN)/golangci-lint-$(GOLANGCI_LINT_VERSION)
176176
KUSTOMIZE_VERSION ?= v5.6.0
177177
CONTROLLER_TOOLS_VERSION ?= v0.18.0
178178
ENVTEST_VERSION ?= release-0.18
179-
GOLANGCI_LINT_VERSION ?= v1.64.8
179+
GOLANGCI_LINT_VERSION ?= v2.1.6
180180

181181
.PHONY: kustomize
182182
kustomize: $(KUSTOMIZE) ## Download kustomize locally if necessary.
@@ -196,7 +196,7 @@ $(ENVTEST): $(LOCALBIN)
196196
.PHONY: golangci-lint
197197
golangci-lint: $(GOLANGCI_LINT) ## Download golangci-lint locally if necessary.
198198
$(GOLANGCI_LINT): $(LOCALBIN)
199-
$(call go-install-tool,$(GOLANGCI_LINT),github.com/golangci/golangci-lint/cmd/golangci-lint,${GOLANGCI_LINT_VERSION})
199+
$(call go-install-tool,$(GOLANGCI_LINT),github.com/golangci/golangci-lint/v2/cmd/golangci-lint,${GOLANGCI_LINT_VERSION})
200200

201201
# go-install-tool will 'go install' any package with custom target and name of binary, if it doesn't exist
202202
# $1 - target path with name of binary (ideally with version)

PROJECT

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,22 @@ resources:
2525
kind: ArgoCDRoleBinding
2626
path: github.com/argoproj-labs/argocd-rbac-operator/api/v1alpha1
2727
version: v1alpha1
28+
- api:
29+
crdVersion: v1
30+
namespaced: true
31+
controller: true
32+
domain: argoproj-labs.io
33+
group: rbac-operator
34+
kind: ArgoCDProjectRole
35+
path: github.com/argoproj-labs/argocd-rbac-operator/api/v1alpha1
36+
version: v1alpha1
37+
- api:
38+
crdVersion: v1
39+
namespaced: true
40+
controller: true
41+
domain: argoproj-labs.io
42+
group: rbac-operator
43+
kind: ArgoCDProjectRoleBinding
44+
path: github.com/argoproj-labs/argocd-rbac-operator/api/v1alpha1
45+
version: v1alpha1
2846
version: "3"

README.md

Lines changed: 133 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22

33
[![Go Report Card](https://goreportcard.com/badge/github.com/argoproj-labs/argocd-rbac-operator)](https://goreportcard.com/report/github.com/argoproj-labs/argocd-rbac-operator)
44
[![go.mod Go version](https://img.shields.io/github/go-mod/go-version/argoproj-labs/argocd-rbac-operator)](https://github.com/argoproj-labs/argocd-rbac-operator)
5-
[![GitHub Release](https://img.shields.io/github/v/release/argoproj-labs/argocd-rbac-operator)](https://github.com/argoproj-labs/argocd-rbac-operator/releases/tag/v0.1.9)
5+
[![GitHub Release](https://img.shields.io/github/v/release/argoproj-labs/argocd-rbac-operator)](https://github.com/argoproj-labs/argocd-rbac-operator/releases/tag/v0.2.0)
66
[![Artifact Hub](https://img.shields.io/endpoint?url=https://artifacthub.io/badge/repository/argocd-rbac-operator)](https://artifacthub.io/packages/search?repo=argocd-rbac-operator)
77

88
Kubernetes Operator for Argo CD RBAC Management.
99

1010
## Introduction
1111

12-
The Argo CD RBAC Operator provides a CRD based API for the RBAC management of Argo CD. It provides a structured and easy to use way to define RBAC policies. The Operator uses the CRs as a single source of truth for RBAC management and converts them into a policy string that is patched into the Argo CD RBAC ConfigMap.
12+
The Argo CD RBAC Operator provides a CRD based API for the RBAC management of Argo CD. It provides a structured and easy to use way to define RBAC policies. The Operator uses the CRs as a single source of truth for RBAC management and converts them into a policy string that is patched into the Argo CD RBAC ConfigMap or AppProjects.
1313

1414
## Installation
1515

@@ -64,6 +64,8 @@ helm install argocd-rbac-operator argocd-rbac-operator/argocd-rbac-operator -f v
6464

6565
## Usage
6666

67+
### Global-scoped RBAC
68+
6769
The following example shows a manifest to create a new ArgoCDRole `test-role`:
6870

6971
```yaml
@@ -105,7 +107,7 @@ spec:
105107
name: "test-role"
106108
```
107109

108-
### Create
110+
#### Create ArgoCDRoles and ArgoCDRoleBindings
109111

110112
Make sure that the `argocd` Namespace exists, so that the ConfigMap can be created properly.
111113

@@ -141,7 +143,7 @@ metadata:
141143
namespace: argocd
142144
```
143145

144-
### Delete
146+
#### Delete ArgoCDRoles and ArgoCDRoleBindings
145147

146148
To delete a Role you can use `kubectl`
147149

@@ -152,16 +154,138 @@ kubectl delete argocdrolebinding.rbac-operator.argoproj-labs.io/test-role-bindin
152154

153155
After the Resource is deleted, the policy string will be also deleted from the RBAC-CM.
154156

155-
### Change the Policy.CSV
157+
#### Change the Policy.CSV
156158

157159
To change the policy.csv you have to make changes in the `internal/controller/common/defaults.go` file.
158160

159-
### Deployment types
161+
#### Deployment types
160162

161163
As for now only single Argo CD deployment type is supported. The default Argo CD namespace is defined as `argocd`, to change that you have to provide a flag `--argocd-rbac-cm-namespace="your-argocd-namespace"`.
162164

165+
### AppProject-scoped RBAC
166+
167+
The following example shows a manifest to create a new ArgoCDProjectRole `test-project-role`:
168+
169+
```yaml
170+
apiVersion: rbac-operator.argoproj-labs.io/v1alpha1
171+
kind: ArgoCDProjectRole
172+
metadata:
173+
name: test-project-role
174+
namespace: test-ns
175+
spec:
176+
description: "Test role for ArgoCD's AppProjects"
177+
rules:
178+
- resource: clusters
179+
verbs:
180+
- get
181+
- watch
182+
objects:
183+
- "*"
184+
- resource: applications
185+
verbs:
186+
- get
187+
objects:
188+
- "*"
189+
```
190+
191+
And a ArgoCDProjectRoleBinding `test-project-role-binding` to bind the specified role to a single or multiple AppProjects:
192+
193+
```yaml
194+
apiVersion: rbac-operator.argoproj-labs.io/v1alpha1
195+
kind: ArgoCDProjectRoleBinding
196+
metadata:
197+
name: test-project-role-binding
198+
namespace: test-ns
199+
spec:
200+
argocdProjectRoleRef:
201+
name: test-project-role
202+
subjects:
203+
- appProjectRef: test-appproject-1
204+
groups:
205+
- test-group-1
206+
- test-group-2
207+
- appProjectRef: test-appproject-2
208+
groups:
209+
- test-group-3
210+
- test-group-4
211+
```
212+
213+
#### Create ArgoCDProjectRoles and ArgoCDProjectRoleBindings
214+
215+
Create a new ArgoCDProjectRole and ArgoCDProjectRoleBinding using the provided example. (Make sure that both CRs and AppProjects are created in the same Namespace)
216+
217+
```bash
218+
kubectl create -f test-project-role.yaml
219+
kubectl create -f test-project-role-binding.yaml
220+
```
221+
222+
After the reconciliation a following role will be added to the specified AppProjects:
223+
224+
```yaml
225+
apiVersion: argoproj.io/v1alpha1
226+
kind: AppProject
227+
metadata:
228+
name: test-appproject-1
229+
namespace: test-ns
230+
spec:
231+
description: "Test AppProject 1 for ArgoCD's RBAC Operator"
232+
roles:
233+
...
234+
- description: Test role for ArgoCD's AppProjects
235+
groups:
236+
- test-group-1
237+
- test-group-2
238+
name: test-project-role
239+
policies:
240+
- p, proj:test-appproject-1:test-project-role, clusters, get, *, allow
241+
- p, proj:test-appproject-1:test-project-role, clusters, watch, *, allow
242+
- p, proj:test-appproject-1:test-project-role, applications, get, *, allow
243+
...
244+
---
245+
apiVersion: argoproj.io/v1alpha1
246+
kind: AppProject
247+
metadata:
248+
name: test-appproject-2
249+
namespace: test-ns
250+
spec:
251+
description: "Test AppProject 2 for ArgoCD's RBAC Operator"
252+
roles:
253+
...
254+
- description: Test role for ArgoCD's AppProjects
255+
groups:
256+
- test-group-3
257+
- test-group-4
258+
name: test-project-role
259+
policies:
260+
- p, proj:test-appproject-2:test-project-role, clusters, get, *, allow
261+
- p, proj:test-appproject-2:test-project-role, clusters, watch, *, allow
262+
- p, proj:test-appproject-2:test-project-role, applications, get, *, allow
263+
...
264+
```
265+
266+
#### Changes to ArgoCDProjectRoles and ArgoCDProjectRoleBindings
267+
268+
If changes there made to the CRs, they also will be reflected in referenced AppProjects:
269+
270+
- changes to `spec.rules` of ArgoCDProjectRole
271+
- will be patched to AppProject on next reconcile of ArgoCDProjectRoleBinding
272+
- changes to `spec.subjects` of ArgoCDProjectRoleBindings
273+
- deletion of a subject, will delete the role in AppProject
274+
- change to subject will be reflected in AppProject on next reconcile
275+
276+
#### Delete ArgoCDProjectRoles and ArgoCDProjectRoleBindings
277+
278+
To delete a Role you can use `kubectl`
279+
280+
```bash
281+
kubectl delete argocdprojectroles test-project-role
282+
kubectl delete argocdprojectrolebindings test-project-role-binding
283+
```
284+
285+
After the deletion of the Role or RoleBinding, the Role will also be deleted in AppProject.
286+
163287
## Roadmap
164288

165-
- extend the operator with functionality to manage Argo CD AppProject RBAC
166-
- achieve test coverage of >= 80% (current: ~75%)
167-
- allow management for multi-instances set-up of Argo CD
289+
- [x] extend the operator with functionality to manage Argo CD AppProject RBAC
290+
- [ ] achieve test coverage of >= 80% (current: ~75%)
291+
- [ ] allow management for multi-instances set-up of Argo CD

0 commit comments

Comments
 (0)