Skip to content

Commit 50d12d4

Browse files
committed
add kubeaps integration
1 parent df448b9 commit 50d12d4

5 files changed

Lines changed: 200 additions & 5 deletions

File tree

‎packages/core/platform/bundles/paas-full.yaml‎

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
{{- $cozyConfig := lookup "v1" "ConfigMap" "cozy-system" "cozystack" }}
2+
{{- $host := index $cozyConfig.data "root-host" }}
3+
{{- if not $host }}
4+
{{- fail "ERROR need root-host in cozystack ConfigMap" }}
5+
{{- end }}
26

37
releases:
48
- name: fluxcd-operator
@@ -200,11 +204,14 @@ releases:
200204
releaseName: dashboard
201205
chart: cozy-dashboard
202206
namespace: cozy-dashboard
203-
dependsOn: [cilium,kubeovn]
207+
dependsOn: [cilium,kubeovn,keycloak-configure]
208+
valuesFrom:
209+
- kind: ConfigMap
210+
name: kubeapps-auth-config
211+
valuesKey: values.yaml
204212
{{- if .Capabilities.APIVersions.Has "source.toolkit.fluxcd.io/v1" }}
205213
{{- with (lookup "source.toolkit.fluxcd.io/v1" "HelmRepository" "cozy-public" "").items }}
206214
values:
207-
kubeapps:
208215
redis:
209216
master:
210217
podAnnotations:

‎packages/core/platform/bundles/paas-hosted.yaml‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
{{- $cozyConfig := lookup "v1" "ConfigMap" "cozy-system" "cozystack" }}
2+
{{- $host := index $cozyConfig.data "root-host" }}
3+
{{- if not $host }}
4+
{{- fail "ERROR need root-host in cozystack ConfigMap" }}
5+
{{- end }}
26

37
releases:
48
- name: fluxcd-operator
@@ -130,7 +134,11 @@ releases:
130134
releaseName: dashboard
131135
chart: cozy-dashboard
132136
namespace: cozy-dashboard
133-
dependsOn: []
137+
dependsOn: [keycloak-configure]
138+
valuesFrom:
139+
- kind: ConfigMap
140+
name: kubeapps-auth-config
141+
valuesKey: values.yaml
134142
{{- if .Capabilities.APIVersions.Has "source.toolkit.fluxcd.io/v1" }}
135143
{{- with (lookup "source.toolkit.fluxcd.io/v1" "HelmRepository" "cozy-public" "").items }}
136144
values:

‎packages/core/platform/templates/helmreleases.yaml‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,18 @@ spec:
5656
values:
5757
{{- toYaml . | nindent 4}}
5858
{{- end }}
59+
60+
{{- if $x.valuesFrom }}
61+
valuesFrom:
62+
{{- range $source := $x.valuesFrom }}
63+
- kind: {{ $source.kind }}
64+
name: {{ $source.name }}
65+
{{- if $source.valuesKey }}
66+
valuesKey: {{ $source.valuesKey }}
67+
{{- end }}
68+
{{- end }}
69+
{{- end }}
70+
5971
{{- with $x.dependsOn }}
6072
dependsOn:
6173
{{- range $dep := . }}

‎packages/system/keycloak-configure/templates/configure-kk.yaml‎

Lines changed: 157 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
{{- $host := index $cozyConfig.data "root-host" }}
33
{{- $apiServerAdress := index $cozyConfig.data "api-server-adress" }}
44
{{- $k8sClient := randAlphaNum 32 -}}
5+
{{- $kubeappsClient := randAlphaNum 32 -}}
6+
{{- $rootSaConfigMap := lookup "v1" "ConfigMap" "kube-system" "kube-root-ca.crt" }}
7+
{{- $k8sCa := index $rootSaConfigMap.data "ca.crt" | b64enc }}
58

69
apiVersion: v1.edp.epam.com/v1alpha1
710
kind: ClusterKeycloak
@@ -20,8 +23,8 @@ metadata:
2023
name: keycloakrealm-cozy
2124
namespace: {{ .Release.Namespace }}
2225
spec:
23-
realmName: cozy
24-
clusterKeycloakRef: keycloak-cozy
26+
realmName: cozy
27+
clusterKeycloakRef: keycloak-cozy
2528

2629
---
2730

@@ -36,6 +39,7 @@ spec:
3639
kind: ClusterKeycloakRealm
3740
description: "Group Membership"
3841
protocol: openid-connect
42+
default: true
3943
protocolMappers:
4044
- name: groups
4145
protocol: openid-connect
@@ -46,6 +50,8 @@ spec:
4650
"full.path": "false"
4751
"id.token.claim": "true"
4852
"userinfo.token.claim": "true"
53+
attributes:
54+
"include.in.token.scope": "true"
4955

5056
---
5157

