Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
121 changes: 121 additions & 0 deletions guided-charts/aws-hyperpod/templates/authmiddleware/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
{{- if .Values.authmiddleware.enabled }}
apiVersion: apps/v1
kind: Deployment
metadata:
name: authmiddleware
namespace: {{ .Values.namespace }}
labels:
app: authmiddleware
component: auth
spec:
replicas: {{ .Values.authmiddleware.replicas }}
selector:
matchLabels:
app: authmiddleware
component: auth
strategy:
rollingUpdate:
maxSurge: 1
maxUnavailable: 0
type: RollingUpdate
minReadySeconds: 0
template:
metadata:
labels:
app: authmiddleware
component: auth
spec:
serviceAccountName: jupyter-k8s-authmiddleware
terminationGracePeriodSeconds: 30
containers:
- image: {{ .Values.authmiddleware.repository }}/{{ .Values.authmiddleware.imageName }}:{{ .Values.authmiddleware.imageTag }}
imagePullPolicy: {{ .Values.authmiddleware.imagePullPolicy }}
name: authmiddleware
resources:
requests:
cpu: {{ .Values.authmiddleware.resources.requests.cpu }}
memory: {{ .Values.authmiddleware.resources.requests.memory }}
limits:
cpu: {{ .Values.authmiddleware.resources.limits.cpu }}
memory: {{ .Values.authmiddleware.resources.limits.memory }}
readinessProbe:
httpGet:
path: /health
port: 8080
initialDelaySeconds: 5
periodSeconds: 10
livenessProbe:
httpGet:
path: /health
port: 8080
initialDelaySeconds: 5
periodSeconds: 10
ports:
- name: http
containerPort: 8080
protocol: TCP
securityContext:
capabilities:
drop:
- ALL
readOnlyRootFilesystem: true
runAsUser: 65532
runAsGroup: 65532
env:
- name: PORT
value: "8080"
- name: READ_TIMEOUT
value: "{{ .Values.authmiddleware.readTimeout }}"
- name: WRITE_TIMEOUT
value: "{{ .Values.authmiddleware.writeTimeout }}"
- name: SHUTDOWN_TIMEOUT
value: "{{ .Values.authmiddleware.shutdownTimeout }}"
- name: JWT_VALIDATION_TYPE
value: "{{ .Values.authmiddleware.jwtValidationType }}"
{{- if eq .Values.authmiddleware.jwtValidationType "hmac" }}
- name: JWT_ISSUER
value: "{{ .Values.authmiddleware.jwtIssuer }}"
- name: JWT_AUDIENCE
value: "{{ .Values.authmiddleware.jwtAudience }}"
- name: JWT_EXPIRATION
value: "{{ .Values.authmiddleware.jwtExpiration }}"
- name: JWT_REFRESH_WINDOW
value: "{{ .Values.authmiddleware.jwtRefreshWindow }}"
- name: JWT_REFRESH_HORIZON
value: "{{ .Values.authmiddleware.jwtRefreshHorizon }}"
- name: COOKIE_NAME
value: "{{ .Values.authmiddleware.cookieName }}"
- name: COOKIE_SECURE
value: "{{ .Values.authmiddleware.cookieSecure }}"
- name: COOKIE_DOMAIN
value: "{{ .Values.domain }}"
- name: COOKIE_PATH
value: "{{ .Values.authmiddleware.cookiePath }}"
- name: COOKIE_MAX_AGE
value: "{{ .Values.authmiddleware.cookieMaxAge }}"
- name: COOKIE_HTTP_ONLY
value: "{{ .Values.authmiddleware.cookieHttpOnly }}"
- name: COOKIE_SAME_SITE
value: "{{ .Values.authmiddleware.cookieSameSite }}"
- name: PATH_REGEX_PATTERN
value: "{{ .Values.authmiddleware.pathRegexPattern }}"
- name: CSRF_COOKIE_NAME
value: "{{ .Values.authmiddleware.csrfCookieName }}"
- name: CSRF_COOKIE_MAX_AGE
value: "{{ .Values.authmiddleware.csrfCookieMaxAge }}"
- name: CSRF_COOKIE_SECURE
value: "{{ .Values.authmiddleware.csrfCookieSecure }}"
- name: ENABLE_BEARER_URL_AUTH
value: "{{ .Values.authmiddleware.enableBearerAuth }}"
volumeMounts:
- name: tmp
mountPath: /tmp
volumes:
- name: tmp
emptyDir: {}
securityContext:
fsGroup: 65532
runAsGroup: 65532
runAsNonRoot: true
runAsUser: 65532
{{- end }}
30 changes: 30 additions & 0 deletions guided-charts/aws-hyperpod/templates/authmiddleware/rbac.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{{- if .Values.authmiddleware.enabled }}
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: jupyter-k8s-authmiddleware
namespace: {{ .Values.namespace }}
labels:
app: authmiddleware
component: auth
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: authmiddleware-role
rules: [] # No Kubernetes API permissions needed
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Watch out: you might need these permissions for cookie renewal

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will add in follow up. atm it seems it will be tripped by this.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just confirming: not updating this?

