Skip to content

Commit 0008a8e

Browse files
authored
[stable/k8s-resources]: support ClusterRoles and ClusterRoleBindings (#618)
Signed-off-by: Ievgenii Shepeliuk <[email protected]>
1 parent b422462 commit 0008a8e

File tree

6 files changed

+129
-3
lines changed

6 files changed

+129
-3
lines changed

stable/k8s-resources/Chart.yaml

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
apiVersion: v1
2-
version: 0.6.6
2+
version: 0.7.0
33
appVersion: 0.0.1
44
name: k8s-resources
55
description: |
@@ -17,6 +17,8 @@ description: |
1717
- Service
1818
- ServiceAccount
1919
- ScaledObject (KEDA)
20+
- ClusterRole
21+
- ClusterRoleBinding
2022
2123
Every resource type can have custom labels, annotations or a `fullnameOverride` set. See default [values.yaml](https://github.com/deliveryhero/helm-charts/blob/master/stable/k8s-resources/values.yaml) for examples.
2224

stable/k8s-resources/README.md

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# k8s-resources
22

3-
![Version: 0.6.6](https://img.shields.io/badge/Version-0.6.6-informational?style=flat-square) ![AppVersion: 0.0.1](https://img.shields.io/badge/AppVersion-0.0.1-informational?style=flat-square)
3+
![Version: 0.7.0](https://img.shields.io/badge/Version-0.7.0-informational?style=flat-square) ![AppVersion: 0.0.1](https://img.shields.io/badge/AppVersion-0.0.1-informational?style=flat-square)
44

55
Not an application but a Helm chart to create any and many resources in Kubernetes.
66

@@ -16,6 +16,8 @@ Currently supports:
1616
- Service
1717
- ServiceAccount
1818
- ScaledObject (KEDA)
19+
- ClusterRole
20+
- ClusterRoleBinding
1921

2022
Every resource type can have custom labels, annotations or a `fullnameOverride` set. See default [values.yaml](https://github.com/deliveryhero/helm-charts/blob/master/stable/k8s-resources/values.yaml) for examples.
2123

@@ -32,7 +34,7 @@ helm install --generate-name oci://ghcr.io/deliveryhero/helm-charts/k8s-resource
3234
To install a specific version of this chart:
3335

3436
```console
35-
helm install --generate-name oci://ghcr.io/deliveryhero/helm-charts/k8s-resources --version 0.6.6
37+
helm install --generate-name oci://ghcr.io/deliveryhero/helm-charts/k8s-resources --version 0.7.0
3638
```
3739

3840
To install the chart with the release name `my-release`:
@@ -57,6 +59,8 @@ helm install my-release oci://ghcr.io/deliveryhero/helm-charts/k8s-resources -f
5759

5860
| Key | Type | Default | Description |
5961
|-----|------|---------|-------------|
62+
| ClusterRoleBindings | list | `[]` | A list ClusterRoleBindings to create |
63+
| ClusterRoles | list | `[]` | A list ClusterRoles to create |
6064
| ConfigMaps | list | `[]` | A list ConfigMap to create |
6165
| CronJobs | list | `[]` | A list CronJobs to create |
6266
| CustomResources | list | `[]` | A list resources to create that are completely custom |

stable/k8s-resources/ci/ct-values.yaml

+39
Original file line numberDiff line numberDiff line change
@@ -116,3 +116,42 @@ Namespaces:
116116
fullnameOverride: ""
117117
annotations: {}
118118
extraLabels: {}
119+
120+
ClusterRoles:
121+
- name: example-cr-1
122+
fullnameOverride: ""
123+
annotations: {}
124+
extraLabels: {}
125+
rules:
126+
- apiGroups:
127+
- ""
128+
resources:
129+
- configmaps
130+
verbs:
131+
- '*'
132+
- name: example-cr-2
133+
extraLabels:
134+
mylabel: myvalue
135+
136+
ClusterRoleBindings:
137+
- name: example-crb-1
138+
fullnameOverride: ""
139+
annotations: {}
140+
extraLabels: {}
141+
roleRef:
142+
kind: ClusterRole
143+
name: cluster-admin
144+
apiGroup: rbac.authorization.k8s.io
145+
subjects:
146+
- kind: ServiceAccount
147+
name: my-sa
148+
namespace: my-ns
149+
- name: example-crb-2
150+
fullnameOverride: ""
151+
annotations: {}
152+
extraLabels:
153+
mylabel: myvalue
154+
roleRef:
155+
kind: ClusterRole
156+
name: cluster-admin
157+
apiGroup: rbac.authorization.k8s.io
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{{- if .Values.ClusterRoles -}}
2+
{{- range .Values.ClusterRoles }}
3+
apiVersion: rbac.authorization.k8s.io/v1
4+
kind: ClusterRole
5+
metadata:
6+
{{- if .namespace }}
7+
namespace: {{ .namespace }}
8+
{{- end }}
9+
name: {{ if .fullnameOverride }}{{ .fullnameOverride }}{{ else }}{{ include "k8s-resources.fullname" $ }}-{{ .name }}{{ end }}
10+
labels:
11+
{{- include "k8s-resources.labels" $ | nindent 4 }}
12+
{{- with .extraLabels }}
13+
{{- toYaml . | nindent 4 }}
14+
{{- end }}
15+
{{- with .annotations }}
16+
annotations:
17+
{{- toYaml . | nindent 4 }}
18+
{{- end }}
19+
{{- with .rules }}
20+
rules:
21+
{{- toYaml . | nindent 2 }}
22+
{{- end }}
23+
---
24+
{{- end }}
25+
{{- end }}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{{- if .Values.ClusterRoleBindings -}}
2+
{{- range .Values.ClusterRoleBindings }}
3+
apiVersion: rbac.authorization.k8s.io/v1
4+
kind: ClusterRoleBinding
5+
metadata:
6+
{{- if .namespace }}
7+
namespace: {{ .namespace }}
8+
{{- end }}
9+
name: {{ if .fullnameOverride }}{{ .fullnameOverride }}{{ else }}{{ include "k8s-resources.fullname" $ }}-{{ .name }}{{ end }}
10+
labels:
11+
{{- include "k8s-resources.labels" $ | nindent 4 }}
12+
{{- with .extraLabels }}
13+
{{- toYaml . | nindent 4 }}
14+
{{- end }}
15+
{{- with .annotations }}
16+
annotations:
17+
{{- toYaml . | nindent 4 }}
18+
{{- end }}
19+
roleRef:
20+
{{- toYaml .roleRef | nindent 2 }}
21+
{{- with .subjects }}
22+
subjects:
23+
{{- toYaml . | nindent 2 }}
24+
{{- end }}
25+
---
26+
{{- end }}
27+
{{- end }}

stable/k8s-resources/values.yaml

+29
Original file line numberDiff line numberDiff line change
@@ -152,3 +152,32 @@ ScaledObjects: []
152152
# cortexOrgID: logistics
153153
# threshold: "4"
154154
# type: prometheus
155+
156+
# ClusterRoles -- A list ClusterRoles to create
157+
ClusterRoles: []
158+
# - name: example-cr
159+
# fullnameOverride: ""
160+
# annotations: {}
161+
# extraLabels: {}
162+
# rules:
163+
# - apiGroups:
164+
# - ""
165+
# resources:
166+
# - configmaps
167+
# verbs:
168+
# - '*'
169+
170+
# ClusterRoleBindings -- A list ClusterRoleBindings to create
171+
ClusterRoleBindings: []
172+
# - name: example-crb
173+
# fullnameOverride: ""
174+
# annotations: {}
175+
# extraLabels: {}
176+
# roleRef:
177+
# kind: ClusterRole
178+
# name: cluster-admin
179+
# apiGroup: rbac.authorization.k8s.io
180+
# subjects:
181+
# - kind: ServiceAccount
182+
# name: my-sa
183+
# namespace: my-ns

0 commit comments

Comments
 (0)