-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add staticSites that can be protected by oauth2-proxy
- Loading branch information
Showing
9 changed files
with
169 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{{- if .Values.staticSites.enabled -}} | ||
kind: ConfigMap | ||
apiVersion: v1 | ||
metadata: | ||
name: static-sites | ||
labels: | ||
app: static-sites | ||
data: | ||
nginx.conf: | | ||
server { | ||
listen 8080; | ||
location {{ .Values.staticSites.path }} { | ||
index index.html; | ||
alias /srv/content/repo; | ||
} | ||
} | ||
{{- end }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
{{- if .Values.staticSites.enabled -}} | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: static-sites | ||
spec: | ||
replicas: 1 | ||
selector: | ||
matchLabels: | ||
app: static-sites | ||
template: | ||
metadata: | ||
labels: | ||
app: static-sites | ||
annotations: | ||
checksum/config: {{ include (print $.Template.BasePath "/static/configmap.yaml") . | sha256sum }} | ||
spec: | ||
volumes: | ||
- name: nginx-config | ||
configMap: | ||
name: static-sites | ||
- name: content | ||
emptyDir: {} | ||
initContainers: | ||
- name: site-clone | ||
image: alpine/git | ||
args: | ||
- clone | ||
- --depth=1 | ||
- --branch={{ .Values.staticSites.branch | required "staticSites.branch is required with staticSite.enabled set to true" }} | ||
- --single-branch | ||
- -- | ||
- '{{ .Values.staticSites.repo | required "staticSites.repo is required with staticSites.enabled set to true" }}' | ||
- /srv/content/repo | ||
securityContext: | ||
runAsUser: 1000 | ||
allowPrivilegeEscalation: False | ||
readOnlyRootFilesystem: True | ||
volumeMounts: | ||
- name: content | ||
mountPath: /srv/content | ||
containers: | ||
- name: content-sync | ||
image: alpine/git | ||
workingDir: /srv/content | ||
command: | ||
- /bin/sh | ||
args: | ||
- -c | ||
- "while true; do git fetch origin; git reset --hard origin/{{ .Values.staticSites.branch }}; sleep\ | ||
\ 5m; done" | ||
securityContext: | ||
runAsUser: 1000 | ||
allowPrivilegeEscalation: False | ||
readOnlyRootFilesystem: True | ||
volumeMounts: | ||
- name: content | ||
mountPath: /srv/content | ||
- name: server | ||
image: nginx:1.19 | ||
command: ["/usr/sbin/nginx", "-g", "daemon off;"] | ||
ports: | ||
- name: nginx | ||
containerPort: 8080 | ||
volumeMounts: | ||
- name: nginx-config | ||
mountPath: /etc/nginx/conf.d/default.conf | ||
subPath: nginx.conf | ||
- name: content | ||
mountPath: /srv/content | ||
{{- end }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{{- if .Values.staticSites.enabled -}} | ||
apiVersion: networking.k8s.io/v1 | ||
kind: Ingress | ||
metadata: | ||
annotations: | ||
# Authenticate with oauth2-proxy so only hub logged-in users see this | ||
# https://kubernetes.github.io/ingress-nginx/examples/auth/oauth-external-auth/ | ||
nginx.ingress.kubernetes.io/auth-url: "http://dex.{{ .Release.Namespace }}.svc.cluster.local:9000/services/oauth2-proxy/oauth2/auth" | ||
nginx.ingress.kubernetes.io/auth-signin: "https://$host/services/oauth2-proxy/oauth2/start?rd=$escaped_request_uri" | ||
name: static-sites | ||
spec: | ||
ingressClassName: nginx | ||
rules: | ||
- host: {{ .Values.staticSites.host}} | ||
http: | ||
paths: | ||
- path: {{ .Values.staticSites.path }} | ||
pathType: Prefix | ||
backend: | ||
service: | ||
name: static-sites | ||
port: | ||
number: 80 | ||
{{- end }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{{- if .Values.staticSites.enabled -}} | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: static-sites | ||
labels: | ||
app: static-sites | ||
spec: | ||
type: ClusterIP | ||
ports: | ||
- name: http | ||
port: 80 | ||
targetPort: nginx | ||
selector: | ||
app: static-sites | ||
{{- end }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters