Skip to content

Commit ca9f11b

Browse files
authored
Add gatekeeper auth (#8)
* Added keycloak gatekeeper auth * Fixed rewrite conflict
1 parent 4e6880d commit ca9f11b

File tree

4 files changed

+25
-6
lines changed

4 files changed

+25
-6
lines changed

rstudio/templates/deployment.yaml

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,16 @@ metadata:
44
name: {{ include "rstudio.fullname" . }}
55
labels:
66
{{- include "rstudio.labels" . | nindent 4 }}
7+
annotations:
8+
authproxy.stakater.com/enabled: "true"
9+
authproxy.stakater.com/source-service-name: {{ .Release.Name }}-service
10+
authproxy.stakater.com/upstream-url: "http://localhost:8787/"
11+
authproxy.stakater.com/client-id: {{ .Values.oidc.client_id }}
12+
authproxy.stakater.com/client-secret: {{ .Values.oidc.client_secret }}
13+
authproxy.stakater.com/listen: ":80"
14+
authproxy.stakater.com/discovery-url: {{ tpl .Values.oidc.discovery_url . }}
15+
authproxy.stakater.com/oauth-uri: "{{ .Values.ingress.access_path }}oauth"
16+
authproxy.stakater.com/gatekeeper-image: keycloak/keycloak-gatekeeper:7.0.0
717
spec:
818
replicas: {{ .Values.replicaCount }}
919
selector:
@@ -50,16 +60,16 @@ spec:
5060
value: "true"
5161
ports:
5262
- name: http
53-
containerPort: 8787
63+
containerPort: 80
5464
protocol: TCP
5565
livenessProbe:
5666
httpGet:
5767
path: /
58-
port: http
68+
port: 8787
5969
readinessProbe:
6070
httpGet:
6171
path: /
62-
port: http
72+
port: 8787
6373
resources:
6474
{{- toYaml .Values.resources | nindent 12 }}
6575
volumeMounts:

rstudio/templates/ingress.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ metadata:
1313
{{- include "rstudio.labels" . | nindent 4 }}
1414
{{- with .Values.ingress.annotations }}
1515
annotations:
16-
{{- toYaml . | nindent 4 }}
16+
{{- tpl (toYaml .) $ | nindent 4 }}
1717
{{- end }}
1818
spec:
1919
{{- if .Values.ingress.tls }}
@@ -34,7 +34,7 @@ spec:
3434
{{- range .paths }}
3535
- path: {{ . }}
3636
backend:
37-
serviceName: {{ $fullName }}
37+
serviceName: {{ $fullName }}-service
3838
servicePort: {{ $svcPort }}
3939
{{- end }}
4040
{{- end }}

rstudio/templates/service.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
apiVersion: v1
22
kind: Service
33
metadata:
4-
name: {{ include "rstudio.fullname" . }}
4+
name: {{ include "rstudio.fullname" . }}-service
55
labels:
66
{{- include "rstudio.labels" . | nindent 4 }}
77
spec:

rstudio/values.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,13 @@ service:
3838
port: 80
3939

4040
ingress:
41+
access_path: /rstudio/
4142
enabled: true
4243
annotations:
4344
nginx.ingress.kubernetes.io/rewrite-target: /$2
45+
nginx.ingress.kubernetes.io/configuration-snippet: |
46+
# This extra rewrite restores the original url because keycloak gatekeeper expects the non-rewritten path
47+
rewrite "{{ .Values.ingress.access_path }}oauth(/|$)(.*)" {{ .Values.ingress.access_path }}oauth/$2 break;
4448
# kubernetes.io/ingress.class: nginx
4549
# kubernetes.io/tls-acme: "true"
4650
hosts:
@@ -70,6 +74,11 @@ tolerations: []
7074

7175
affinity: {}
7276

77+
oidc:
78+
client_id: "rstudio"
79+
client_secret: "some_secret"
80+
discovery_url: "http://cloudman-keycloak-http.cloudman.svc.cluster.local/auth/realms/master"
81+
7382
persistence:
7483
enabled: true
7584
name: rstudio-pvc

0 commit comments

Comments
 (0)