Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reimplement portal using strictly nginx-ingress #149

Merged
merged 4 commits into from
Jul 26, 2018
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion incubator/portal/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
apiVersion: v1
description: A Helm chart to provide Portal
name: portal
version: 0.1.0
version: 0.2.0
41 changes: 5 additions & 36 deletions incubator/portal/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -1,21 +1,3 @@
{{/*
Create a default fully qualified proxy name.
*/}}
{{- define "portal.proxy.name" -}}
{{- $diff := dict "nameOverride" "proxy" | dict "Values" -}}
{{- $values := merge $diff . -}}
{{- include "common.name" $values -}}
{{- end -}}

{/*
Create a default fully qualified proxy name.
*/}}
{{- define "portal.proxy.fullname" -}}
{{- $base := default (printf "%s-%s" .Release.Name "proxy") .Values.proxy.fullnameOverride -}}
{{- $diff := dict "fullnameOverride" $base | dict "Values" -}}
{{- $values := merge $diff . -}}
{{- template "common.fullname" $values -}}
{{- end -}}

{/*
Create a default fully qualified oauth2-proxy name.
Expand All @@ -28,9 +10,9 @@ Create a default fully qualified oauth2-proxy name.
{{- end -}}

{/*
Schema
scheme
*/}}
{{- define "portal.schema" -}}
{{- define "portal.scheme" -}}
{{- if .Values.ingress.tls.enabled -}}
{{- printf "https" -}}
{{- else -}}
Expand All @@ -43,32 +25,19 @@ Schema
External auth auth-url endpoint
*/}}
{{- define "portal.auth-url" -}}
{{- printf "%s://$host/oauth2/auth" (include "portal.schema" . ) -}}
{{- printf "%s://$host/oauth2/auth" (include "portal.scheme" . ) -}}
{{- end -}}

{/*
External auth auth-signin endpoint
*/}}
{{- define "portal.auth-signin" -}}
{{- printf "%s://$host/oauth2/start" (include "portal.schema" . ) -}}
{{- printf "%s://$host/oauth2/start?rd=$request_uri" (include "portal.scheme" . ) -}}
{{- end -}}

{/*
External auth auth-request-redirect endpoint
*/}}
{{- define "portal.auth-request-redirect" -}}
{{- printf "%s://$host/" (include "portal.schema" . ) -}}
{{- printf "%s://$host/" (include "portal.scheme" . ) -}}
{{- end -}}

{{- /*
portal.proxy.labels.standard prints the standard Helm labels for proxy.

The standard labels are frequently used in metadata.
*/ -}}
{{- define "portal.proxy.labels.standard" -}}
app: {{ template "portal.proxy.name" . }}
chart: {{ template "common.chartref" . }}
heritage: {{ .Release.Service | quote }}
release: {{ .Release.Name | quote }}
{{- end -}}

Original file line number Diff line number Diff line change
@@ -1,30 +1,39 @@
{{- if .Values.ingress.enabled -}}

{{- $root := . -}}
{{- $servicePort := .Values.proxy.service.externalPort -}}
{{- $serviceName := include "portal.proxy.fullname" . -}}
{{- $serviceName := include "common.fullname" . -}}

{{- $basehost := .Values.config.basehost -}}

{{ range $name, $value := .Values.backends }}
{{ if not $value.external }}

{{ if $value.externalName }}
---
apiVersion: v1
kind: Service
metadata:
name: {{ include "common.fullname" $root }}-{{ $name }}
labels:
{{ include "common.labels.standard" $root | indent 4 }}
spec:
type: ExternalName
externalName: {{ $value.externalName | quote }}
{{ end }}
---
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: {{ include "portal.proxy.fullname" $root }}-{{ $name }}
name: {{ include "common.fullname" $root }}-{{ $name }}
annotations:
kubernetes.io/tls-acme: {{ $root.Values.ingress.tls.enabled | quote }}
ingress.kubernetes.io/auth-signin: {{ template "portal.auth-signin" $root }}
ingress.kubernetes.io/auth-url: {{ template "portal.auth-url" $root }}
ingress.kubernetes.io/auth-request-redirect: {{ template "portal.auth-request-redirect" $root }}
nginx.ingress.kubernetes.io/auth-signin: {{ template "portal.auth-signin" $root }}
nginx.ingress.kubernetes.io/auth-url: {{ template "portal.auth-url" $root }}
nginx.ingress.kubernetes.io/auth-request-redirect: {{ template "portal.auth-request-redirect" $root }}

