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
69apiVersion : v1.edp.epam.com/v1alpha1
710kind : ClusterKeycloak
@@ -20,8 +23,8 @@ metadata:
2023 name : keycloakrealm-cozy
2124 namespace : {{ .Release.Namespace }}
2225spec :
23- realmName : cozy
24- clusterKeycloakRef : keycloak-cozy
26+ realmName : cozy
27+ clusterKeycloakRef : keycloak-cozy
2528
2629---
2730
3639 kind : ClusterKeycloakRealm
3740 description : " Group Membership"
3841 protocol : openid-connect
42+ default : true
3943 protocolMappers :
4044 - name : groups
4145 protocol : openid-connect
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
0 commit comments