@@ -84,3 +90,152 @@ spec:
8490
redirectUris:
8591
- http://localhost:18000
8692
- http://localhost:8000
93+
94+
---
95+
96+
apiVersion: v1.edp.epam.com/v1
97+
kind: KeycloakClientScope
98+
metadata:
99+
name: kubernetes-client
100+
spec:
101+
name: kubernetes-client
102+
realmRef:
103+
name: keycloakrealm-cozy
104+
kind: ClusterKeycloakRealm
105+
description: "kubernetes-client"
106+
protocol: openid-connect
107+
default: true
108+
attributes:
109+
"include.in.token.scope": "true"
110+
protocolMappers:
111+
- name: audience
112+
protocol: openid-connect
113+
protocolMapper: "oidc-audience-mapper"
114+
config:
115+
"included.client.audience": "kubernetes"
116+
"id.token.claim": "true"
117+
"access.token.claim": "true"
118+
"lightweight.claim": "false"
119+
"introspection.token.claim": "true"
120+
121+
---
122+
123+
apiVersion: v1
124+
kind: Secret
125+
metadata:
126+
name: kubeapps-client
127+
type: Opaque
128+
stringData:
129+
client-secret-key: {{ $kubeappsClient }}
130+
131+
---
132+
133+
apiVersion: v1.edp.epam.com/v1
134+
kind: KeycloakClient
135+
metadata:
136+
name: kubeapps-client
137+
spec:
138+
serviceAccount:
139+
enabled: true
140+
realmRef:
141+
name: keycloakrealm-cozy
142+
kind: ClusterKeycloakRealm
143+
secret: $kubeapps-client:client-secret-key
144+
advancedProtocolMappers: true
145+
authorizationServicesEnabled: true
146+
name: kubeapps
147+
clientId: kubeapps
148+
directAccess: true
149+
public: false
150+
webUrl: "https://dashboard.{{ $host }}"
151+
defaultClientScopes:
152+
- groups
153+
- kubernetes-client
154+
redirectUris:
155+
- "http://dashboard.{{ $host }}/oauth2/callback/*"
156+
157+
---
158+
159+
apiVersion: v1
160+
kind: ConfigMap
161+
metadata:
162+
name: kubeapps-auth-config
163+
namespace: cozy-dashboard
164+
data:
165+
values.yaml: |
166+
kubeapps:
167+
authProxy:
168+
enabled: true
169+
provider: "oidc"
170+
clientID: "kubeapps"
171+
clientSecret: {{ $kubeappsClient }}
172+
cookieSecret: {{ randAlphaNum 16 | b64enc | quote }}
173+
extraFlags:
174+
- --ssl-insecure-skip-verify
175+
- --cookie-secure=false
176+
- --scope=openid email groups
177+
- --oidc-issuer-url=https://keycloak.{{ $host }}/realms/cozy
178+
179+
---
180+
181+
apiVersion: v1.edp.epam.com/v1
182+
kind: KeycloakRealmGroup
183+
metadata:
184+
name: kubeapps-admin
185+
namespace: {{ include "tenant.name" . }}
186+
spec:
187+
name: kubeapps-admin
188+
realmRef:
189+
name: keycloakrealm-cozy
190+
kind: ClusterKeycloakRealm
191+
192+
---
193+
194+
apiVersion: rbac.authorization.k8s.io/v1
195+
kind: Role
196+
metadata:
197+
name: tenant-root-dashboard-resources
198+
namespace: tenant-root
199+
rules:
200+
- apiGroups:
201+
- ""
202+
resources:
203+
- secrets
204+
resourceNames:
205+
- kubeconfig
206+
verbs: ["get", "list", "watch"]
207+
208+
209+
---
210+
211+
apiVersion: v1
212+
kind: Secret
213+
metadata:
214+
name: kubeconfig
215+
namespace: tenant-root
216+
stringData:
217+
kubeconfig: |
218+
apiVersion: v1
219+
clusters:
220+
- cluster:
221+
server: https://{{ $apiServerAdress }}:6443
222+
certificate-authority-data: {{ $k8sCa }}
223+
name: cluster
224+
contexts:
225+
- context:
226+
cluster: cluster
227+
user: keycloak
228+
name: default
229+
current-context: default
230+
users:
231+
- name: keycloak
232+
user:
233+
exec:
234+
apiVersion: client.authentication.k8s.io/v1beta1
235+
args:
236+
- oidc-login
237+
- get-token
238+
- --oidc-issuer-url=https://keycloak.{{ $host }}/realms/cozy
239+
- --oidc-client-id=kubernetes
240+
- --oidc-client-secret={{ $k8sClient | quote }}
241+
command: kubectl
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
apiVersion: rbac.authorization.k8s.io/v1
2+
kind: ClusterRoleBinding
3+
metadata:
4+
name: kubeapps-admin-group
5+
namespace: cozy-dashboard
6+
roleRef:
7+
apiGroup: rbac.authorization.k8s.io
8+
kind: ClusterRole
9+
name: admin
10+
subjects:
11+
- apiGroup: rbac.authorization.k8s.io
12+
kind: Group
13+
name: kubeapps-admin

0 commit comments

Comments
 (0)