Skip to content

Commit

Permalink
feat: add rbac to helm values
Browse files Browse the repository at this point in the history
  • Loading branch information
adityathebe committed Dec 29, 2023
1 parent c250a7f commit df1d1f8
Show file tree
Hide file tree
Showing 3 changed files with 84 additions and 25 deletions.
84 changes: 62 additions & 22 deletions chart/templates/clusterrole.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,53 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
kind: "{{if .Values.serviceAccount.rbac.cluster_role}}Cluster{{end}}Role"
metadata:
name: {{ include "canary-checker.name" . }}-role
rules:
{{- if .Values.serviceAccount.rbac.secrets}}
- apiGroups:
- v1
resources:
- secrets
verbs:
- get
- list
{{- end}}
{{- if .Values.serviceAccount.rbac.configmaps}}
- apiGroups:
- v1
resources:
- configmaps
verbs:
- get
- list
{{- end}}
{{- if .Values.serviceAccount.rbac.exec}}
- apiGroups: [""]
resources:
- pods/attach
- pods/exec
- pods/log
verbs:
- '*'
{{- end}}
{{- if .Values.serviceAccount.rbac.tokenRequest}}
- apiGroups:
- authentication.k8s.io/v1
resources:
- serviceaccounts/token
verbs:
- create
{{- end}}
{{- if .Values.serviceAccount.rbac.readAll}}
- apiGroups:
- '*'
resources:
- '*'
verbs:
- list
- get
- watch
{{- end}}
- apiGroups:
- canaries.flanksource.com
resources:
Expand All @@ -25,6 +70,7 @@ rules:
- get
- patch
- update
{{- if .Values.serviceAccount.rbac.podsCreateAndDelete}}
# for creating and destroying pods during the pod canary test
- apiGroups:
- ""
Expand All @@ -34,46 +80,40 @@ rules:
- services
verbs:
- "*"
{{- end}}
{{- if .Values.serviceAccount.rbac.ingressCreateAndDelete }}
- apiGroups:
- "metrics.k8s.io"
- "networking.k8s.io/v1"
resources:
- pods
- nodes
- ingresses
verbs:
- "*"
# for getting the XML results from junit tests
- apiGroups:
- ""
- "extensions"
resources:
- pods/exec
- pods/log
- ingresses
verbs:
- "*"
{{- end}}
{{- if .Values.serviceAccount.rbac.namespaceCreateAndDelete }}
- apiGroups:
- ""
resources:
- nodes
verbs:
- get
- list
- apiGroups:
- "networking.k8s.io"
- "v1"
resources:
- ingresses
- namespaces
verbs:
- "*"
{{- end}}
- apiGroups:
- "extensions"
- "metrics.k8s.io"
resources:
- ingresses
- pods
- nodes
verbs:
- "*"
# for reading configuration from canaries
- apiGroups:
- ""
resources:
- secrets
- configmaps
- nodes
verbs:
- get
- list
Expand Down
4 changes: 2 additions & 2 deletions chart/templates/clusterrolebinding.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
kind: "{{if .Values.serviceAccount.rbac.cluster_role}}Cluster{{end}}RoleBinding"
metadata:
name: {{ include "canary-checker.fullname" . }}-rolebinding
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
kind: "{{if .Values.serviceAccount.rbac.cluster_role}}Cluster{{end}}Role"
name: {{ include "canary-checker.name" . }}-role
subjects:
- kind: ServiceAccount
Expand Down
21 changes: 20 additions & 1 deletion chart/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,29 @@ resources:
memory: 2Gi

serviceAccount:
{}
# Configures extra annotations on the service account
# annotations:
# some: annotation
rbac:
# Whether to create cluster-wide or namespaced roles
cluster_role: false

# for secret management with valueFrom
tokenRequest: true
secrets: true
configmaps: true

# for use with kubernetes resource lookups
readAll: true

# for pod and junit canaries
podsCreateAndDelete: true

Check failure on line 155 in chart/values.yaml

View workflow job for this annotation

GitHub Actions / helm

[trailing-spaces] trailing spaces
# for pod canary
ingressCreateAndDelete: true

Check failure on line 158 in chart/values.yaml

View workflow job for this annotation

GitHub Actions / helm

[trailing-spaces] trailing spaces
# for namespace canary
namespaceCreateAndDelete: true

disableChecks: {}

Expand Down

0 comments on commit df1d1f8

Please sign in to comment.