{{- if $root.Values.ingress.dns.enabled }}
domainName: {{ printf "%s.%s" $name $basehost | quote }}
{{- end }}
{{ if $value.tls }}
nginx.ingress.kubernetes.io/secure-backends: "true"
nginx.ingress.kubernetes.io/server-snippet: "proxy_ssl_verify off;"
Copy link

Choose a reason for hiding this comment

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

It would be nice to have verify as its own flag. You may want TLS AND verification of certs

{{ end }}

{{- if $root.Values.ingress.annotations }}
{{ toYaml $root.Values.ingress.annotations | indent 4 }}
Expand All @@ -38,27 +47,26 @@ metadata:
{{ toYaml $root.Values.ingress.labels | indent 4 }}
{{- end }}

{{- if $root.Values.ingress.dns.enabled }}
dns: "route53"
{{- end }}

spec:
rules:
- host: {{ printf "%s.%s" $name $basehost | quote }}
- host: {{ printf $root.Values.config.hostnameFormat $name $basehost | quote }}
http:
paths:
- path: /
backend:
serviceName: {{ $serviceName }}
servicePort: {{ $servicePort }}

{{ if $value.externalName }}
serviceName: {{ include "common.fullname" $root }}-{{ $name }}
{{ else }}
serviceName: {{ $value.serviceName }}
{{ end }}
servicePort: {{ $value.servicePort }}
{{- if $root.Values.ingress.tls.enabled }}
tls:
- secretName: {{ $serviceName }}-{{ $name }}-tls
hosts:
- {{ printf "%s.%s" $name $basehost | quote }}
- {{ printf $root.Values.config.hostnameFormat $name $basehost | quote }}
{{- end -}}

{{- end -}}
{{- end -}}
{{- end }}
{{- end }}
9 changes: 5 additions & 4 deletions incubator/portal/templates/dashboard.configmap.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{{- $basehost := .Values.config.basehost -}}
{{- $schema := ( include "portal.schema" . ) -}}
{{- $hostnameFormat := .Values.config.hostnameFormat -}}
{{- $scheme := ( include "portal.scheme" . ) -}}
---
apiVersion: v1
kind: ConfigMap
Expand Down Expand Up @@ -42,7 +43,7 @@ data:
{{ $url := $value.endpoint }}
<a class="nav-link" id="{{ $name }}-link" href="{{ $url }}" data-toggle="collapse" data-target="#{{ $name }}" aria-expanded="false" aria-controls="{{ $name }}">{{ $value.name }}</a>
{{ else }}
{{ $url := ( printf "%s://%s.%s" $schema $name $basehost ) }}
{{ $url := ( printf (cat "%s://" $hostnameFormat | nospace) $scheme $name $basehost ) }}
<a class="nav-link" id="{{ $name }}-link" href="{{ $url }}" data-toggle="collapse" data-target="#{{ $name }}" aria-expanded="false" aria-controls="{{ $name }}">{{ $value.name }}</a>
{{ end }}
</li>
Expand All @@ -57,7 +58,7 @@ data:
{{ $url := $value.endpoint }}
<iframe class="embed-responsive-item collapse" aria-labelledby="{{ $name }}-link" data-parent="#accordion" id="{{ $name }}" data-src="{{ $url }}" allowfullscreen></iframe>
{{ else }}
{{ $url := ( printf "%s://%s.%s" $schema $name $basehost ) }}
{{ $url := ( printf (cat "%s://" $hostnameFormat | nospace) $scheme $name $basehost ) }}
<iframe class="embed-responsive-item collapse" aria-labelledby="{{ $name }}-link" data-parent="#accordion" id="{{ $name }}" data-src="{{ $url }}" allowfullscreen></iframe>
{{ end }}
{{ end }}
Expand Down Expand Up @@ -116,4 +117,4 @@ data:
the <a href="http://nginx.org/r/error_log">error log</a> for details.</p>
<p><em>Faithfully yours, nginx.</em></p>
</body>
</html>
</html>
10 changes: 0 additions & 10 deletions incubator/portal/templates/dashboard.ingress.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,9 @@ metadata:
name: {{ include "common.fullname" $root }}
annotations:
kubernetes.io/tls-acme: {{ $root.Values.ingress.tls.enabled | quote }}
ingress.kubernetes.io/auth-signin: {{ template "portal.auth-signin" . }}
ingress.kubernetes.io/auth-url: {{ template "portal.auth-url" . }}
nginx.ingress.kubernetes.io/auth-signin: {{ template "portal.auth-signin" . }}
nginx.ingress.kubernetes.io/auth-url: {{ template "portal.auth-url" . }}

