Skip to content

Commit 162a5f9

Browse files
author
wwanarif
committed
enabled keycloak and mysql integration
Signed-off-by: wwanarif <[email protected]>
1 parent e919c09 commit 162a5f9

File tree

28 files changed

+906
-137
lines changed

28 files changed

+906
-137
lines changed

setup-scripts/setup-genai-studio/manifests/studio-manifest-aws-ecr.yaml

Lines changed: 151 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,13 @@ data:
2020
# SPDX-License-Identifier: Apache-2.0
2121
2222
server {
23-
listen 80;
24-
listen [::]:80;
23+
# listen 80;
24+
# listen [::]:80;
25+
listen 443 ssl;
26+
listen [::]:443 ssl;
27+
28+
ssl_certificate /etc/ssl/tls.crt;
29+
ssl_certificate_key /etc/ssl/tls.key;
2530
2631
proxy_connect_timeout 600;
2732
proxy_send_timeout 600;
@@ -34,7 +39,7 @@ data:
3439
resolver_timeout 5s;
3540
3641
location /home {
37-
root /usr/share/nginx/html; # Use root to serve files from a directory
42+
root /usr/share/nginx/html;
3843
index index.html;
3944
}
4045
@@ -71,6 +76,15 @@ data:
7176
proxy_set_header X-Forwarded-Proto $scheme;
7277
}
7378
79+
# Location block for keycloak
80+
location /auth {
81+
proxy_pass https://${KEYCLOAK_DNS}/auth/;
82+
proxy_set_header Host $host:30007;
83+
proxy_set_header X-Real-IP $remote_addr;
84+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
85+
proxy_set_header X-Forwarded-Proto $scheme;
86+
}
87+
7488
# Location block for app-backend
7589
location /v1/app-backend {
7690
# Initialize the variable for namespace
@@ -170,10 +184,11 @@ spec:
170184
selector:
171185
app: studio-nginx
172186
ports:
173-
- protocol: TCP
174-
port: 80
175-
targetPort: 80
176-
nodePort: 30007
187+
- name: https
188+
protocol: TCP
189+
port: 443
190+
targetPort: 443
191+
nodePort: 30007
177192
type: NodePort
178193
---
179194
apiVersion: apps/v1
@@ -201,7 +216,7 @@ spec:
201216
envsubst "$(env | grep _DNS= | awk -F= '{print "${"$1"}"}' | tr '\n' ' ')" < /tmp/default.conf > /etc/nginx/conf.d/default.conf
202217
envFrom:
203218
- configMapRef:
204-
name: internal-dns-config
219+
name: studio-config
205220
volumeMounts:
206221
- name: tmp-volume
207222
mountPath: /tmp
@@ -214,6 +229,8 @@ spec:
214229
volumeMounts:
215230
- name: nginx-conf-volume
216231
mountPath: /etc/nginx/conf.d
232+
- name: tls
233+
mountPath: /etc/ssl
217234
securityContext: {}
218235
volumes:
219236
- name: tmp-volume
@@ -222,6 +239,9 @@ spec:
222239
name: studio-nginx-config
223240
- name: nginx-conf-volume
224241
emptyDir: {}
242+
- name: tls
243+
secret:
244+
secretName: tls-secret
225245
---
226246
apiVersion: v1
227247
kind: Service
@@ -272,6 +292,9 @@ rules:
272292
- apiGroups: [""]
273293
resources: ["persistentvolumeclaims"]
274294
verbs: ["get", "create", "list", "watch"]
295+
- apiGroups: [""]
296+
resources: ["persistentvolumeclaims"]
297+
verbs: ["get", "create", "list", "watch"]
275298
---
276299
apiVersion: rbac.authorization.k8s.io/v1
277300
kind: ClusterRoleBinding
@@ -322,7 +345,7 @@ spec:
322345
value: ${NO_PROXY}
323346
envFrom:
324347
- configMapRef:
325-
name: internal-dns-config
348+
name: studio-config
326349
ports:
327350
- containerPort: 5000
328351
resources:
@@ -394,4 +417,122 @@ spec:
394417
- name: ecr-registry-secret
395418
volumes:
396419
- name: tmp
397-
emptyDir: {}
420+
emptyDir: {}
421+
---
422+
apiVersion: apps/v1
423+
kind: Deployment
424+
metadata:
425+
name: keycloak
426+
namespace: studio
427+
labels:
428+
app: keycloak
429+
spec:
430+
replicas: 1
431+
selector:
432+
matchLabels:
433+
app: keycloak
434+
template:
435+
metadata:
436+
labels:
437+
app: keycloak
438+
spec:
439+
initContainers:
440+
- name: keycloak-assets
441+
image: curlimages/curl:latest
442+
command: ["/bin/sh", "-c"]
443+
args:
444+
- |
445+
OWNER=$(echo ${KC_ASSETS_GIT_URL} | sed -E 's|https://github.com/([^/]+)/([^/]+)/tree/([^/]+)/.*|\1|')
446+
REPO=$(echo ${KC_ASSETS_GIT_URL} | sed -E 's|https://github.com/([^/]+)/([^/]+)/tree/([^/]+)/.*|\2|')
447+
BRANCH=$(echo ${KC_ASSETS_GIT_URL} | sed -E 's|https://github.com/[^/]+/[^/]+/tree/([^/]+)/.*|\1|')
448+
KC_ASSETS_DIR=$(echo ${KC_ASSETS_GIT_URL} | sed -E 's|https://github.com/[^/]+/[^/]+/tree/[^/]+/(.*?)/?$|\1|')
449+
if [[ "${KC_ASSETS_DIR: -1}" == "/" ]]; then KC_ASSETS_DIR="${KC_ASSETS_DIR%/}"; fi
450+
DOWNLOAD_URL="https://codeload.github.com/${OWNER}/${REPO}/tar.gz/${BRANCH}"
451+
curl "${DOWNLOAD_URL}" | tar -xz --strip-components=4 -C /opt/keycloak/themes "${REPO}-${BRANCH}/${KC_ASSETS_DIR}/themes"
452+
curl "${DOWNLOAD_URL}" | tar -xz --strip-components=4 -C /opt/keycloak/data "${REPO}-${BRANCH}/${KC_ASSETS_DIR}/data"
453+
envFrom:
454+
- configMapRef:
455+
name: studio-config
456+
volumeMounts:
457+
- name: keycloak-themes-volume
458+
mountPath: /opt/keycloak/themes
459+
- name: keycloak-dataimport-volume
460+
mountPath: /opt/keycloak/data/import
461+
securityContext:
462+
runAsUser: 0
463+
runAsGroup: 0
464+
containers:
465+
- name: keycloak
466+
image: quay.io/keycloak/keycloak:latest
467+
volumeMounts:
468+
- name: tls
469+
mountPath: /etc/ssl
470+
readOnly: true
471+
- name: keycloak-themes-volume
472+
mountPath: /opt/keycloak/themes
473+
- name: keycloak-dataimport-volume
474+
mountPath: /opt/keycloak/data/import
475+
args:
476+
- start
477+
- --import-realm
478+
ports:
479+
- containerPort: 8080
480+
- containerPort: 8443
481+
env:
482+
- name: KC_BOOTSTRAP_ADMIN_USERNAME
483+
value: "admin"
484+
- name: KC_BOOTSTRAP_ADMIN_PASSWORD
485+
value: "admin"
486+
- name: KC_PROXY_HEADERS
487+
value: "forwarded"
488+
- name: KC_HTTP_RELATIVE_PATH
489+
value: "/auth"
490+
- name: KC_PROXY
491+
value: edge
492+
- name: KC_HTTPS_CERTIFICATE_FILE
493+
value: /etc/ssl/tls.crt
494+
- name: KC_HTTPS_CERTIFICATE_KEY_FILE
495+
value: /etc/ssl/tls.key
496+
- name: KC_HOSTNAME_STRICT
497+
value: "false"
498+
- name: KC_HOSTNAME_STRICT_HTTPS
499+
value: "true"
500+
readinessProbe:
501+
failureThreshold: 3
502+
httpGet:
503+
path: auth/realms/master
504+
port: 8443
505+
scheme: HTTPS
506+
periodSeconds: 10
507+
successThreshold: 1
508+
timeoutSeconds: 1
509+
resources:
510+
requests:
511+
memory: "512Mi"
512+
cpu: "500m"
513+
limits:
514+
memory: "1Gi"
515+
cpu: "1"
516+
volumes:
517+
- name: tls
518+
secret:
519+
secretName: tls-secret
520+
- name: keycloak-themes-volume
521+
emptyDir: {}
522+
- name: keycloak-dataimport-volume
523+
emptyDir: {}
524+
---
525+
apiVersion: v1
526+
kind: Service
527+
metadata:
528+
name: keycloak
529+
namespace: studio
530+
spec:
531+
type: ClusterIP
532+
ports:
533+
- name: https
534+
protocol: TCP
535+
port: 8443
536+
targetPort: 8443
537+
selector:
538+
app: keycloak

0 commit comments

Comments
 (0)