Skip to content

Commit edbbb9b

Browse files
authored
add kubeaps integration (#486)
<!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit ## Release Notes - **New Features** - Introduced a new variable `$host` for improved configuration management. - Added a `valuesFrom` section to the `dashboard` release, allowing external value sourcing. - Enhanced Keycloak integration with new client scopes, roles, and configurations for Kubeapps. - Added support for custom pod specifications and environment variables in Redis configurations. - Introduced a new Kubernetes configuration file for managing access to resources via Role and Secret. - Updated image versions across various components to ensure compatibility and leverage new features. - **Bug Fixes** - Implemented error handling to ensure required configurations are present. - Improved handling of request headers for the `/logos` endpoint in Nginx configuration. - Adjusted security context configurations to enhance deployment security. - **Documentation** - Updated configuration files to reflect new dependencies and structures for better clarity. - Enhanced README documentation with upgrade instructions and security defaults. - Expanded notes on handling persistent volumes and data migration during upgrades. These enhancements improve the overall functionality and reliability of the platform. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
1 parent 9a699d7 commit edbbb9b

Some content is hidden

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

44 files changed

+4003
-576
lines changed

packages/apps/tenant/Chart.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ description: Separated tenant namespace
44
icon: /logos/tenant.svg
55

66
type: application
7-
version: 1.6.0
7+
version: 1.6.1
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
{{- $cozyConfig := lookup "v1" "ConfigMap" "cozy-system" "cozystack" }}
2+
{{- $host := index $cozyConfig.data "root-host" }}
3+
{{- $apiServerAdress := index $cozyConfig.data "api-server-adress" }}
4+
{{- $k8sClientSecret := lookup "v1" "Secret" "cozy-keycloak" "k8s-client" }}
5+
{{- $k8sClient := index $k8sClientSecret.data "client-secret-key" | b64dec }}
6+
{{- $rootSaConfigMap := lookup "v1" "ConfigMap" "kube-system" "kube-root-ca.crt" }}
7+
{{- $k8sCa := index $rootSaConfigMap.data "ca.crt" | b64enc }}
8+
9+
apiVersion: rbac.authorization.k8s.io/v1
10+
kind: Role
11+
metadata:
12+
name: {{ include "tenant.name" . }}-dashboard-resources
13+
namespace: {{ .Release.namespace }}
14+
rules:
15+
- apiGroups:
16+
- ""
17+
resources:
18+
- secrets
19+
resourceNames:
20+
- kubeconfig-{{ include "tenant.name" . }}
21+
verbs: ["get", "list", "watch"]
22+
23+
24+
---
25+
26+
apiVersion: v1
27+
kind: Secret
28+
metadata:
29+
name: kubeconfig-{{ include "tenant.name" . }}
30+
namespace: tenant-root
31+
stringData:
32+
kubeconfig: |
33+
apiVersion: v1
34+
clusters:
35+
- cluster:
36+
server: https://{{ $apiServerAdress }}:6443
37+
certificate-authority-data: {{ $k8sCa }}
38+
name: cluster
39+
contexts:
40+
- context:
41+
cluster: cluster
42+
namespace: {{ include "tenant.name" . }}
43+
user: keycloak
44+
name: {{ include "tenant.name" . }}
45+
current-context: default
46+
users:
47+
- name: keycloak
48+
user:
49+
exec:
50+
apiVersion: client.authentication.k8s.io/v1beta1
51+
args:
52+
- oidc-login
53+
- get-token
54+
- --oidc-issuer-url=https://keycloak.{{ $host }}/realms/cozy
55+
- --oidc-client-id=kubernetes
56+
- --oidc-client-secret={{ $k8sClient }}
57+
- --skip-open-browser
58+
- --grant-type=password
59+
command: kubectl

packages/apps/tenant/templates/tenant.yaml

Lines changed: 195 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ subjects:
4343
- kind: ServiceAccount
4444
name: tenant-root
4545
namespace: tenant-root
46+
- kind: Group
47+
name: tenant-root-super-admin
48+
apiGroup: rbac.authorization.k8s.io
4649
{{- end }}
4750
{{- if hasPrefix "tenant-" .Release.Namespace }}
4851
{{- $parts := splitList "-" .Release.Namespace }}
@@ -51,12 +54,18 @@ subjects:
5154
- kind: ServiceAccount
5255
name: {{ join "-" (slice $parts 0 (add $i 1)) }}
5356
namespace: {{ join "-" (slice $parts 0 (add $i 1)) }}
57+
- kind: Group
58+
name: {{ join "-" (slice $parts 0 (add $i 1)) }}-super-admin
59+
apiGroup: rbac.authorization.k8s.io
5460
{{- end }}
5561
{{- end }}
5662
{{- end }}
5763
- kind: ServiceAccount
5864
name: {{ include "tenant.name" . }}
5965
namespace: {{ include "tenant.name" . }}
66+
- kind: Group
67+
name: {{ include "tenant.name" . }}-super-admin
68+
apiGroup: rbac.authorization.k8s.io
6069
roleRef:
6170
kind: Role
6271
name: {{ include "tenant.name" . }}
@@ -84,6 +93,9 @@ subjects:
8493
- kind: ServiceAccount
8594
name: {{ include "tenant.name" . }}
8695
namespace: {{ include "tenant.name" . }}
96+
- kind: Group
97+
name: {{ include "tenant.name" . }}-super-admin
98+
apiGroup: rbac.authorization.k8s.io
8799
roleRef:
88100
kind: Role
89101
name: {{ include "tenant.name" . }}
@@ -95,16 +107,47 @@ metadata:
95107
name: {{ include "tenant.name" . }}-view
96108
namespace: {{ include "tenant.name" . }}
97109
rules:
98-
- apiGroups: ["apps.cozystack.io"]
99-
resources: ["*"]
100-
verbs: ["get", "list", "watch"]
101-
- apiGroups: ["helm.toolkit.fluxcd.io"]
102-
resources: ["helmreleases"]
103-
verbs: ["get", "list", "watch"]
104-
- apiGroups: [""]
105-
resources: ["pods", "pods/log"]
106-
verbs: ["get", "list", "watch"]
110+
- apiGroups:
111+
- rbac.authorization.k8s.io
112+
resources:
113+
- roles
114+
verbs:
115+
- get
116+
- apiGroups:
117+
- apps.cozystack.io
118+
resources:
119+
- "*"
120+
verbs:
121+
- get
122+
- list
123+
- watch
124+
- apiGroups:
125+
- helm.toolkit.fluxcd.io
126+
resources:
127+
- helmreleases
128+
verbs:
129+
- get
130+
- list
131+
- watch
132+
- apiGroups:
133+
- ""
134+
resources:
135+
- "*"
136+
verbs:
137+
- get
138+
- list
139+
- watch
140+
- apiGroups:
141+
- networking.k8s.io
142+
resources:
143+
- ingresses
144+
verbs:
145+
- get
146+
- list
147+
- watch
148+
107149
---
150+
108151
kind: RoleBinding
109152
apiVersion: rbac.authorization.k8s.io/v1
110153
metadata:
@@ -125,21 +168,46 @@ metadata:
125168
name: {{ include "tenant.name" . }}-use
126169
namespace: {{ include "tenant.name" . }}
127170
rules:
171+
- apiGroups: [rbac.authorization.k8s.io]
172+
resources:
173+
- roles
174+
verbs:
175+
- get
128176
- apiGroups: ["apps.cozystack.io"]
129-
resources: ["*"]
130-
verbs: ["get", "list", "watch"]
177+
resources:
178+
- "*"
179+
verbs:
180+
- get
181+
- list
182+
- watch
131183
- apiGroups: ["helm.toolkit.fluxcd.io"]
132-
resources: ["helmreleases"]
133-
verbs: ["get", "list", "watch"]
184+
resources:
185+
- helmreleases
186+
verbs:
187+
- get
188+
- list
189+
- watch
134190
- apiGroups: [""]
135-
resources: ["pods", "pods/log"]
136-
verbs: ["get", "list", "watch"]
137-
- apiGroups: ["kubevirt.io"]
138-
resources: ["virtualmachines"]
139-
verbs: ["get", "list"]
191+
resources:
192+
- "*"
193+
verbs:
194+
- get
195+
- list
196+
- watch
197+
- apiGroups: ["networking.k8s.io"]
198+
resources:
199+
- ingresses
200+
verbs:
201+
- get
202+
- list
203+
- watch
140204
- apiGroups: ["subresources.kubevirt.io"]
141-
resources: ["virtualmachineinstances/console", "virtualmachineinstances/vnc"]
142-
verbs: ["get", "list"]
205+
resources:
206+
- virtualmachineinstances/console
207+
- virtualmachineinstances/vnc
208+
verbs:
209+
- get
210+
- list
143211
---
144212
kind: RoleBinding
145213
apiVersion: rbac.authorization.k8s.io/v1
@@ -161,70 +229,135 @@ metadata:
161229
name: {{ include "tenant.name" . }}-admin
162230
namespace: {{ include "tenant.name" . }}
163231
rules:
164-
- apiGroups: ["helm.toolkit.fluxcd.io"]
165-
resources: ["helmreleases"]
166-
verbs: ["get", "list", "watch", "create", "update", "patch", "delete"]
232+
- apiGroups: [rbac.authorization.k8s.io]
233+
resources:
234+
- roles
235+
verbs:
236+
- get
167237
- apiGroups: [""]
168-
resources: ["pods/log", "pods"]
169-
verbs: ["get", "list", "watch", "delete"]
238+
resources:
239+
- "*"
240+
verbs:
241+
- get
242+
- list
243+
- watch
244+
- delete
245+
- apiGroups: ["helm.toolkit.fluxcd.io"]
246+
resources:
247+
- helmreleases
248+
verbs:
249+
- get
250+
- list
251+
- watch
170252
- apiGroups: ["kubevirt.io"]
171-
resources: ["virtualmachines"]
172-
verbs: ["get", "list"]
253+
resources:
254+
- virtualmachines
255+
verbs:
256+
- get
257+
- list
173258
- apiGroups: ["subresources.kubevirt.io"]
174-
resources: ["virtualmachineinstances/console", "virtualmachineinstances/vnc"]
175-
verbs: ["get", "list"]
259+
resources:
260+
- virtualmachineinstances/console
261+
- virtualmachineinstances/vnc
262+
verbs:
263+
- get
264+
- list
176265
- apiGroups: ["apps.cozystack.io"]
177-
resources: ["buckets", "clickhouses", "ferretdb", "foos", "httpcaches", "kafkas", "kuberneteses", "mysqls", "natses", "postgreses", "rabbitmqs", "redises", "seaweedfses", "tcpbalancers", "virtualmachines", "vmdisks", "vminstances"]
178-
verbs: ["get", "list", "watch", "create", "update", "patch", "delete"]
266+
resources:
267+
- buckets
268+
- clickhouses
269+
- ferretdb
270+
- foos
271+
- httpcaches
272+
- kafkas
273+
- kuberneteses
274+
- mysqls
275+
- natses
276+
- postgreses
277+
- rabbitmqs
278+
- redises
279+
- seaweedfses
280+
- tcpbalancers
281+
- virtualmachines
282+
- vmdisks
283+
- vminstances
284+
verbs:
285+
- get
286+
- list
287+
- watch
288+
- create
289+
- update
290+
- patch
291+
- delete
292+
179293

180294
---
181-
kind: RoleBinding
182295
apiVersion: rbac.authorization.k8s.io/v1
296+
kind: Role
183297
metadata:
184298
name: {{ include "tenant.name" . }}-admin
185-
namespace: {{ include "tenant.name" . }}
299+
namespace: cozy-public
300+
rules:
301+
- apiGroups: ["source.toolkit.fluxcd.io"]
302+
resources: ["helmrepositories"]
303+
verbs:
304+
- get
305+
- list
306+
- apiGroups:
307+
- source.toolkit.fluxcd.io
308+
resources:
309+
- helmcharts
310+
verbs:
311+
- get
312+
- list
313+
- apiGroups: ["source.toolkit.fluxcd.io"]
314+
resources:
315+
- helmcharts
316+
verbs: ["*"]
317+
resourceNames:
318+
- bucket
319+
- clickhouse
320+
- ferretdb
321+
- foo
322+
- httpcache
323+
- kafka
324+
- kubernetes
325+
- mysql
326+
- nats
327+
- postgres
328+
- rabbitmq
329+
- redis
330+
- seaweedfs
331+
- tcpbalancer
332+
- virtualmachine
333+
- vmdisk
334+
- vminstance
335+
336+
---
337+
apiVersion: rbac.authorization.k8s.io/v1
338+
kind: RoleBinding
339+
metadata:
340+
name: {{ include "tenant.name" . }}-admin
341+
namespace: cozy-public
186342
subjects:
187-
- kind: Group
188-
name: {{ include "tenant.name" . }}-admin
189-
apiGroup: rbac.authorization.k8s.io
343+
- kind: Group
344+
name: {{ include "tenant.name" . }}-admin
345+
apiGroup: rbac.authorization.k8s.io
190346
roleRef:
191347
kind: Role
192348
name: {{ include "tenant.name" . }}-admin
193349
apiGroup: rbac.authorization.k8s.io
194350
---
195-
kind: Role
196-
apiVersion: rbac.authorization.k8s.io/v1
197-
metadata:
198-
name: {{ include "tenant.name" . }}-super-admin
199-
namespace: {{ include "tenant.name" . }}
200-
rules:
201-
- apiGroups: ["helm.toolkit.fluxcd.io"]
202-
resources: ["helmreleases"]
203-
verbs: ["get", "list", "watch", "create", "update", "patch", "delete"]
204-
- apiGroups: [""]
205-
resources: ["pods/log", "pods"]
206-
verbs: ["get", "list", "watch", "delete"]
207-
- apiGroups: ["kubevirt.io"]
208-
resources: ["virtualmachines"]
209-
verbs: ["get", "list"]
210-
- apiGroups: ["subresources.kubevirt.io"]
211-
resources: ["virtualmachineinstances/console", "virtualmachineinstances/vnc"]
212-
verbs: ["get", "list"]
213-
- apiGroups: ["apps.cozystack.io"]
214-
resources: ["*"]
215-
verbs: ["get", "list", "watch", "create", "update", "patch", "delete"]
216-
217-
---
218351
kind: RoleBinding
219352
apiVersion: rbac.authorization.k8s.io/v1
220353
metadata:
221-
name: {{ include "tenant.name" . }}-super-admin
354+
name: {{ include "tenant.name" . }}-admin
222355
namespace: {{ include "tenant.name" . }}
223356
subjects:
224357
- kind: Group
225-
name: {{ include "tenant.name" . }}-super-admin
358+
name: {{ include "tenant.name" . }}-admin
226359
apiGroup: rbac.authorization.k8s.io
227360
roleRef:
228361
kind: Role
229-
name: {{ include "tenant.name" . }}-super-admin
362+
name: {{ include "tenant.name" . }}-admin
230363
apiGroup: rbac.authorization.k8s.io

0 commit comments

Comments
 (0)