{{- if $root.Values.ingress.dns.enabled }}
domainName: {{ $root.Values.config.basehost | quote }}
{{- end }}

{{- if $root.Values.ingress.annotations }}
{{ toYaml $root.Values.ingress.annotations | indent 4 }}
{{- end }}
Expand All @@ -26,10 +20,6 @@ metadata:
ingressName: "portal"
{{ include "common.labels.standard" $root | indent 4 }}

{{- if $root.Values.ingress.dns.enabled }}
dns: "route53"
{{- end }}

{{- if $root.Values.ingress.labels }}
{{ toYaml $root.Values.ingress.labels | indent 4 }}
{{- end }}
Expand Down
7 changes: 7 additions & 0 deletions incubator/portal/templates/dashboard.oauth.ingress.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@ apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: {{ include "common.fullname" $root }}-oauth2
annotations:
kubernetes.io/tls-acme: {{ $root.Values.ingress.tls.enabled | quote }}

{{- if $root.Values.ingress.annotations }}
{{ toYaml $root.Values.ingress.annotations | indent 4 }}
{{- end }}

spec:
rules:
- host: {{ $root.Values.config.basehost | quote }}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,31 +1,36 @@

{{- if .Values.ingress.enabled -}}

{{- $root := . -}}
{{- $serviceName := include "portal.proxy.fullname" . -}}
{{- $serviceName := include "common.fullname" . -}}
{{- $basehost := .Values.config.basehost -}}

{{ range $name, $value := .Values.backends }}
{{ if not $value.external }}
---
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: {{ include "portal.proxy.fullname" $root }}-{{ $name }}-oauth
name: {{ $serviceName }}-{{ $name }}-oauth
annotations:

{{- if $root.Values.ingress.annotations }}
{{ toYaml $root.Values.ingress.annotations | indent 4 }}
{{- end }}

spec:
rules:
- host: {{ printf "%s.%s" $name $basehost | quote }}
- host: {{ printf $root.Values.config.hostnameFormat $name $basehost | quote }}
http:
paths:
- path: /oauth2
backend:
serviceName: {{ template "portal.oauth2-proxy.fullname" $root }}
servicePort: {{ $root.Values.oauth2.externalPort }}

{{- if $root.Values.ingress.tls.enabled }}
tls:
- secretName: {{ $serviceName }}-{{ $name }}-tls
hosts:
- {{ printf "%s.%s" $name $basehost | quote }}
- {{ printf $root.Values.config.hostnameFormat $name $basehost | quote }}
{{- end -}}

{{- end -}}
Expand Down
50 changes: 0 additions & 50 deletions incubator/portal/templates/proxy.configmap.yaml

This file was deleted.

55 changes: 0 additions & 55 deletions incubator/portal/templates/proxy.deployment.yaml

This file was deleted.