---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: authmiddleware-rolebinding
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: authmiddleware-role
subjects:
- kind: ServiceAccount
name: jupyter-k8s-authmiddleware
namespace: {{ .Values.namespace }}
{{- end }}
20 changes: 20 additions & 0 deletions guided-charts/aws-hyperpod/templates/authmiddleware/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{{- if .Values.authmiddleware.enabled }}
apiVersion: v1
kind: Service
metadata:
name: authmiddleware
namespace: {{ .Values.namespace }}
labels:
app: authmiddleware
component: auth
spec:
type: ClusterIP
selector:
app: authmiddleware
component: auth
ports:
- port: 8080
targetPort: 8080
protocol: TCP
name: http
{{- end }}
87 changes: 87 additions & 0 deletions guided-charts/aws-hyperpod/templates/traefik/auth-middlewares.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
apiVersion: traefik.io/v1alpha1
kind: Middleware
metadata:
name: auth-headers
namespace: {{ .Values.namespace }}
spec:
headers:
sslRedirect: true
stsSeconds: 315360000
browserXssFilter: true
contentTypeNosniff: true
forceSTSHeader: true
sslHost: {{ .Values.domain }}
stsIncludeSubdomains: true
stsPreload: true
frameDeny: true
---
{{- if .Values.authmiddleware.enabled }}
apiVersion: traefik.io/v1alpha1
kind: Middleware
metadata:
name: authmiddleware-bearer-auth
namespace: {{ .Values.namespace }}
labels:
app: authmiddleware
component: auth
spec:
forwardAuth:
address: "http://authmiddleware.{{ .Values.namespace }}:8080/bearer-auth"
trustForwardHeader: true
addAuthCookiesToResponse:
- "{{ .Values.authmiddleware.cookieName }}"
- "{{ .Values.authmiddleware.csrfCookieName }}"
authRequestHeaders:
- "Cookie"
- "X-Forwarded-Uri"
- "X-Forwarded-Host"
- "X-Forwarded-Proto"
---
apiVersion: traefik.io/v1alpha1
kind: Middleware
metadata:
name: authmiddleware-verify
namespace: {{ .Values.namespace }}
labels:
app: authmiddleware
component: auth
spec:
forwardAuth:
address: "http://authmiddleware.{{ .Values.namespace }}:8080/verify"
trustForwardHeader: true
addAuthCookiesToResponse:
- "{{ .Values.authmiddleware.cookieName }}"
- "{{ .Values.authmiddleware.csrfCookieName }}"
authRequestHeaders:
- "Cookie"
- "X-Forwarded-Uri"
- "X-Forwarded-Host"
- "X-Forwarded-Proto"
{{- end }}
---
apiVersion: traefik.io/v1alpha1
kind: Middleware
metadata:
name: workspace-auth-redirect
namespace: {{ .Values.namespace }}
labels:
app: authmiddleware
component: auth
spec:
redirectRegex:
regex: "^(https?://[^/]+/workspaces/[^/]+/[^/]+)/?$"
replacement: "${1}/bearer-auth"
permanent: false
---
apiVersion: traefik.io/v1alpha1
kind: Middleware
metadata:
name: strip-bearer-auth-suffix
namespace: {{ .Values.namespace }}
labels:
app: authmiddleware
component: auth
spec:
replacePathRegex:
regex: "^(/workspaces/[^/]+/[^/]+)/bearer-auth$"
replacement: "$1/"
131 changes: 131 additions & 0 deletions guided-charts/aws-hyperpod/templates/traefik/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: traefik
namespace: {{ .Values.namespace }}
labels:
app: traefik
component: router
spec:
replicas: {{ .Values.traefik.replicas }}
selector:
matchLabels:
app: traefik
component: router
strategy:
rollingUpdate:
maxSurge: 1
maxUnavailable: 0
type: RollingUpdate
minReadySeconds: 0
template:
metadata:
annotations:
prometheus.io/scrape: "true"
prometheus.io/path: "/metrics"
prometheus.io/port: "9100"
labels:
app: traefik
component: router
spec:
serviceAccountName: jupyter-k8s-traefik
terminationGracePeriodSeconds: 60
hostNetwork: false
affinity:
podAntiAffinity:
preferredDuringSchedulingIgnoredDuringExecution:
- weight: 100
podAffinityTerm:
labelSelector:
matchExpressions:
- key: app
operator: In
values:
- traefik
topologyKey: kubernetes.io/hostname
containers:
- image: {{ .Values.traefik.repository }}/{{ .Values.traefik.imageName }}:{{ .Values.traefik.imageTag }}
imagePullPolicy: IfNotPresent
name: traefik
resources:
requests:
cpu: 100m
memory: 64Mi
limits:
cpu: 500m
memory: 256Mi
readinessProbe:
httpGet:
path: /ping
port: 9000
scheme: HTTP
failureThreshold: 1
initialDelaySeconds: 2
periodSeconds: 10
successThreshold: 1
timeoutSeconds: 2
livenessProbe:
httpGet:
path: /ping
port: 9000
scheme: HTTP
failureThreshold: 3
initialDelaySeconds: 2
periodSeconds: 10
successThreshold: 1
timeoutSeconds: 2
ports:
- name: metrics
containerPort: 9100
protocol: TCP
- name: traefik
containerPort: 9000
protocol: TCP
- name: web
containerPort: 8000
protocol: TCP
- name: websecure
containerPort: 8443
protocol: TCP
securityContext:
capabilities:
drop:
- ALL
readOnlyRootFilesystem: true
runAsUser: 65532
runAsGroup: 65532
volumeMounts:
- name: tmp
mountPath: /tmp
args:
- "--global.checknewversion=false"
- "--global.sendanonymoususage=false"
- "--entrypoints.metrics.address=:9100/tcp"
- "--entrypoints.traefik.address=:9000/tcp"
- "--entrypoints.web.address=:8000/tcp"
{{- if .Values.traefik.redirectHttp }}
- "--entrypoints.web.http.redirections.entryPoint.to=websecure"
- "--entrypoints.web.http.redirections.entryPoint.scheme=https"
- "--entrypoints.web.http.redirections.entryPoint.permanent=true"
{{- end }}
- "--entrypoints.websecure.address=:8443/tcp"
- "--api.dashboard=false"
- "--ping=true"
- "--metrics.prometheus=true"
- "--metrics.prometheus.entrypoint=metrics"
- "--providers.kubernetescrd"
- "--providers.kubernetescrd.allowexternalnameservices=true"
- "--providers.kubernetescrd.allowcrossnamespace={{ .Values.traefik.allowCrossNamespace }}"
- "--providers.kubernetesingress"
- "--entrypoints.websecure.http.tls=true"
{{- if .Values.traefik.debug }}
- "--log.level=DEBUG"
{{- end }}
volumes:
- name: tmp
emptyDir: {}
securityContext:
fsGroup: 65532
runAsGroup: 65532
runAsNonRoot: true
runAsUser: 65532
Loading