-
Notifications
You must be signed in to change notification settings - Fork 326
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use a single serviceaccount and rolebinding for all authmethods.
- Loading branch information
Ashwin Venkatesh
committed
Mar 7, 2022
1 parent
cf1492f
commit 6fdd05a
Showing
17 changed files
with
117 additions
and
163 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{{- if .Values.global.acls.manageSystemACLs }} | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: ClusterRole | ||
metadata: | ||
name: {{ template "consul.fullname" . }}-authmethod | ||
labels: | ||
app: {{ template "consul.name" . }} | ||
chart: {{ template "consul.chart" . }} | ||
heritage: {{ .Release.Service }} | ||
release: {{ .Release.Name }} | ||
component: authmethod | ||
rules: | ||
- apiGroups: [ "" ] | ||
resources: | ||
- serviceaccounts | ||
verbs: | ||
- get | ||
{{- end }} |
39 changes: 39 additions & 0 deletions
39
charts/consul/templates/authmethod-clusterrolebinding.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
{{- if .Values.global.acls.manageSystemACLs }} | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: ClusterRoleBinding | ||
metadata: | ||
name: {{ template "consul.fullname" . }}-authdelegator | ||
labels: | ||
app: {{ template "consul.name" . }} | ||
chart: {{ template "consul.chart" . }} | ||
heritage: {{ .Release.Service }} | ||
release: {{ .Release.Name }} | ||
component: authmethod | ||
roleRef: | ||
apiGroup: rbac.authorization.k8s.io | ||
kind: ClusterRole | ||
name: "system:auth-delegator" | ||
subjects: | ||
- kind: ServiceAccount | ||
name: {{ template "consul.fullname" . }}-authmethod | ||
namespace: {{ .Release.Namespace }} | ||
--- | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: ClusterRoleBinding | ||
metadata: | ||
name: {{ template "consul.fullname" . }}-authmethod | ||
labels: | ||
app: {{ template "consul.name" . }} | ||
chart: {{ template "consul.chart" . }} | ||
heritage: {{ .Release.Service }} | ||
release: {{ .Release.Name }} | ||
component: authmethod | ||
roleRef: | ||
apiGroup: rbac.authorization.k8s.io | ||
kind: ClusterRole | ||
name: {{ template "consul.fullname" . }}-authmethod | ||
subjects: | ||
- kind: ServiceAccount | ||
name: {{ template "consul.fullname" . }}-authmethod | ||
namespace: {{ .Release.Namespace }} | ||
{{- end }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 0 additions & 20 deletions
20
charts/consul/templates/component-authmethod-clusterrolebinding.yaml
This file was deleted.
Oops, something went wrong.
22 changes: 0 additions & 22 deletions
22
charts/consul/templates/connect-inject-authmethod-clusterrolebinding.yaml
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#!/usr/bin/env bats | ||
|
||
load _helpers | ||
|
||
@test "authmethod/ClusterRole: disabled by default" { | ||
cd `chart_dir` | ||
assert_empty helm template \ | ||
-s templates/authmethod-clusterrole.yaml \ | ||
. | ||
} | ||
|
||
@test "authmethod/ClusterRole: enabled with global.acls.manageSystemACLs true" { | ||
cd `chart_dir` | ||
local actual=$(helm template \ | ||
-s templates/authmethod-clusterrole.yaml \ | ||
--set 'global.acls.manageSystemACLs=true' \ | ||
. | tee /dev/stderr | | ||
yq -s 'length > 0' | tee /dev/stderr) | ||
[ "${actual}" = "true" ] | ||
} |
20 changes: 20 additions & 0 deletions
20
charts/consul/test/unit/authmethod-clusterrolebinding.bats
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#!/usr/bin/env bats | ||
|
||
load _helpers | ||
|
||
@test "authmethod/ClusterRoleBinding: disabled by default" { | ||
cd `chart_dir` | ||
assert_empty helm template \ | ||
-s templates/authmethod-clusterrolebinding.yaml \ | ||
. | ||
} | ||
|
||
@test "authmethod/ClusterRoleBinding: enabled with global.acls.manageSystemACLs true" { | ||
cd `chart_dir` | ||
local actual=$(helm template \ | ||
-s templates/authmethod-clusterrolebinding.yaml \ | ||
--set 'global.acls.manageSystemACLs=true' \ | ||
. | tee /dev/stderr | | ||
yq -s 'length > 0' | tee /dev/stderr) | ||
[ "${actual}" = "true" ] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 0 additions & 20 deletions
20
charts/consul/test/unit/component-authmethod-clusterrolebinding.bats
This file was deleted.
Oops, something went wrong.
42 changes: 0 additions & 42 deletions
42
charts/consul/test/unit/connect-inject-authmethod-clusterrolebinding.bats
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.